aboutsummaryrefslogtreecommitdiffstats
path: root/components/net/storage_thread.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2016-07-27 10:03:53 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2016-07-27 10:25:48 +0200
commit8d919c5c1fe58142822879ac9d08e5b46d2b23a1 (patch)
tree16adc8e458d61df5828d426d61ae65a088bfa6f8 /components/net/storage_thread.rs
parent1662e292d8c3ec85329a204d57c5c07e4cc743ad (diff)
downloadservo-8d919c5c1fe58142822879ac9d08e5b46d2b23a1.tar.gz
servo-8d919c5c1fe58142822879ac9d08e5b46d2b23a1.zip
Remove use of util::opts from storage_thread
Diffstat (limited to 'components/net/storage_thread.rs')
-rw-r--r--components/net/storage_thread.rs25
1 files changed, 13 insertions, 12 deletions
diff --git a/components/net/storage_thread.rs b/components/net/storage_thread.rs
index 3432e6aa873..0e7c7647420 100644
--- a/components/net/storage_thread.rs
+++ b/components/net/storage_thread.rs
@@ -8,23 +8,22 @@ use resource_thread;
use std::borrow::ToOwned;
use std::collections::BTreeMap;
use std::collections::HashMap;
-use std::path::Path;
+use std::path::PathBuf;
use url::Url;
-use util::opts;
use util::thread::spawn_named;
const QUOTA_SIZE_LIMIT: usize = 5 * 1024 * 1024;
pub trait StorageThreadFactory {
- fn new() -> Self;
+ fn new(config_dir: Option<PathBuf>) -> Self;
}
impl StorageThreadFactory for IpcSender<StorageThreadMsg> {
/// Create a storage thread
- fn new() -> IpcSender<StorageThreadMsg> {
+ fn new(config_dir: Option<PathBuf>) -> IpcSender<StorageThreadMsg> {
let (chan, port) = ipc::channel().unwrap();
spawn_named("StorageManager".to_owned(), move || {
- StorageManager::new(port).start();
+ StorageManager::new(port, config_dir).start();
});
chan
}
@@ -34,19 +33,22 @@ struct StorageManager {
port: IpcReceiver<StorageThreadMsg>,
session_data: HashMap<String, (usize, BTreeMap<String, String>)>,
local_data: HashMap<String, (usize, BTreeMap<String, String>)>,
+ config_dir: Option<PathBuf>,
}
impl StorageManager {
- fn new(port: IpcReceiver<StorageThreadMsg>) -> StorageManager {
+ fn new(port: IpcReceiver<StorageThreadMsg>,
+ config_dir: Option<PathBuf>)
+ -> StorageManager {
let mut local_data = HashMap::new();
- if let Some(ref config_dir) = opts::get().config_dir {
- resource_thread::read_json_from_file(
- &mut local_data, Path::new(config_dir), "local_data.json");
+ if let Some(ref config_dir) = config_dir {
+ resource_thread::read_json_from_file(&mut local_data, config_dir, "local_data.json");
}
StorageManager {
port: port,
session_data: HashMap::new(),
local_data: local_data,
+ config_dir: config_dir,
}
}
}
@@ -77,9 +79,8 @@ impl StorageManager {
self.clear(sender, url, storage_type)
}
StorageThreadMsg::Exit(sender) => {
- if let Some(ref config_dir) = opts::get().config_dir {
- resource_thread::write_json_to_file(
- &self.local_data, Path::new(config_dir), "local_data.json");
+ if let Some(ref config_dir) = self.config_dir {
+ resource_thread::write_json_to_file(&self.local_data, config_dir, "local_data.json");
}
let _ = sender.send(());
break