Skip to content

Commit

Permalink
Stop wrapping FileManager in an Arc.
Browse files Browse the repository at this point in the history
It already contains an Arc internally.
  • Loading branch information
Ms2ger committed Oct 14, 2016
1 parent 53b6343 commit d820387
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions components/net/blob_loader.rs
Expand Up @@ -23,7 +23,7 @@ use util::thread::spawn_named;
// TODO: Check on GET
// https://w3c.github.io/FileAPI/#requestResponseModel

pub fn factory<UI: 'static + UIProvider>(filemanager: Arc<FileManager<UI>>)
pub fn factory<UI: 'static + UIProvider>(filemanager: FileManager<UI>)
-> Box<FnBox(LoadData, LoadConsumer, Arc<MimeClassifier>, CancellationListener) + Send> {
box move |load_data: LoadData, start_chan, classifier, cancel_listener| {
spawn_named(format!("blob loader for {}", load_data.url), move || {
Expand All @@ -35,7 +35,7 @@ pub fn factory<UI: 'static + UIProvider>(filemanager: Arc<FileManager<UI>>)
fn load_blob<UI: 'static + UIProvider>
(load_data: LoadData, start_chan: LoadConsumer,
classifier: Arc<MimeClassifier>,
filemanager: Arc<FileManager<UI>>,
filemanager: FileManager<UI>,
cancel_listener: CancellationListener) {
let (chan, recv) = ipc::channel().unwrap();
if let Ok((id, origin, _fragment)) = parse_blob_url(&load_data.url.clone()) {
Expand Down
9 changes: 9 additions & 0 deletions components/net/filemanager_thread.rs
Expand Up @@ -116,6 +116,15 @@ pub struct FileManager<UI: 'static + UIProvider> {
store: Arc<FileManagerStore<UI>>,
}

// Not derived to avoid an unnecessary `UI: Clone` bound.
impl<UI: 'static + UIProvider> Clone for FileManager<UI> {
fn clone(&self) -> Self {
FileManager {
store: self.store.clone(),
}
}
}

impl<UI: 'static + UIProvider> FileManager<UI> {
pub fn new(ui: &'static UI) -> FileManager<UI> {
FileManager {
Expand Down
4 changes: 2 additions & 2 deletions components/net/resource_thread.rs
Expand Up @@ -475,7 +475,7 @@ pub struct CoreResourceManager {
devtools_chan: Option<Sender<DevtoolsControlMsg>>,
swmanager_chan: Option<IpcSender<CustomResponseMediator>>,
profiler_chan: ProfilerChan,
filemanager: Arc<FileManager<TFDProvider>>,
filemanager: FileManager<TFDProvider>,
cancel_load_map: HashMap<ResourceId, Sender<()>>,
next_resource_id: ResourceId,
}
Expand All @@ -490,7 +490,7 @@ impl CoreResourceManager {
devtools_chan: devtools_channel,
swmanager_chan: None,
profiler_chan: profiler_chan,
filemanager: Arc::new(FileManager::new(TFD_PROVIDER)),
filemanager: FileManager::new(TFD_PROVIDER),
cancel_load_map: HashMap::new(),
next_resource_id: ResourceId(0),
}
Expand Down

0 comments on commit d820387

Please sign in to comment.