aboutsummaryrefslogtreecommitdiffstats
path: root/components/net_traits
diff options
context:
space:
mode:
Diffstat (limited to 'components/net_traits')
-rw-r--r--components/net_traits/Cargo.toml1
-rw-r--r--components/net_traits/lib.rs34
2 files changed, 35 insertions, 0 deletions
diff --git a/components/net_traits/Cargo.toml b/components/net_traits/Cargo.toml
index 0822ff7054d..296ca750b57 100644
--- a/components/net_traits/Cargo.toml
+++ b/components/net_traits/Cargo.toml
@@ -30,3 +30,4 @@ image = "0.5.0"
serde = "0.6"
serde_macros = "0.6"
url = "0.5"
+websocket = "0.14.0"
diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs
index 267163fad53..5da54d7c241 100644
--- a/components/net_traits/lib.rs
+++ b/components/net_traits/lib.rs
@@ -23,6 +23,7 @@ extern crate serde;
extern crate stb_image;
extern crate url;
extern crate util;
+extern crate websocket;
use hyper::header::{ContentType, Headers};
use hyper::http::RawStatus;
@@ -225,10 +226,43 @@ pub enum IncludeSubdomains {
NotIncluded
}
+#[derive(HeapSizeOf, Deserialize, Serialize)]
+pub enum MessageData {
+ Text(String),
+ Binary(Vec<u8>),
+}
+
+#[derive(Deserialize, Serialize)]
+pub enum WebSocketDomAction {
+ SendMessage(MessageData),
+ Close(u16, String),
+}
+
+#[derive(Deserialize, Serialize)]
+pub enum WebSocketNetworkEvent {
+ ConnectionEstablished,
+ MessageReceived(MessageData),
+ Close,
+}
+
+#[derive(Deserialize, Serialize)]
+pub struct WebSocketCommunicate {
+ pub event_sender: IpcSender<WebSocketNetworkEvent>,
+ pub action_receiver: IpcReceiver<WebSocketDomAction>,
+}
+
+#[derive(Deserialize, Serialize)]
+pub struct WebSocketConnectData {
+ pub resource_url: Url,
+ pub origin: String,
+}
+
#[derive(Deserialize, Serialize)]
pub enum ControlMsg {
/// Request the data associated with a particular URL
Load(LoadData, LoadConsumer, Option<IpcSender<ResourceId>>),
+ /// Try to make a websocket connection to a URL.
+ WebsocketConnect(WebSocketCommunicate, WebSocketConnectData),
/// Store a set of cookies for a given originating URL
SetCookiesForUrl(Url, String, CookieSource),
/// Retrieve the stored cookies for a given URL