mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Use serde in devtools
This commit is contained in:
parent
77444d00be
commit
406273c641
23 changed files with 245 additions and 233 deletions
|
@ -26,7 +26,6 @@ git = "https://github.com/servo/ipc-channel"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
hyper = { version = "0.8", features = [ "serde-serialization" ] }
|
hyper = { version = "0.8", features = [ "serde-serialization" ] }
|
||||||
log = "0.3.5"
|
log = "0.3.5"
|
||||||
rustc-serialize = "0.3"
|
|
||||||
serde = "0.7"
|
serde = "0.7"
|
||||||
serde_json = "0.7"
|
serde_json = "0.7"
|
||||||
serde_macros = "0.7"
|
serde_macros = "0.7"
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
/// General actor system infrastructure.
|
/// General actor system infrastructure.
|
||||||
|
|
||||||
use devtools_traits::PreciseTime;
|
use devtools_traits::PreciseTime;
|
||||||
use rustc_serialize::json;
|
use serde_json::Value;
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::collections::HashMap;
|
use std::collections::{BTreeMap, HashMap};
|
||||||
use std::mem::replace;
|
use std::mem::replace;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
@ -26,7 +26,7 @@ pub trait Actor: Any + ActorAsAny {
|
||||||
fn handle_message(&self,
|
fn handle_message(&self,
|
||||||
registry: &ActorRegistry,
|
registry: &ActorRegistry,
|
||||||
msg_type: &str,
|
msg_type: &str,
|
||||||
msg: &json::Object,
|
msg: &BTreeMap<String, Value>,
|
||||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()>;
|
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()>;
|
||||||
fn name(&self) -> String;
|
fn name(&self) -> String;
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ impl ActorRegistry {
|
||||||
/// Attempt to process a message as directed by its `to` property. If the actor is not
|
/// Attempt to process a message as directed by its `to` property. If the actor is not
|
||||||
/// found or does not indicate that it knew how to process the message, ignore the failure.
|
/// found or does not indicate that it knew how to process the message, ignore the failure.
|
||||||
pub fn handle_message(&mut self,
|
pub fn handle_message(&mut self,
|
||||||
msg: &json::Object,
|
msg: &BTreeMap<String, Value>,
|
||||||
stream: &mut TcpStream)
|
stream: &mut TcpStream)
|
||||||
-> Result<(), ()> {
|
-> Result<(), ()> {
|
||||||
let to = msg.get("to").unwrap().as_string().unwrap();
|
let to = msg.get("to").unwrap().as_string().unwrap();
|
||||||
|
|
|
@ -16,30 +16,30 @@ use devtools_traits::{CONSOLE_API, CachedConsoleMessageTypes, DevtoolScriptContr
|
||||||
use ipc_channel::ipc::{self, IpcSender};
|
use ipc_channel::ipc::{self, IpcSender};
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use protocol::JsonPacketStream;
|
use protocol::JsonPacketStream;
|
||||||
use rustc_serialize::json::{self, Json, ToJson};
|
use serde_json::{self, Value};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
|
|
||||||
trait EncodableConsoleMessage {
|
trait EncodableConsoleMessage {
|
||||||
fn encode(&self) -> json::EncodeResult<String>;
|
fn encode(&self) -> serde_json::Result<String>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EncodableConsoleMessage for CachedConsoleMessage {
|
impl EncodableConsoleMessage for CachedConsoleMessage {
|
||||||
fn encode(&self) -> json::EncodeResult<String> {
|
fn encode(&self) -> serde_json::Result<String> {
|
||||||
match *self {
|
match *self {
|
||||||
CachedConsoleMessage::PageError(ref a) => json::encode(a),
|
CachedConsoleMessage::PageError(ref a) => serde_json::to_string(a),
|
||||||
CachedConsoleMessage::ConsoleAPI(ref a) => json::encode(a),
|
CachedConsoleMessage::ConsoleAPI(ref a) => serde_json::to_string(a),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct StartedListenersTraits {
|
struct StartedListenersTraits {
|
||||||
customNetworkRequest: bool,
|
customNetworkRequest: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct StartedListenersReply {
|
struct StartedListenersReply {
|
||||||
from: String,
|
from: String,
|
||||||
nativeConsoleAPI: bool,
|
nativeConsoleAPI: bool,
|
||||||
|
@ -47,37 +47,37 @@ struct StartedListenersReply {
|
||||||
traits: StartedListenersTraits,
|
traits: StartedListenersTraits,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct GetCachedMessagesReply {
|
struct GetCachedMessagesReply {
|
||||||
from: String,
|
from: String,
|
||||||
messages: Vec<json::Object>,
|
messages: Vec<BTreeMap<String, Value>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct StopListenersReply {
|
struct StopListenersReply {
|
||||||
from: String,
|
from: String,
|
||||||
stoppedListeners: Vec<String>,
|
stoppedListeners: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct AutocompleteReply {
|
struct AutocompleteReply {
|
||||||
from: String,
|
from: String,
|
||||||
matches: Vec<String>,
|
matches: Vec<String>,
|
||||||
matchProp: String,
|
matchProp: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct EvaluateJSReply {
|
struct EvaluateJSReply {
|
||||||
from: String,
|
from: String,
|
||||||
input: String,
|
input: String,
|
||||||
result: Json,
|
result: Value,
|
||||||
timestamp: u64,
|
timestamp: u64,
|
||||||
exception: Json,
|
exception: Value,
|
||||||
exceptionMessage: String,
|
exceptionMessage: String,
|
||||||
helperResult: Json,
|
helperResult: Value,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct SetPreferencesReply {
|
struct SetPreferencesReply {
|
||||||
from: String,
|
from: String,
|
||||||
updated: Vec<String>,
|
updated: Vec<String>,
|
||||||
|
@ -98,7 +98,7 @@ impl Actor for ConsoleActor {
|
||||||
fn handle_message(&self,
|
fn handle_message(&self,
|
||||||
registry: &ActorRegistry,
|
registry: &ActorRegistry,
|
||||||
msg_type: &str,
|
msg_type: &str,
|
||||||
msg: &json::Object,
|
msg: &BTreeMap<String, Value>,
|
||||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||||
Ok(match msg_type {
|
Ok(match msg_type {
|
||||||
"getCachedMessages" => {
|
"getCachedMessages" => {
|
||||||
|
@ -118,7 +118,7 @@ impl Actor for ConsoleActor {
|
||||||
self.pipeline, message_types, chan)).unwrap();
|
self.pipeline, message_types, chan)).unwrap();
|
||||||
let messages = try!(port.recv().map_err(|_| ())).into_iter().map(|message| {
|
let messages = try!(port.recv().map_err(|_| ())).into_iter().map(|message| {
|
||||||
let json_string = message.encode().unwrap();
|
let json_string = message.encode().unwrap();
|
||||||
let json = Json::from_str(&json_string).unwrap();
|
let json = serde_json::from_str::<Value>(&json_string).unwrap();
|
||||||
json.as_object().unwrap().to_owned()
|
json.as_object().unwrap().to_owned()
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
|
@ -183,49 +183,49 @@ impl Actor for ConsoleActor {
|
||||||
let result = match try!(port.recv().map_err(|_| ())) {
|
let result = match try!(port.recv().map_err(|_| ())) {
|
||||||
VoidValue => {
|
VoidValue => {
|
||||||
let mut m = BTreeMap::new();
|
let mut m = BTreeMap::new();
|
||||||
m.insert("type".to_owned(), "undefined".to_owned().to_json());
|
m.insert("type".to_owned(), serde_json::to_value("undefined"));
|
||||||
Json::Object(m)
|
Value::Object(m)
|
||||||
}
|
}
|
||||||
NullValue => {
|
NullValue => {
|
||||||
let mut m = BTreeMap::new();
|
let mut m = BTreeMap::new();
|
||||||
m.insert("type".to_owned(), "null".to_owned().to_json());
|
m.insert("type".to_owned(), serde_json::to_value("null"));
|
||||||
Json::Object(m)
|
Value::Object(m)
|
||||||
}
|
}
|
||||||
BooleanValue(val) => val.to_json(),
|
BooleanValue(val) => Value::Bool(val),
|
||||||
NumberValue(val) => {
|
NumberValue(val) => {
|
||||||
if val.is_nan() {
|
if val.is_nan() {
|
||||||
let mut m = BTreeMap::new();
|
let mut m = BTreeMap::new();
|
||||||
m.insert("type".to_owned(), "NaN".to_owned().to_json());
|
m.insert("type".to_owned(), serde_json::to_value("NaN"));
|
||||||
Json::Object(m)
|
Value::Object(m)
|
||||||
} else if val.is_infinite() {
|
} else if val.is_infinite() {
|
||||||
let mut m = BTreeMap::new();
|
let mut m = BTreeMap::new();
|
||||||
if val < 0. {
|
if val < 0. {
|
||||||
m.insert("type".to_owned(), "-Infinity".to_owned().to_json());
|
m.insert("type".to_owned(), serde_json::to_value("-Infinity"));
|
||||||
} else {
|
} else {
|
||||||
m.insert("type".to_owned(), "Infinity".to_owned().to_json());
|
m.insert("type".to_owned(), serde_json::to_value("Infinity"));
|
||||||
}
|
}
|
||||||
Json::Object(m)
|
Value::Object(m)
|
||||||
} else if val == 0. && val.is_sign_negative() {
|
} else if val == 0. && val.is_sign_negative() {
|
||||||
let mut m = BTreeMap::new();
|
let mut m = BTreeMap::new();
|
||||||
m.insert("type".to_owned(), "-0".to_owned().to_json());
|
m.insert("type".to_owned(), serde_json::to_value("-0"));
|
||||||
Json::Object(m)
|
Value::Object(m)
|
||||||
} else {
|
} else {
|
||||||
val.to_json()
|
serde_json::to_value(&val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StringValue(s) => s.to_json(),
|
StringValue(s) => Value::String(s),
|
||||||
ActorValue { class, uuid } => {
|
ActorValue { class, uuid } => {
|
||||||
//TODO: make initial ActorValue message include these properties?
|
//TODO: make initial ActorValue message include these properties?
|
||||||
let mut m = BTreeMap::new();
|
let mut m = BTreeMap::new();
|
||||||
let actor = ObjectActor::new(registry, uuid);
|
let actor = ObjectActor::new(registry, uuid);
|
||||||
|
|
||||||
m.insert("type".to_owned(), "object".to_owned().to_json());
|
m.insert("type".to_owned(), serde_json::to_value("object"));
|
||||||
m.insert("class".to_owned(), class.to_json());
|
m.insert("class".to_owned(), serde_json::to_value(&class));
|
||||||
m.insert("actor".to_owned(), actor.to_json());
|
m.insert("actor".to_owned(), serde_json::to_value(&actor));
|
||||||
m.insert("extensible".to_owned(), true.to_json());
|
m.insert("extensible".to_owned(), Value::Bool(true));
|
||||||
m.insert("frozen".to_owned(), false.to_json());
|
m.insert("frozen".to_owned(), Value::Bool(false));
|
||||||
m.insert("sealed".to_owned(), false.to_json());
|
m.insert("sealed".to_owned(), Value::Bool(false));
|
||||||
Json::Object(m)
|
Value::Object(m)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -235,9 +235,9 @@ impl Actor for ConsoleActor {
|
||||||
input: input,
|
input: input,
|
||||||
result: result,
|
result: result,
|
||||||
timestamp: 0,
|
timestamp: 0,
|
||||||
exception: Json::Object(BTreeMap::new()),
|
exception: Value::Object(BTreeMap::new()),
|
||||||
exceptionMessage: "".to_owned(),
|
exceptionMessage: "".to_owned(),
|
||||||
helperResult: Json::Object(BTreeMap::new()),
|
helperResult: Value::Object(BTreeMap::new()),
|
||||||
};
|
};
|
||||||
stream.write_json_packet(&msg);
|
stream.write_json_packet(&msg);
|
||||||
ActorMessageStatus::Processed
|
ActorMessageStatus::Processed
|
||||||
|
|
|
@ -7,7 +7,8 @@ use actors::timeline::HighResolutionStamp;
|
||||||
use devtools_traits::DevtoolScriptControlMsg;
|
use devtools_traits::DevtoolScriptControlMsg;
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use rustc_serialize::json;
|
use serde_json::Value;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
use time::precise_time_ns;
|
use time::precise_time_ns;
|
||||||
|
@ -30,7 +31,7 @@ impl Actor for FramerateActor {
|
||||||
fn handle_message(&self,
|
fn handle_message(&self,
|
||||||
_registry: &ActorRegistry,
|
_registry: &ActorRegistry,
|
||||||
_msg_type: &str,
|
_msg_type: &str,
|
||||||
_msg: &json::Object,
|
_msg: &BTreeMap<String, Value>,
|
||||||
_stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
_stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||||
Ok(ActorMessageStatus::Ignored)
|
Ok(ActorMessageStatus::Ignored)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,7 @@ use devtools_traits::{ComputedNodeLayout, DevtoolScriptControlMsg, NodeInfo};
|
||||||
use ipc_channel::ipc::{self, IpcSender};
|
use ipc_channel::ipc::{self, IpcSender};
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use protocol::JsonPacketStream;
|
use protocol::JsonPacketStream;
|
||||||
use rustc_serialize::json::{self, Json};
|
use serde_json::{self, Value};
|
||||||
use serde_json;
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
|
@ -27,13 +26,13 @@ pub struct InspectorActor {
|
||||||
pub pipeline: PipelineId,
|
pub pipeline: PipelineId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct GetHighlighterReply {
|
struct GetHighlighterReply {
|
||||||
highligter: HighlighterMsg, // sic.
|
highligter: HighlighterMsg, // sic.
|
||||||
from: String,
|
from: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct HighlighterMsg {
|
struct HighlighterMsg {
|
||||||
actor: String,
|
actor: String,
|
||||||
}
|
}
|
||||||
|
@ -48,12 +47,12 @@ pub struct NodeActor {
|
||||||
pipeline: PipelineId,
|
pipeline: PipelineId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct ShowBoxModelReply {
|
struct ShowBoxModelReply {
|
||||||
from: String,
|
from: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct HideBoxModelReply {
|
struct HideBoxModelReply {
|
||||||
from: String,
|
from: String,
|
||||||
}
|
}
|
||||||
|
@ -66,7 +65,7 @@ impl Actor for HighlighterActor {
|
||||||
fn handle_message(&self,
|
fn handle_message(&self,
|
||||||
_registry: &ActorRegistry,
|
_registry: &ActorRegistry,
|
||||||
msg_type: &str,
|
msg_type: &str,
|
||||||
_msg: &json::Object,
|
_msg: &BTreeMap<String, Value>,
|
||||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||||
Ok(match msg_type {
|
Ok(match msg_type {
|
||||||
"showBoxModel" => {
|
"showBoxModel" => {
|
||||||
|
@ -90,7 +89,7 @@ impl Actor for HighlighterActor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct ModifyAttributeReply {
|
struct ModifyAttributeReply {
|
||||||
from: String,
|
from: String,
|
||||||
}
|
}
|
||||||
|
@ -103,14 +102,14 @@ impl Actor for NodeActor {
|
||||||
fn handle_message(&self,
|
fn handle_message(&self,
|
||||||
registry: &ActorRegistry,
|
registry: &ActorRegistry,
|
||||||
msg_type: &str,
|
msg_type: &str,
|
||||||
msg: &json::Object,
|
msg: &BTreeMap<String, Value>,
|
||||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||||
Ok(match msg_type {
|
Ok(match msg_type {
|
||||||
"modifyAttributes" => {
|
"modifyAttributes" => {
|
||||||
let target = msg.get("to").unwrap().as_string().unwrap();
|
let target = msg.get("to").unwrap().as_string().unwrap();
|
||||||
let mods = msg.get("modifications").unwrap().as_array().unwrap();
|
let mods = msg.get("modifications").unwrap().as_array().unwrap();
|
||||||
let modifications = mods.iter().map(|json_mod| {
|
let modifications = mods.iter().map(|json_mod| {
|
||||||
json::decode(&json_mod.to_string()).unwrap()
|
serde_json::from_str(&serde_json::to_string(json_mod).unwrap()).unwrap()
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
self.script_chan.send(ModifyAttribute(self.pipeline,
|
self.script_chan.send(ModifyAttribute(self.pipeline,
|
||||||
|
@ -129,26 +128,26 @@ impl Actor for NodeActor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct GetWalkerReply {
|
struct GetWalkerReply {
|
||||||
from: String,
|
from: String,
|
||||||
walker: WalkerMsg,
|
walker: WalkerMsg,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct WalkerMsg {
|
struct WalkerMsg {
|
||||||
actor: String,
|
actor: String,
|
||||||
root: NodeActorMsg,
|
root: NodeActorMsg,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct AttrMsg {
|
struct AttrMsg {
|
||||||
namespace: String,
|
namespace: String,
|
||||||
name: String,
|
name: String,
|
||||||
value: String,
|
value: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct NodeActorMsg {
|
struct NodeActorMsg {
|
||||||
actor: String,
|
actor: String,
|
||||||
baseURI: String,
|
baseURI: String,
|
||||||
|
@ -245,23 +244,23 @@ struct WalkerActor {
|
||||||
pipeline: PipelineId,
|
pipeline: PipelineId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct QuerySelectorReply {
|
struct QuerySelectorReply {
|
||||||
from: String,
|
from: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct DocumentElementReply {
|
struct DocumentElementReply {
|
||||||
from: String,
|
from: String,
|
||||||
node: NodeActorMsg,
|
node: NodeActorMsg,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct ClearPseudoclassesReply {
|
struct ClearPseudoclassesReply {
|
||||||
from: String,
|
from: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct ChildrenReply {
|
struct ChildrenReply {
|
||||||
hasFirst: bool,
|
hasFirst: bool,
|
||||||
hasLast: bool,
|
hasLast: bool,
|
||||||
|
@ -277,7 +276,7 @@ impl Actor for WalkerActor {
|
||||||
fn handle_message(&self,
|
fn handle_message(&self,
|
||||||
registry: &ActorRegistry,
|
registry: &ActorRegistry,
|
||||||
msg_type: &str,
|
msg_type: &str,
|
||||||
msg: &json::Object,
|
msg: &BTreeMap<String, Value>,
|
||||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||||
Ok(match msg_type {
|
Ok(match msg_type {
|
||||||
"querySelector" => {
|
"querySelector" => {
|
||||||
|
@ -336,13 +335,13 @@ impl Actor for WalkerActor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct GetPageStyleReply {
|
struct GetPageStyleReply {
|
||||||
from: String,
|
from: String,
|
||||||
pageStyle: PageStyleMsg,
|
pageStyle: PageStyleMsg,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct PageStyleMsg {
|
struct PageStyleMsg {
|
||||||
actor: String,
|
actor: String,
|
||||||
}
|
}
|
||||||
|
@ -353,7 +352,7 @@ struct PageStyleActor {
|
||||||
pipeline: PipelineId,
|
pipeline: PipelineId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct GetAppliedReply {
|
struct GetAppliedReply {
|
||||||
entries: Vec<AppliedEntry>,
|
entries: Vec<AppliedEntry>,
|
||||||
rules: Vec<AppliedRule>,
|
rules: Vec<AppliedRule>,
|
||||||
|
@ -361,24 +360,25 @@ struct GetAppliedReply {
|
||||||
from: String,
|
from: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct GetComputedReply {
|
struct GetComputedReply {
|
||||||
computed: Vec<u32>, //XXX all css props
|
computed: Vec<u32>, //XXX all css props
|
||||||
from: String,
|
from: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct AppliedEntry {
|
struct AppliedEntry {
|
||||||
rule: String,
|
rule: String,
|
||||||
pseudoElement: Json,
|
pseudoElement: Value,
|
||||||
isSystem: bool,
|
isSystem: bool,
|
||||||
matchedSelectors: Vec<String>,
|
matchedSelectors: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct AppliedRule {
|
struct AppliedRule {
|
||||||
actor: String,
|
actor: String,
|
||||||
__type__: u32,
|
#[serde(rename = "type")]
|
||||||
|
type_: String,
|
||||||
href: String,
|
href: String,
|
||||||
cssText: String,
|
cssText: String,
|
||||||
line: u32,
|
line: u32,
|
||||||
|
@ -386,7 +386,7 @@ struct AppliedRule {
|
||||||
parentStyleSheet: String,
|
parentStyleSheet: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct AppliedSheet {
|
struct AppliedSheet {
|
||||||
actor: String,
|
actor: String,
|
||||||
href: String,
|
href: String,
|
||||||
|
@ -451,7 +451,7 @@ impl Actor for PageStyleActor {
|
||||||
fn handle_message(&self,
|
fn handle_message(&self,
|
||||||
registry: &ActorRegistry,
|
registry: &ActorRegistry,
|
||||||
msg_type: &str,
|
msg_type: &str,
|
||||||
msg: &json::Object,
|
msg: &BTreeMap<String, Value>,
|
||||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||||
Ok(match msg_type {
|
Ok(match msg_type {
|
||||||
"getApplied" => {
|
"getApplied" => {
|
||||||
|
@ -493,7 +493,7 @@ impl Actor for PageStyleActor {
|
||||||
} = rx.recv().unwrap();
|
} = rx.recv().unwrap();
|
||||||
|
|
||||||
let auto_margins = msg.get("autoMargins")
|
let auto_margins = msg.get("autoMargins")
|
||||||
.and_then(&Json::as_boolean).unwrap_or(false);
|
.and_then(&Value::as_boolean).unwrap_or(false);
|
||||||
|
|
||||||
// http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/styles.js
|
// http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/styles.js
|
||||||
let msg = GetLayoutReply {
|
let msg = GetLayoutReply {
|
||||||
|
@ -528,8 +528,8 @@ impl Actor for PageStyleActor {
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
};
|
};
|
||||||
let msg = &serde_json::to_string(&msg).unwrap();
|
let msg = serde_json::to_string(&msg).unwrap();
|
||||||
let msg = Json::from_str(msg).unwrap();
|
let msg = serde_json::from_str::<Value>(&msg).unwrap();
|
||||||
stream.write_json_packet(&msg);
|
stream.write_json_packet(&msg);
|
||||||
ActorMessageStatus::Processed
|
ActorMessageStatus::Processed
|
||||||
}
|
}
|
||||||
|
@ -547,7 +547,7 @@ impl Actor for InspectorActor {
|
||||||
fn handle_message(&self,
|
fn handle_message(&self,
|
||||||
registry: &ActorRegistry,
|
registry: &ActorRegistry,
|
||||||
msg_type: &str,
|
msg_type: &str,
|
||||||
_msg: &json::Object,
|
_msg: &BTreeMap<String, Value>,
|
||||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||||
Ok(match msg_type {
|
Ok(match msg_type {
|
||||||
"getWalker" => {
|
"getWalker" => {
|
||||||
|
|
|
@ -3,10 +3,11 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
||||||
use rustc_serialize::json;
|
use serde_json::Value;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
pub struct TimelineMemoryReply {
|
pub struct TimelineMemoryReply {
|
||||||
jsObjectSize: u64,
|
jsObjectSize: u64,
|
||||||
jsStringSize: u64,
|
jsStringSize: u64,
|
||||||
|
@ -31,7 +32,7 @@ impl Actor for MemoryActor {
|
||||||
fn handle_message(&self,
|
fn handle_message(&self,
|
||||||
_registry: &ActorRegistry,
|
_registry: &ActorRegistry,
|
||||||
_msg_type: &str,
|
_msg_type: &str,
|
||||||
_msg: &json::Object,
|
_msg: &BTreeMap<String, Value>,
|
||||||
_stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
_stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||||
Ok(ActorMessageStatus::Ignored)
|
Ok(ActorMessageStatus::Ignored)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,8 @@ use hyper::header::{ContentType, Cookie};
|
||||||
use hyper::http::RawStatus;
|
use hyper::http::RawStatus;
|
||||||
use hyper::method::Method;
|
use hyper::method::Method;
|
||||||
use protocol::JsonPacketStream;
|
use protocol::JsonPacketStream;
|
||||||
use rustc_serialize::json;
|
use serde_json::Value;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
use time;
|
use time;
|
||||||
use time::Tm;
|
use time::Tm;
|
||||||
|
@ -41,7 +42,7 @@ pub struct NetworkEventActor {
|
||||||
response: HttpResponse,
|
response: HttpResponse,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
pub struct EventActor {
|
pub struct EventActor {
|
||||||
pub actor: String,
|
pub actor: String,
|
||||||
pub url: String,
|
pub url: String,
|
||||||
|
@ -51,12 +52,12 @@ pub struct EventActor {
|
||||||
pub private: bool
|
pub private: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
pub struct ResponseCookiesMsg {
|
pub struct ResponseCookiesMsg {
|
||||||
pub cookies: u32,
|
pub cookies: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
pub struct ResponseStartMsg {
|
pub struct ResponseStartMsg {
|
||||||
pub httpVersion: String,
|
pub httpVersion: String,
|
||||||
pub remoteAddress: String,
|
pub remoteAddress: String,
|
||||||
|
@ -67,7 +68,7 @@ pub struct ResponseStartMsg {
|
||||||
pub discardResponseBody: bool,
|
pub discardResponseBody: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
pub struct ResponseContentMsg {
|
pub struct ResponseContentMsg {
|
||||||
pub mimeType: String,
|
pub mimeType: String,
|
||||||
pub contentSize: u32,
|
pub contentSize: u32,
|
||||||
|
@ -76,19 +77,19 @@ pub struct ResponseContentMsg {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
pub struct ResponseHeadersMsg {
|
pub struct ResponseHeadersMsg {
|
||||||
pub headers: u32,
|
pub headers: u32,
|
||||||
pub headersSize: u32,
|
pub headersSize: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
pub struct RequestCookiesMsg {
|
pub struct RequestCookiesMsg {
|
||||||
pub cookies: u32,
|
pub cookies: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct GetRequestHeadersReply {
|
struct GetRequestHeadersReply {
|
||||||
from: String,
|
from: String,
|
||||||
headers: Vec<String>,
|
headers: Vec<String>,
|
||||||
|
@ -96,7 +97,7 @@ struct GetRequestHeadersReply {
|
||||||
rawHeaders: String
|
rawHeaders: String
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct GetResponseHeadersReply {
|
struct GetResponseHeadersReply {
|
||||||
from: String,
|
from: String,
|
||||||
headers: Vec<String>,
|
headers: Vec<String>,
|
||||||
|
@ -104,33 +105,33 @@ struct GetResponseHeadersReply {
|
||||||
rawHeaders: String
|
rawHeaders: String
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct GetResponseContentReply {
|
struct GetResponseContentReply {
|
||||||
from: String,
|
from: String,
|
||||||
content: Option<Vec<u8>>,
|
content: Option<Vec<u8>>,
|
||||||
contentDiscarded: bool,
|
contentDiscarded: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct GetRequestPostDataReply {
|
struct GetRequestPostDataReply {
|
||||||
from: String,
|
from: String,
|
||||||
postData: Option<Vec<u8>>,
|
postData: Option<Vec<u8>>,
|
||||||
postDataDiscarded: bool
|
postDataDiscarded: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct GetRequestCookiesReply {
|
struct GetRequestCookiesReply {
|
||||||
from: String,
|
from: String,
|
||||||
cookies: Vec<u8>
|
cookies: Vec<u8>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct GetResponseCookiesReply {
|
struct GetResponseCookiesReply {
|
||||||
from: String,
|
from: String,
|
||||||
cookies: Vec<u8>
|
cookies: Vec<u8>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct Timings {
|
struct Timings {
|
||||||
blocked: u32,
|
blocked: u32,
|
||||||
dns: u32,
|
dns: u32,
|
||||||
|
@ -140,14 +141,14 @@ struct Timings {
|
||||||
receive: u32,
|
receive: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct GetEventTimingsReply {
|
struct GetEventTimingsReply {
|
||||||
from: String,
|
from: String,
|
||||||
timings: Timings,
|
timings: Timings,
|
||||||
totalTime: u32,
|
totalTime: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct GetSecurityInfoReply {
|
struct GetSecurityInfoReply {
|
||||||
from: String,
|
from: String,
|
||||||
seuritInfo: String,
|
seuritInfo: String,
|
||||||
|
@ -162,7 +163,7 @@ impl Actor for NetworkEventActor {
|
||||||
fn handle_message(&self,
|
fn handle_message(&self,
|
||||||
_registry: &ActorRegistry,
|
_registry: &ActorRegistry,
|
||||||
msg_type: &str,
|
msg_type: &str,
|
||||||
_msg: &json::Object,
|
_msg: &BTreeMap<String, Value>,
|
||||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||||
Ok(match msg_type {
|
Ok(match msg_type {
|
||||||
"getRequestHeaders" => {
|
"getRequestHeaders" => {
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
||||||
use rustc_serialize::json;
|
use serde_json::Value;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
|
|
||||||
pub struct ObjectActor {
|
pub struct ObjectActor {
|
||||||
|
@ -18,7 +19,7 @@ impl Actor for ObjectActor {
|
||||||
fn handle_message(&self,
|
fn handle_message(&self,
|
||||||
_: &ActorRegistry,
|
_: &ActorRegistry,
|
||||||
_: &str,
|
_: &str,
|
||||||
_: &json::Object,
|
_: &BTreeMap<String, Value>,
|
||||||
_: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
_: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||||
Ok(ActorMessageStatus::Ignored)
|
Ok(ActorMessageStatus::Ignored)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,15 @@
|
||||||
|
|
||||||
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
||||||
use protocol::JsonPacketStream;
|
use protocol::JsonPacketStream;
|
||||||
use rustc_serialize::json;
|
use serde_json::Value;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
|
|
||||||
pub struct PerformanceActor {
|
pub struct PerformanceActor {
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct PerformanceFeatures {
|
struct PerformanceFeatures {
|
||||||
withMarkers: bool,
|
withMarkers: bool,
|
||||||
withMemory: bool,
|
withMemory: bool,
|
||||||
|
@ -20,12 +21,12 @@ struct PerformanceFeatures {
|
||||||
withJITOptimizations: bool,
|
withJITOptimizations: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct PerformanceTraits {
|
struct PerformanceTraits {
|
||||||
features: PerformanceFeatures,
|
features: PerformanceFeatures,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct ConnectReply {
|
struct ConnectReply {
|
||||||
from: String,
|
from: String,
|
||||||
traits: PerformanceTraits,
|
traits: PerformanceTraits,
|
||||||
|
@ -39,7 +40,7 @@ impl Actor for PerformanceActor {
|
||||||
fn handle_message(&self,
|
fn handle_message(&self,
|
||||||
_registry: &ActorRegistry,
|
_registry: &ActorRegistry,
|
||||||
msg_type: &str,
|
msg_type: &str,
|
||||||
_msg: &json::Object,
|
_msg: &BTreeMap<String, Value>,
|
||||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||||
Ok(match msg_type {
|
Ok(match msg_type {
|
||||||
"connect" => {
|
"connect" => {
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
||||||
use rustc_serialize::json;
|
use serde_json::Value;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
|
|
||||||
pub struct ProfilerActor {
|
pub struct ProfilerActor {
|
||||||
|
@ -18,7 +19,7 @@ impl Actor for ProfilerActor {
|
||||||
fn handle_message(&self,
|
fn handle_message(&self,
|
||||||
_registry: &ActorRegistry,
|
_registry: &ActorRegistry,
|
||||||
_msg_type: &str,
|
_msg_type: &str,
|
||||||
_msg: &json::Object,
|
_msg: &BTreeMap<String, Value>,
|
||||||
_stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
_stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||||
Ok(ActorMessageStatus::Ignored)
|
Ok(ActorMessageStatus::Ignored)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,33 +10,34 @@
|
||||||
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
||||||
use actors::tab::{TabActor, TabActorMsg};
|
use actors::tab::{TabActor, TabActorMsg};
|
||||||
use protocol::JsonPacketStream;
|
use protocol::JsonPacketStream;
|
||||||
use rustc_serialize::json;
|
use serde_json::Value;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct ActorTraits {
|
struct ActorTraits {
|
||||||
sources: bool,
|
sources: bool,
|
||||||
highlightable: bool,
|
highlightable: bool,
|
||||||
customHighlighters: Vec<String>,
|
customHighlighters: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct ListAddonsReply {
|
struct ListAddonsReply {
|
||||||
from: String,
|
from: String,
|
||||||
addons: Vec<AddonMsg>,
|
addons: Vec<AddonMsg>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
enum AddonMsg {}
|
enum AddonMsg {}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct ListTabsReply {
|
struct ListTabsReply {
|
||||||
from: String,
|
from: String,
|
||||||
selected: u32,
|
selected: u32,
|
||||||
tabs: Vec<TabActorMsg>,
|
tabs: Vec<TabActorMsg>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
pub struct RootActorMsg {
|
pub struct RootActorMsg {
|
||||||
from: String,
|
from: String,
|
||||||
applicationType: String,
|
applicationType: String,
|
||||||
|
@ -55,7 +56,7 @@ impl Actor for RootActor {
|
||||||
fn handle_message(&self,
|
fn handle_message(&self,
|
||||||
registry: &ActorRegistry,
|
registry: &ActorRegistry,
|
||||||
msg_type: &str,
|
msg_type: &str,
|
||||||
_msg: &json::Object,
|
_msg: &BTreeMap<String, Value>,
|
||||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||||
Ok(match msg_type {
|
Ok(match msg_type {
|
||||||
"listAddons" => {
|
"listAddons" => {
|
||||||
|
|
|
@ -11,40 +11,43 @@ use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
||||||
use actors::console::ConsoleActor;
|
use actors::console::ConsoleActor;
|
||||||
use devtools_traits::DevtoolScriptControlMsg::WantsLiveNotifications;
|
use devtools_traits::DevtoolScriptControlMsg::WantsLiveNotifications;
|
||||||
use protocol::JsonPacketStream;
|
use protocol::JsonPacketStream;
|
||||||
use rustc_serialize::json;
|
use serde_json::Value;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct TabTraits;
|
struct TabTraits;
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct TabAttachedReply {
|
struct TabAttachedReply {
|
||||||
from: String,
|
from: String,
|
||||||
__type__: String,
|
#[serde(rename = "type")]
|
||||||
|
type_: String,
|
||||||
threadActor: String,
|
threadActor: String,
|
||||||
cacheDisabled: bool,
|
cacheDisabled: bool,
|
||||||
javascriptEnabled: bool,
|
javascriptEnabled: bool,
|
||||||
traits: TabTraits,
|
traits: TabTraits,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct TabDetachedReply {
|
struct TabDetachedReply {
|
||||||
from: String,
|
from: String,
|
||||||
__type__: String,
|
#[serde(rename = "type")]
|
||||||
|
type_: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct ReconfigureReply {
|
struct ReconfigureReply {
|
||||||
from: String
|
from: String
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct ListFramesReply {
|
struct ListFramesReply {
|
||||||
from: String,
|
from: String,
|
||||||
frames: Vec<FrameMsg>,
|
frames: Vec<FrameMsg>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct FrameMsg {
|
struct FrameMsg {
|
||||||
id: u32,
|
id: u32,
|
||||||
url: String,
|
url: String,
|
||||||
|
@ -52,7 +55,7 @@ struct FrameMsg {
|
||||||
parentID: u32,
|
parentID: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
pub struct TabActorMsg {
|
pub struct TabActorMsg {
|
||||||
actor: String,
|
actor: String,
|
||||||
title: String,
|
title: String,
|
||||||
|
@ -85,7 +88,7 @@ impl Actor for TabActor {
|
||||||
fn handle_message(&self,
|
fn handle_message(&self,
|
||||||
registry: &ActorRegistry,
|
registry: &ActorRegistry,
|
||||||
msg_type: &str,
|
msg_type: &str,
|
||||||
_msg: &json::Object,
|
_msg: &BTreeMap<String, Value>,
|
||||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||||
Ok(match msg_type {
|
Ok(match msg_type {
|
||||||
"reconfigure" => {
|
"reconfigure" => {
|
||||||
|
@ -98,7 +101,7 @@ impl Actor for TabActor {
|
||||||
"attach" => {
|
"attach" => {
|
||||||
let msg = TabAttachedReply {
|
let msg = TabAttachedReply {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
__type__: "tabAttached".to_owned(),
|
type_: "tabAttached".to_owned(),
|
||||||
threadActor: self.thread.clone(),
|
threadActor: self.thread.clone(),
|
||||||
cacheDisabled: false,
|
cacheDisabled: false,
|
||||||
javascriptEnabled: true,
|
javascriptEnabled: true,
|
||||||
|
@ -117,7 +120,7 @@ impl Actor for TabActor {
|
||||||
"detach" => {
|
"detach" => {
|
||||||
let msg = TabDetachedReply {
|
let msg = TabDetachedReply {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
__type__: "detached".to_owned(),
|
type_: "detached".to_owned(),
|
||||||
};
|
};
|
||||||
let console_actor = registry.find::<ConsoleActor>(&self.console);
|
let console_actor = registry.find::<ConsoleActor>(&self.console);
|
||||||
console_actor.streams.borrow_mut().pop();
|
console_actor.streams.borrow_mut().pop();
|
||||||
|
|
|
@ -4,33 +4,37 @@
|
||||||
|
|
||||||
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
||||||
use protocol::JsonPacketStream;
|
use protocol::JsonPacketStream;
|
||||||
use rustc_serialize::json;
|
use serde_json::Value;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct ThreadAttachedReply {
|
struct ThreadAttachedReply {
|
||||||
from: String,
|
from: String,
|
||||||
__type__: String,
|
#[serde(rename = "type")]
|
||||||
|
type_: String,
|
||||||
actor: String,
|
actor: String,
|
||||||
poppedFrames: Vec<PoppedFrameMsg>,
|
poppedFrames: Vec<PoppedFrameMsg>,
|
||||||
why: WhyMsg,
|
why: WhyMsg,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
enum PoppedFrameMsg {}
|
enum PoppedFrameMsg {}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct WhyMsg {
|
struct WhyMsg {
|
||||||
__type__: String,
|
#[serde(rename = "type")]
|
||||||
|
type_: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct ThreadResumedReply {
|
struct ThreadResumedReply {
|
||||||
from: String,
|
from: String,
|
||||||
__type__: String,
|
#[serde(rename = "type")]
|
||||||
|
type_: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct ReconfigureReply {
|
struct ReconfigureReply {
|
||||||
from: String
|
from: String
|
||||||
}
|
}
|
||||||
|
@ -55,16 +59,16 @@ impl Actor for ThreadActor {
|
||||||
fn handle_message(&self,
|
fn handle_message(&self,
|
||||||
registry: &ActorRegistry,
|
registry: &ActorRegistry,
|
||||||
msg_type: &str,
|
msg_type: &str,
|
||||||
_msg: &json::Object,
|
_msg: &BTreeMap<String, Value>,
|
||||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||||
Ok(match msg_type {
|
Ok(match msg_type {
|
||||||
"attach" => {
|
"attach" => {
|
||||||
let msg = ThreadAttachedReply {
|
let msg = ThreadAttachedReply {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
__type__: "paused".to_owned(),
|
type_: "paused".to_owned(),
|
||||||
actor: registry.new_name("pause"),
|
actor: registry.new_name("pause"),
|
||||||
poppedFrames: vec![],
|
poppedFrames: vec![],
|
||||||
why: WhyMsg { __type__: "attached".to_owned() },
|
why: WhyMsg { type_: "attached".to_owned() },
|
||||||
};
|
};
|
||||||
stream.write_json_packet(&msg);
|
stream.write_json_packet(&msg);
|
||||||
ActorMessageStatus::Processed
|
ActorMessageStatus::Processed
|
||||||
|
@ -73,7 +77,7 @@ impl Actor for ThreadActor {
|
||||||
"resume" => {
|
"resume" => {
|
||||||
let msg = ThreadResumedReply {
|
let msg = ThreadResumedReply {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
__type__: "resumed".to_owned(),
|
type_: "resumed".to_owned(),
|
||||||
};
|
};
|
||||||
stream.write_json_packet(&msg);
|
stream.write_json_packet(&msg);
|
||||||
ActorMessageStatus::Processed
|
ActorMessageStatus::Processed
|
||||||
|
|
|
@ -11,8 +11,10 @@ use devtools_traits::{PreciseTime, TimelineMarker, TimelineMarkerType};
|
||||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use protocol::JsonPacketStream;
|
use protocol::JsonPacketStream;
|
||||||
use rustc_serialize::{Encodable, Encoder, json};
|
use serde::{Serialize, Serializer};
|
||||||
|
use serde_json::Value;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
@ -41,25 +43,25 @@ struct Emitter {
|
||||||
memory_actor: Option<String>,
|
memory_actor: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct IsRecordingReply {
|
struct IsRecordingReply {
|
||||||
from: String,
|
from: String,
|
||||||
value: bool
|
value: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct StartReply {
|
struct StartReply {
|
||||||
from: String,
|
from: String,
|
||||||
value: HighResolutionStamp,
|
value: HighResolutionStamp,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct StopReply {
|
struct StopReply {
|
||||||
from: String,
|
from: String,
|
||||||
value: HighResolutionStamp,
|
value: HighResolutionStamp,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct TimelineMarkerReply {
|
struct TimelineMarkerReply {
|
||||||
name: String,
|
name: String,
|
||||||
start: HighResolutionStamp,
|
start: HighResolutionStamp,
|
||||||
|
@ -68,25 +70,28 @@ struct TimelineMarkerReply {
|
||||||
endStack: Option<Vec<()>>,
|
endStack: Option<Vec<()>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct MarkersEmitterReply {
|
struct MarkersEmitterReply {
|
||||||
__type__: String,
|
#[serde(rename = "type")]
|
||||||
|
type_: String,
|
||||||
markers: Vec<TimelineMarkerReply>,
|
markers: Vec<TimelineMarkerReply>,
|
||||||
from: String,
|
from: String,
|
||||||
endTime: HighResolutionStamp,
|
endTime: HighResolutionStamp,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct MemoryEmitterReply {
|
struct MemoryEmitterReply {
|
||||||
__type__: String,
|
#[serde(rename = "type")]
|
||||||
|
type_: String,
|
||||||
from: String,
|
from: String,
|
||||||
delta: HighResolutionStamp,
|
delta: HighResolutionStamp,
|
||||||
measurement: TimelineMemoryReply,
|
measurement: TimelineMemoryReply,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct FramerateEmitterReply {
|
struct FramerateEmitterReply {
|
||||||
__type__: String,
|
#[serde(rename = "type")]
|
||||||
|
type_: String,
|
||||||
from: String,
|
from: String,
|
||||||
delta: HighResolutionStamp,
|
delta: HighResolutionStamp,
|
||||||
timestamps: Vec<HighResolutionStamp>,
|
timestamps: Vec<HighResolutionStamp>,
|
||||||
|
@ -110,9 +115,9 @@ impl HighResolutionStamp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Encodable for HighResolutionStamp {
|
impl Serialize for HighResolutionStamp {
|
||||||
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
fn serialize<S: Serializer>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||||
self.0.encode(s)
|
self.0.serialize(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +177,7 @@ impl Actor for TimelineActor {
|
||||||
fn handle_message(&self,
|
fn handle_message(&self,
|
||||||
registry: &ActorRegistry,
|
registry: &ActorRegistry,
|
||||||
msg_type: &str,
|
msg_type: &str,
|
||||||
msg: &json::Object,
|
msg: &BTreeMap<String, Value>,
|
||||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||||
Ok(match msg_type {
|
Ok(match msg_type {
|
||||||
"start" => {
|
"start" => {
|
||||||
|
@ -290,7 +295,7 @@ impl Emitter {
|
||||||
fn send(&mut self, markers: Vec<TimelineMarkerReply>) -> () {
|
fn send(&mut self, markers: Vec<TimelineMarkerReply>) -> () {
|
||||||
let end_time = PreciseTime::now();
|
let end_time = PreciseTime::now();
|
||||||
let reply = MarkersEmitterReply {
|
let reply = MarkersEmitterReply {
|
||||||
__type__: "markers".to_owned(),
|
type_: "markers".to_owned(),
|
||||||
markers: markers,
|
markers: markers,
|
||||||
from: self.from.clone(),
|
from: self.from.clone(),
|
||||||
endTime: HighResolutionStamp::new(self.start_stamp, end_time),
|
endTime: HighResolutionStamp::new(self.start_stamp, end_time),
|
||||||
|
@ -302,7 +307,7 @@ impl Emitter {
|
||||||
let registry = lock.as_mut().unwrap();
|
let registry = lock.as_mut().unwrap();
|
||||||
let framerate_actor = registry.find_mut::<FramerateActor>(actor_name);
|
let framerate_actor = registry.find_mut::<FramerateActor>(actor_name);
|
||||||
let framerateReply = FramerateEmitterReply {
|
let framerateReply = FramerateEmitterReply {
|
||||||
__type__: "framerate".to_owned(),
|
type_: "framerate".to_owned(),
|
||||||
from: framerate_actor.name(),
|
from: framerate_actor.name(),
|
||||||
delta: HighResolutionStamp::new(self.start_stamp, end_time),
|
delta: HighResolutionStamp::new(self.start_stamp, end_time),
|
||||||
timestamps: framerate_actor.take_pending_ticks(),
|
timestamps: framerate_actor.take_pending_ticks(),
|
||||||
|
@ -314,7 +319,7 @@ impl Emitter {
|
||||||
let registry = self.registry.lock().unwrap();
|
let registry = self.registry.lock().unwrap();
|
||||||
let memory_actor = registry.find::<MemoryActor>(actor_name);
|
let memory_actor = registry.find::<MemoryActor>(actor_name);
|
||||||
let memoryReply = MemoryEmitterReply {
|
let memoryReply = MemoryEmitterReply {
|
||||||
__type__: "memory".to_owned(),
|
type_: "memory".to_owned(),
|
||||||
from: memory_actor.name(),
|
from: memory_actor.name(),
|
||||||
delta: HighResolutionStamp::new(self.start_stamp, end_time),
|
delta: HighResolutionStamp::new(self.start_stamp, end_time),
|
||||||
measurement: memory_actor.measure(),
|
measurement: memory_actor.measure(),
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
|
|
||||||
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
||||||
use devtools_traits::WorkerId;
|
use devtools_traits::WorkerId;
|
||||||
use rustc_serialize::json;
|
use serde_json::Value;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
|
|
||||||
pub struct WorkerActor {
|
pub struct WorkerActor {
|
||||||
|
@ -20,7 +21,7 @@ impl Actor for WorkerActor {
|
||||||
fn handle_message(&self,
|
fn handle_message(&self,
|
||||||
_: &ActorRegistry,
|
_: &ActorRegistry,
|
||||||
_: &str,
|
_: &str,
|
||||||
_: &json::Object,
|
_: &BTreeMap<String, Value>,
|
||||||
_: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
_: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||||
Ok(ActorMessageStatus::Processed)
|
Ok(ActorMessageStatus::Processed)
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ extern crate ipc_channel;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
extern crate msg;
|
extern crate msg;
|
||||||
extern crate rustc_serialize;
|
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
extern crate time;
|
extern crate time;
|
||||||
|
@ -80,14 +79,15 @@ mod actors {
|
||||||
}
|
}
|
||||||
mod protocol;
|
mod protocol;
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct ConsoleAPICall {
|
struct ConsoleAPICall {
|
||||||
from: String,
|
from: String,
|
||||||
__type__: String,
|
#[serde(rename = "type")]
|
||||||
|
type_: String,
|
||||||
message: ConsoleMsg,
|
message: ConsoleMsg,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct ConsoleMsg {
|
struct ConsoleMsg {
|
||||||
level: String,
|
level: String,
|
||||||
timeStamp: u64,
|
timeStamp: u64,
|
||||||
|
@ -97,65 +97,73 @@ struct ConsoleMsg {
|
||||||
columnNumber: usize,
|
columnNumber: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct NetworkEventMsg {
|
struct NetworkEventMsg {
|
||||||
from: String,
|
from: String,
|
||||||
__type__: String,
|
#[serde(rename = "type")]
|
||||||
|
type_: String,
|
||||||
eventActor: EventActor,
|
eventActor: EventActor,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct ResponseStartUpdateMsg {
|
struct ResponseStartUpdateMsg {
|
||||||
from: String,
|
from: String,
|
||||||
__type__: String,
|
#[serde(rename = "type")]
|
||||||
|
type_: String,
|
||||||
updateType: String,
|
updateType: String,
|
||||||
response: ResponseStartMsg,
|
response: ResponseStartMsg,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct ResponseContentUpdateMsg {
|
struct ResponseContentUpdateMsg {
|
||||||
from: String,
|
from: String,
|
||||||
__type__: String,
|
#[serde(rename = "type")]
|
||||||
|
type_: String,
|
||||||
updateType: String,
|
updateType: String,
|
||||||
responseContent: ResponseContentMsg,
|
responseContent: ResponseContentMsg,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct ResponseCookiesUpdateMsg {
|
struct ResponseCookiesUpdateMsg {
|
||||||
from: String,
|
from: String,
|
||||||
__type__: String,
|
#[serde(rename = "type")]
|
||||||
|
type_: String,
|
||||||
updateType: String,
|
updateType: String,
|
||||||
responseCookies: ResponseCookiesMsg,
|
responseCookies: ResponseCookiesMsg,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct ResponseHeadersUpdateMsg {
|
struct ResponseHeadersUpdateMsg {
|
||||||
from: String,
|
from: String,
|
||||||
__type__: String,
|
#[serde(rename = "type")]
|
||||||
|
type_: String,
|
||||||
updateType: String,
|
updateType: String,
|
||||||
responseHeaders: ResponseHeadersMsg,
|
responseHeaders: ResponseHeadersMsg,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct RequestCookiesUpdateMsg {
|
struct RequestCookiesUpdateMsg {
|
||||||
from: String,
|
from: String,
|
||||||
__type__: String,
|
#[serde(rename = "type")]
|
||||||
|
type_: String,
|
||||||
updateType: String,
|
updateType: String,
|
||||||
requestcookies: RequestCookiesMsg,
|
requestcookies: RequestCookiesMsg,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct EventTimingsUpdateMsg {
|
struct EventTimingsUpdateMsg {
|
||||||
from: String,
|
from: String,
|
||||||
__type__: String,
|
#[serde(rename = "type")]
|
||||||
|
type_: String,
|
||||||
updateType: String,
|
updateType: String,
|
||||||
totalTime: u32,
|
totalTime: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(Serialize)]
|
||||||
struct SecurityInfoUpdateMsg {
|
struct SecurityInfoUpdateMsg {
|
||||||
from: String,
|
from: String,
|
||||||
__type__: String,
|
#[serde(rename = "type")]
|
||||||
|
type_: String,
|
||||||
updateType: String,
|
updateType: String,
|
||||||
securityState: String,
|
securityState: String,
|
||||||
}
|
}
|
||||||
|
@ -329,7 +337,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||||
let console_actor = actors.find::<ConsoleActor>(&console_actor_name);
|
let console_actor = actors.find::<ConsoleActor>(&console_actor_name);
|
||||||
let msg = ConsoleAPICall {
|
let msg = ConsoleAPICall {
|
||||||
from: console_actor.name.clone(),
|
from: console_actor.name.clone(),
|
||||||
__type__: "consoleAPICall".to_owned(),
|
type_: "consoleAPICall".to_owned(),
|
||||||
message: ConsoleMsg {
|
message: ConsoleMsg {
|
||||||
level: match console_message.logLevel {
|
level: match console_message.logLevel {
|
||||||
LogLevel::Debug => "debug",
|
LogLevel::Debug => "debug",
|
||||||
|
@ -397,7 +405,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||||
//Send a networkEvent message to the client
|
//Send a networkEvent message to the client
|
||||||
let msg = NetworkEventMsg {
|
let msg = NetworkEventMsg {
|
||||||
from: console_actor_name,
|
from: console_actor_name,
|
||||||
__type__: "networkEvent".to_owned(),
|
type_: "networkEvent".to_owned(),
|
||||||
eventActor: actor.event_actor(),
|
eventActor: actor.event_actor(),
|
||||||
};
|
};
|
||||||
for stream in &mut connections {
|
for stream in &mut connections {
|
||||||
|
@ -411,7 +419,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||||
|
|
||||||
let msg7 = RequestCookiesUpdateMsg {
|
let msg7 = RequestCookiesUpdateMsg {
|
||||||
from: netevent_actor_name.clone(),
|
from: netevent_actor_name.clone(),
|
||||||
__type__: "networkEventUpdate".to_owned(),
|
type_: "networkEventUpdate".to_owned(),
|
||||||
updateType: "requestCookies".to_owned(),
|
updateType: "requestCookies".to_owned(),
|
||||||
requestcookies: actor.request_cookies(),
|
requestcookies: actor.request_cookies(),
|
||||||
};
|
};
|
||||||
|
@ -422,7 +430,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||||
//Send a networkEventUpdate (responseStart) to the client
|
//Send a networkEventUpdate (responseStart) to the client
|
||||||
let msg = ResponseStartUpdateMsg {
|
let msg = ResponseStartUpdateMsg {
|
||||||
from: netevent_actor_name.clone(),
|
from: netevent_actor_name.clone(),
|
||||||
__type__: "networkEventUpdate".to_owned(),
|
type_: "networkEventUpdate".to_owned(),
|
||||||
updateType: "responseStart".to_owned(),
|
updateType: "responseStart".to_owned(),
|
||||||
response: actor.response_start()
|
response: actor.response_start()
|
||||||
};
|
};
|
||||||
|
@ -432,7 +440,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||||
}
|
}
|
||||||
let msg2 = EventTimingsUpdateMsg {
|
let msg2 = EventTimingsUpdateMsg {
|
||||||
from: netevent_actor_name.clone(),
|
from: netevent_actor_name.clone(),
|
||||||
__type__: "networkEventUpdate".to_owned(),
|
type_: "networkEventUpdate".to_owned(),
|
||||||
updateType: "eventTimings".to_owned(),
|
updateType: "eventTimings".to_owned(),
|
||||||
totalTime: 0
|
totalTime: 0
|
||||||
};
|
};
|
||||||
|
@ -443,7 +451,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||||
|
|
||||||
let msg3 = SecurityInfoUpdateMsg {
|
let msg3 = SecurityInfoUpdateMsg {
|
||||||
from: netevent_actor_name.clone(),
|
from: netevent_actor_name.clone(),
|
||||||
__type__: "networkEventUpdate".to_owned(),
|
type_: "networkEventUpdate".to_owned(),
|
||||||
updateType: "securityInfo".to_owned(),
|
updateType: "securityInfo".to_owned(),
|
||||||
securityState: "".to_owned(),
|
securityState: "".to_owned(),
|
||||||
};
|
};
|
||||||
|
@ -454,7 +462,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||||
|
|
||||||
let msg4 = ResponseContentUpdateMsg {
|
let msg4 = ResponseContentUpdateMsg {
|
||||||
from: netevent_actor_name.clone(),
|
from: netevent_actor_name.clone(),
|
||||||
__type__: "networkEventUpdate".to_owned(),
|
type_: "networkEventUpdate".to_owned(),
|
||||||
updateType: "responseContent".to_owned(),
|
updateType: "responseContent".to_owned(),
|
||||||
responseContent: actor.response_content(),
|
responseContent: actor.response_content(),
|
||||||
};
|
};
|
||||||
|
@ -465,7 +473,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||||
|
|
||||||
let msg5 = ResponseCookiesUpdateMsg {
|
let msg5 = ResponseCookiesUpdateMsg {
|
||||||
from: netevent_actor_name.clone(),
|
from: netevent_actor_name.clone(),
|
||||||
__type__: "networkEventUpdate".to_owned(),
|
type_: "networkEventUpdate".to_owned(),
|
||||||
updateType: "responseCookies".to_owned(),
|
updateType: "responseCookies".to_owned(),
|
||||||
responseCookies: actor.response_cookies(),
|
responseCookies: actor.response_cookies(),
|
||||||
};
|
};
|
||||||
|
@ -476,7 +484,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||||
|
|
||||||
let msg6 = ResponseHeadersUpdateMsg {
|
let msg6 = ResponseHeadersUpdateMsg {
|
||||||
from: netevent_actor_name.clone(),
|
from: netevent_actor_name.clone(),
|
||||||
__type__: "networkEventUpdate".to_owned(),
|
type_: "networkEventUpdate".to_owned(),
|
||||||
updateType: "responseHeaders".to_owned(),
|
updateType: "responseHeaders".to_owned(),
|
||||||
responseHeaders: actor.response_headers(),
|
responseHeaders: actor.response_headers(),
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,26 +6,25 @@
|
||||||
//! [JSON packets]
|
//! [JSON packets]
|
||||||
//! (https://wiki.mozilla.org/Remote_Debugging_Protocol_Stream_Transport#JSON_Packets).
|
//! (https://wiki.mozilla.org/Remote_Debugging_Protocol_Stream_Transport#JSON_Packets).
|
||||||
|
|
||||||
use rustc_serialize::json::Json;
|
use serde::Serialize;
|
||||||
use rustc_serialize::json::ParserError::{IoError, SyntaxError};
|
use serde_json::{self, Value};
|
||||||
use rustc_serialize::{Encodable, json};
|
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
|
|
||||||
pub trait JsonPacketStream {
|
pub trait JsonPacketStream {
|
||||||
fn write_json_packet<T: Encodable>(&mut self, obj: &T);
|
fn write_json_packet<T: Serialize>(&mut self, obj: &T);
|
||||||
fn read_json_packet(&mut self) -> Result<Option<Json>, String>;
|
fn read_json_packet(&mut self) -> Result<Option<Value>, String>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl JsonPacketStream for TcpStream {
|
impl JsonPacketStream for TcpStream {
|
||||||
fn write_json_packet<T: Encodable>(&mut self, obj: &T) {
|
fn write_json_packet<T: Serialize>(&mut self, obj: &T) {
|
||||||
let s = json::encode(obj).unwrap().replace("__type__", "type");
|
let s = serde_json::to_string(obj).unwrap();
|
||||||
println!("<- {}", s);
|
println!("<- {}", s);
|
||||||
write!(self, "{}:{}", s.len(), s).unwrap();
|
write!(self, "{}:{}", s.len(), s).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_json_packet(&mut self) -> Result<Option<Json>, String> {
|
fn read_json_packet(&mut self) -> Result<Option<Value>, String> {
|
||||||
// https://wiki.mozilla.org/Remote_Debugging_Protocol_Stream_Transport
|
// https://wiki.mozilla.org/Remote_Debugging_Protocol_Stream_Transport
|
||||||
// In short, each JSON packet is [ascii length]:[JSON data of given length]
|
// In short, each JSON packet is [ascii length]:[JSON data of given length]
|
||||||
let mut buffer = vec!();
|
let mut buffer = vec!();
|
||||||
|
@ -50,11 +49,18 @@ impl JsonPacketStream for TcpStream {
|
||||||
let mut packet = String::new();
|
let mut packet = String::new();
|
||||||
self.take(packet_len).read_to_string(&mut packet).unwrap();
|
self.take(packet_len).read_to_string(&mut packet).unwrap();
|
||||||
println!("{}", packet);
|
println!("{}", packet);
|
||||||
return match Json::from_str(&packet) {
|
return match serde_json::from_str(&packet) {
|
||||||
Ok(json) => Ok(Some(json)),
|
Ok(json) => Ok(Some(json)),
|
||||||
Err(err) => match err {
|
Err(err) => match err {
|
||||||
IoError(ioerr) => return Err(ioerr.description().to_owned()),
|
serde_json::Error::Io(ioerr) => {
|
||||||
SyntaxError(_, l, c) => return Err(format!("syntax at {}:{}", l, c)),
|
return Err(ioerr.description().to_owned())
|
||||||
|
},
|
||||||
|
serde_json::Error::Syntax(_, l, c) => {
|
||||||
|
return Err(format!("syntax at {}:{}", l, c))
|
||||||
|
},
|
||||||
|
serde_json::Error::FromUtf8(e) => {
|
||||||
|
return Err(e.description().to_owned())
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
|
@ -25,7 +25,6 @@ heapsize = "0.3.0"
|
||||||
heapsize_plugin = "0.1.2"
|
heapsize_plugin = "0.1.2"
|
||||||
hyper = { version = "0.8", features = [ "serde-serialization" ] }
|
hyper = { version = "0.8", features = [ "serde-serialization" ] }
|
||||||
time = "0.1"
|
time = "0.1"
|
||||||
rustc-serialize = "0.3"
|
|
||||||
bitflags = "0.3"
|
bitflags = "0.3"
|
||||||
serde = "0.7"
|
serde = "0.7"
|
||||||
serde_macros = "0.7"
|
serde_macros = "0.7"
|
||||||
|
|
|
@ -21,7 +21,6 @@ extern crate heapsize;
|
||||||
extern crate hyper;
|
extern crate hyper;
|
||||||
extern crate ipc_channel;
|
extern crate ipc_channel;
|
||||||
extern crate msg;
|
extern crate msg;
|
||||||
extern crate rustc_serialize;
|
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
extern crate time;
|
extern crate time;
|
||||||
extern crate url;
|
extern crate url;
|
||||||
|
@ -32,7 +31,6 @@ use hyper::http::RawStatus;
|
||||||
use hyper::method::Method;
|
use hyper::method::Method;
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use rustc_serialize::{Decodable, Decoder};
|
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
use time::Duration;
|
use time::Duration;
|
||||||
use time::Tm;
|
use time::Tm;
|
||||||
|
@ -218,26 +216,12 @@ pub enum DevtoolScriptControlMsg {
|
||||||
RequestAnimationFrame(PipelineId, String),
|
RequestAnimationFrame(PipelineId, String),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable, Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
pub struct Modification {
|
pub struct Modification {
|
||||||
pub attributeName: String,
|
pub attributeName: String,
|
||||||
pub newValue: Option<String>,
|
pub newValue: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Decodable for Modification {
|
|
||||||
fn decode<D: Decoder>(d: &mut D) -> Result<Modification, D::Error> {
|
|
||||||
d.read_struct("Modification", 2, |d|
|
|
||||||
Ok(Modification {
|
|
||||||
attributeName: try!(d.read_struct_field("attributeName", 0, Decodable::decode)),
|
|
||||||
newValue: match d.read_struct_field("newValue", 1, Decodable::decode) {
|
|
||||||
Ok(opt) => opt,
|
|
||||||
Err(_) => None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Deserialize, Serialize)]
|
#[derive(Clone, Deserialize, Serialize)]
|
||||||
pub enum LogLevel {
|
pub enum LogLevel {
|
||||||
Log,
|
Log,
|
||||||
|
@ -264,9 +248,10 @@ bitflags! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable, Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
pub struct PageError {
|
pub struct PageError {
|
||||||
pub _type: String,
|
#[serde(rename = "type")]
|
||||||
|
pub type_: String,
|
||||||
pub errorMessage: String,
|
pub errorMessage: String,
|
||||||
pub sourceName: String,
|
pub sourceName: String,
|
||||||
pub lineText: String,
|
pub lineText: String,
|
||||||
|
@ -281,9 +266,10 @@ pub struct PageError {
|
||||||
pub private: bool,
|
pub private: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable, Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
pub struct ConsoleAPI {
|
pub struct ConsoleAPI {
|
||||||
pub _type: String,
|
#[serde(rename = "type")]
|
||||||
|
pub type_: String,
|
||||||
pub level: String,
|
pub level: String,
|
||||||
pub filename: String,
|
pub filename: String,
|
||||||
pub lineNumber: u32,
|
pub lineNumber: u32,
|
||||||
|
|
|
@ -167,7 +167,7 @@ pub fn handle_get_cached_messages(_pipeline_id: PipelineId,
|
||||||
// TODO: make script error reporter pass all reported errors
|
// TODO: make script error reporter pass all reported errors
|
||||||
// to devtools and cache them for returning here.
|
// to devtools and cache them for returning here.
|
||||||
let msg = PageError {
|
let msg = PageError {
|
||||||
_type: "PageError".to_owned(),
|
type_: "PageError".to_owned(),
|
||||||
errorMessage: "page error test".to_owned(),
|
errorMessage: "page error test".to_owned(),
|
||||||
sourceName: String::new(),
|
sourceName: String::new(),
|
||||||
lineText: String::new(),
|
lineText: String::new(),
|
||||||
|
@ -186,7 +186,7 @@ pub fn handle_get_cached_messages(_pipeline_id: PipelineId,
|
||||||
if message_types.contains(CONSOLE_API) {
|
if message_types.contains(CONSOLE_API) {
|
||||||
// TODO: do for real
|
// TODO: do for real
|
||||||
let msg = ConsoleAPI {
|
let msg = ConsoleAPI {
|
||||||
_type: "ConsoleAPI".to_owned(),
|
type_: "ConsoleAPI".to_owned(),
|
||||||
level: "error".to_owned(),
|
level: "error".to_owned(),
|
||||||
filename: "http://localhost/~mihai/mozilla/test.html".to_owned(),
|
filename: "http://localhost/~mihai/mozilla/test.html".to_owned(),
|
||||||
lineNumber: 0,
|
lineNumber: 0,
|
||||||
|
|
2
components/servo/Cargo.lock
generated
2
components/servo/Cargo.lock
generated
|
@ -412,7 +412,6 @@ dependencies = [
|
||||||
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_macros 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_macros 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -431,7 +430,6 @@ dependencies = [
|
||||||
"ipc-channel 0.2.1 (git+https://github.com/servo/ipc-channel)",
|
"ipc-channel 0.2.1 (git+https://github.com/servo/ipc-channel)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_macros 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_macros 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
2
ports/cef/Cargo.lock
generated
2
ports/cef/Cargo.lock
generated
|
@ -381,7 +381,6 @@ dependencies = [
|
||||||
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_macros 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_macros 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -400,7 +399,6 @@ dependencies = [
|
||||||
"ipc-channel 0.2.1 (git+https://github.com/servo/ipc-channel)",
|
"ipc-channel 0.2.1 (git+https://github.com/servo/ipc-channel)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_macros 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_macros 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
2
ports/gonk/Cargo.lock
generated
2
ports/gonk/Cargo.lock
generated
|
@ -374,7 +374,6 @@ dependencies = [
|
||||||
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_json 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_macros 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_macros 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -393,7 +392,6 @@ dependencies = [
|
||||||
"ipc-channel 0.2.1 (git+https://github.com/servo/ipc-channel)",
|
"ipc-channel 0.2.1 (git+https://github.com/servo/ipc-channel)",
|
||||||
"msg 0.0.1",
|
"msg 0.0.1",
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_macros 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_macros 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue