aboutsummaryrefslogtreecommitdiffstats
path: root/components/net/filemanager_thread.rs
diff options
context:
space:
mode:
authorMs2ger <Ms2ger@gmail.com>2016-11-18 13:09:23 +0100
committerMs2ger <Ms2ger@gmail.com>2016-11-21 10:37:26 +0100
commitae1340bf506eeef71c026e3da10b010eca59d379 (patch)
tree2fd2c6e4bf6603e0afd5094dbb098cd6307089f5 /components/net/filemanager_thread.rs
parentf672bf9eabdfcf2eca4305c577599900fbb77ea9 (diff)
downloadservo-ae1340bf506eeef71c026e3da10b010eca59d379.tar.gz
servo-ae1340bf506eeef71c026e3da10b010eca59d379.zip
Pass the UIProvider to FileManager::handle() as needed.
Diffstat (limited to 'components/net/filemanager_thread.rs')
-rw-r--r--components/net/filemanager_thread.rs28
1 files changed, 10 insertions, 18 deletions
diff --git a/components/net/filemanager_thread.rs b/components/net/filemanager_thread.rs
index 03aaa22eb38..f109c77c251 100644
--- a/components/net/filemanager_thread.rs
+++ b/components/net/filemanager_thread.rs
@@ -112,26 +112,15 @@ enum FileImpl {
Sliced(Uuid, RelativePos),
}
-pub struct FileManager<UI: 'static + UIProvider> {
+#[derive(Clone)]
+pub struct FileManager {
store: Arc<FileManagerStore>,
- ui: &'static 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(),
- ui: self.ui,
- }
- }
-}
-
-impl<UI: 'static + UIProvider> FileManager<UI> {
- pub fn new(ui: &'static UI) -> FileManager<UI> {
+impl FileManager {
+ pub fn new() -> FileManager {
FileManager {
store: Arc::new(FileManagerStore::new()),
- ui: ui,
}
}
@@ -162,18 +151,21 @@ impl<UI: 'static + UIProvider> FileManager<UI> {
}
/// Message handler
- pub fn handle(&self, msg: FileManagerThreadMsg, cancel_listener: Option<CancellationListener>) {
+ pub fn handle<UI>(&self,
+ msg: FileManagerThreadMsg,
+ cancel_listener: Option<CancellationListener>,
+ ui: &'static UI)
+ where UI: UIProvider + 'static,
+ {
match msg {
FileManagerThreadMsg::SelectFile(filter, sender, origin, opt_test_path) => {
let store = self.store.clone();
- let ui = self.ui;
spawn_named("select file".to_owned(), move || {
store.select_file(filter, sender, origin, opt_test_path, ui);
});
}
FileManagerThreadMsg::SelectFiles(filter, sender, origin, opt_test_paths) => {
let store = self.store.clone();
- let ui = self.ui;
spawn_named("select files".to_owned(), move || {
store.select_files(filter, sender, origin, opt_test_paths, ui);
})