aboutsummaryrefslogtreecommitdiffstats
path: root/components/net_traits/lib.rs
diff options
context:
space:
mode:
authorZhen Zhang <izgzhen@gmail.com>2016-05-17 18:10:07 +0800
committerZhen Zhang <izgzhen@gmail.com>2016-05-23 15:35:46 +0800
commitdd590d088b036e06dd5775237e04ac45de3b1488 (patch)
tree741d109fece881f31cca5848868186aa3863b1e6 /components/net_traits/lib.rs
parent983612751ba6a031d7a22e53bc2baabe64739f1b (diff)
downloadservo-dd590d088b036e06dd5775237e04ac45de3b1488.tar.gz
servo-dd590d088b036e06dd5775237e04ac45de3b1488.zip
Implement file-type functionalities in htmlinputelement and related
Changes include: - Implement file selection and other DOM behaviours in htmlinputelement - Integrate IpcSender<FileManagerThreadMsg> into ResourceThreads - Improve filemanager_thread, including adding type_string field to SelectedFile - Improve interfaces in FileList/File/Blob to accommodate the above changes
Diffstat (limited to 'components/net_traits/lib.rs')
-rw-r--r--components/net_traits/lib.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs
index c940f3b0f68..748d8c56c51 100644
--- a/components/net_traits/lib.rs
+++ b/components/net_traits/lib.rs
@@ -28,6 +28,7 @@ extern crate util;
extern crate uuid;
extern crate websocket;
+use filemanager_thread::FileManagerThreadMsg;
use heapsize::HeapSizeOf;
use hyper::header::{ContentType, Headers};
use hyper::http::RawStatus;
@@ -186,8 +187,13 @@ pub type CoreResourceThread = IpcSender<CoreResourceMsg>;
pub type IpcSendResult = Result<(), IOError>;
+/// Abstraction of the ability to send a particular type of message,
+/// used by net_traits::ResourceThreads to ease the use its IpcSender sub-fields
+/// XXX: If this trait will be used more in future, some auto derive might be appealing
pub trait IpcSend<T> where T: serde::Serialize + serde::Deserialize {
+ /// send message T
fn send(&self, T) -> IpcSendResult;
+ /// get underlying sender
fn sender(&self) -> IpcSender<T>;
}
@@ -200,13 +206,17 @@ pub trait IpcSend<T> where T: serde::Serialize + serde::Deserialize {
pub struct ResourceThreads {
core_thread: CoreResourceThread,
storage_thread: IpcSender<StorageThreadMsg>,
+ filemanager_thread: IpcSender<FileManagerThreadMsg>,
}
impl ResourceThreads {
- pub fn new(c: CoreResourceThread, s: IpcSender<StorageThreadMsg>) -> ResourceThreads {
+ pub fn new(c: CoreResourceThread,
+ s: IpcSender<StorageThreadMsg>,
+ f: IpcSender<FileManagerThreadMsg>) -> ResourceThreads {
ResourceThreads {
core_thread: c,
storage_thread: s,
+ filemanager_thread: f,
}
}
}
@@ -231,6 +241,16 @@ impl IpcSend<StorageThreadMsg> for ResourceThreads {
}
}
+impl IpcSend<FileManagerThreadMsg> for ResourceThreads {
+ fn send(&self, msg: FileManagerThreadMsg) -> IpcSendResult {
+ self.filemanager_thread.send(msg)
+ }
+
+ fn sender(&self) -> IpcSender<FileManagerThreadMsg> {
+ self.filemanager_thread.clone()
+ }
+}
+
// Ignore the sub-fields
impl HeapSizeOf for ResourceThreads {
fn heap_size_of_children(&self) -> usize { 0 }