diff options
Diffstat (limited to 'components/net_traits/lib.rs')
-rw-r--r-- | components/net_traits/lib.rs | 79 |
1 files changed, 14 insertions, 65 deletions
diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs index bd0fae8d777..eb8983f9d10 100644 --- a/components/net_traits/lib.rs +++ b/components/net_traits/lib.rs @@ -9,7 +9,6 @@ #![deny(unsafe_code)] -extern crate bluetooth_traits; extern crate cookie as cookie_rs; extern crate heapsize; #[macro_use] extern crate heapsize_derive; @@ -27,14 +26,13 @@ extern crate num_traits; extern crate serde; #[macro_use] extern crate serde_derive; +extern crate servo_config; extern crate servo_url; extern crate url; -extern crate util; extern crate uuid; extern crate webrender_traits; extern crate websocket; -use bluetooth_traits::{BluetoothResponseListener, BluetoothResponseResult}; use cookie_rs::Cookie; use filemanager_thread::FileManagerThreadMsg; use heapsize::HeapSizeOf; @@ -44,7 +42,6 @@ use hyper::mime::{Attr, Mime}; use hyper_serde::Serde; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::router::ROUTER; -use msg::constellation_msg::PipelineId; use request::{Request, RequestInit}; use response::{HttpsState, Response}; use servo_url::ServoUrl; @@ -238,19 +235,6 @@ impl<T: FetchResponseListener> Action<T> for FetchResponseMsg { } } -impl<T: BluetoothResponseListener> Action<T> for BluetoothResponseResult { - /// Execute the default action on a provided listener. - fn process(self, listener: &mut T) { - listener.response(self) - } -} - -/// A wrapper for a network load that can either be channel or event-based. -#[derive(Deserialize, Serialize)] -pub enum LoadConsumer { - Channel(IpcSender<LoadResponse>), -} - /// Handle to a resource thread pub type CoreResourceThread = IpcSender<CoreResourceMsg>; @@ -361,16 +345,16 @@ pub enum CoreResourceMsg { Fetch(RequestInit, IpcSender<FetchResponseMsg>), /// Try to make a websocket connection to a URL. WebsocketConnect(WebSocketCommunicate, WebSocketConnectData), - /// Store a set of cookies for a given originating URL - SetCookiesForUrl(ServoUrl, String, CookieSource), - /// Store a set of cookies for a given originating URL - SetCookiesForUrlWithData( + /// Store a cookie for a given originating URL + SetCookieForUrl( ServoUrl, #[serde(deserialize_with = "::hyper_serde::deserialize", serialize_with = "::hyper_serde::serialize")] Cookie, CookieSource ), + /// Store cookies for a given originating URL + SetCookiesForUrl(ServoUrl, Vec<Serde<Cookie>>, CookieSource), /// Retrieve the stored cookies for a given URL GetCookiesForUrl(ServoUrl, IpcSender<Option<String>>, CookieSource), /// Get a cookie by name for a given originating URL @@ -401,19 +385,6 @@ pub fn fetch_async<F>(request: RequestInit, core_resource_thread.send(CoreResourceMsg::Fetch(request, action_sender)).unwrap(); } -/// Message sent in response to `Load`. Contains metadata, and a port -/// for receiving the data. -/// -/// Even if loading fails immediately, we send one of these and the -/// progress_port will provide the error. -#[derive(Serialize, Deserialize)] -pub struct LoadResponse { - /// Metadata, such as from HTTP headers. - pub metadata: Metadata, - /// Port for reading data. - pub progress_port: IpcReceiver<ProgressMsg>, -} - #[derive(Clone, Deserialize, Serialize, HeapSizeOf)] pub struct ResourceCorsData { /// CORS Preflight flag @@ -466,24 +437,17 @@ impl Metadata { /// Extract the parts of a Mime that we care about. pub fn set_content_type(&mut self, content_type: Option<&Mime>) { - match self.headers { - None => self.headers = Some(Serde(Headers::new())), - Some(_) => (), + if self.headers.is_none() { + self.headers = Some(Serde(Headers::new())); } - match content_type { - None => (), - Some(mime) => { - if let Some(headers) = self.headers.as_mut() { - headers.set(ContentType(mime.clone())); - } - - self.content_type = Some(Serde(ContentType(mime.clone()))); - let &Mime(_, _, ref parameters) = mime; - for &(ref k, ref v) in parameters { - if &Attr::Charset == k { - self.charset = Some(v.to_string()); - } + if let Some(mime) = content_type { + self.headers.as_mut().unwrap().set(ContentType(mime.clone())); + self.content_type = Some(Serde(ContentType(mime.clone()))); + let Mime(_, _, ref parameters) = *mime; + for &(ref k, ref v) in parameters { + if Attr::Charset == *k { + self.charset = Some(v.to_string()); } } } @@ -499,15 +463,6 @@ pub enum CookieSource { NonHTTP, } -/// Messages sent in response to a `Load` message -#[derive(PartialEq, Debug, Deserialize, Serialize)] -pub enum ProgressMsg { - /// Binary data - there may be multiple of these - Payload(Vec<u8>), - /// Indicates loading is complete, either successfully or not - Done(Result<(), NetworkError>), -} - /// Convenience function for synchronously loading a whole resource. pub fn load_whole_resource(request: RequestInit, core_resource_thread: &CoreResourceThread) @@ -544,12 +499,6 @@ pub fn unwrap_websocket_protocol(wsp: Option<&header::WebSocketProtocol>) -> Opt #[derive(Clone, PartialEq, Eq, Copy, Hash, Debug, Deserialize, Serialize, HeapSizeOf)] pub struct ResourceId(pub u32); -#[derive(Deserialize, Serialize)] -pub enum ConstellationMsg { - /// Queries whether a pipeline or its ancestors are private - IsPrivate(PipelineId, IpcSender<bool>), -} - /// Network errors that have to be exported out of the loaders #[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize, HeapSizeOf)] pub enum NetworkError { |