aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/devtools/actor.rs11
-rw-r--r--components/devtools/actors/console.rs16
-rw-r--r--components/devtools/actors/framerate.rs6
-rw-r--r--components/devtools/actors/inspector.rs48
-rw-r--r--components/devtools/actors/memory.rs6
-rw-r--r--components/devtools/actors/network_event.rs18
-rw-r--r--components/devtools/actors/object.rs6
-rw-r--r--components/devtools/actors/profiler.rs6
-rw-r--r--components/devtools/actors/root.rs10
-rw-r--r--components/devtools/actors/tab.rs14
-rw-r--r--components/devtools/actors/timeline.rs12
-rw-r--r--components/devtools/actors/worker.rs6
12 files changed, 83 insertions, 76 deletions
diff --git a/components/devtools/actor.rs b/components/devtools/actor.rs
index b0cd26e2468..a4201214727 100644
--- a/components/devtools/actor.rs
+++ b/components/devtools/actor.rs
@@ -15,6 +15,12 @@ use std::net::TcpStream;
use std::raw::TraitObject;
use std::sync::{Arc, Mutex};
+#[derive(PartialEq)]
+pub enum ActorMessageStatus {
+ Processed,
+ Ignored,
+}
+
/// A common trait for all devtools actors that encompasses an immutable name
/// and the ability to process messages that are directed to particular actors.
/// TODO: ensure the name is immutable
@@ -23,7 +29,7 @@ pub trait Actor: Any {
registry: &ActorRegistry,
msg_type: &str,
msg: &json::Object,
- stream: &mut TcpStream) -> Result<bool, ()>;
+ stream: &mut TcpStream) -> Result<ActorMessageStatus, ()>;
fn name(&self) -> String;
}
@@ -194,7 +200,8 @@ impl ActorRegistry {
None => println!("message received for unknown actor \"{}\"", to),
Some(actor) => {
let msg_type = msg.get("type").unwrap().as_string().unwrap();
- if !try!(actor.handle_message(self, &msg_type.to_string(), msg, stream)) {
+ if try!(actor.handle_message(self, &msg_type.to_string(), msg, stream))
+ != ActorMessageStatus::Processed {
println!("unexpected message type \"{}\" found for actor \"{}\"",
msg_type, to);
}
diff --git a/components/devtools/actors/console.rs b/components/devtools/actors/console.rs
index 9eca96d6272..b7313230290 100644
--- a/components/devtools/actors/console.rs
+++ b/components/devtools/actors/console.rs
@@ -7,7 +7,7 @@
//! Mediates interaction between the remote web console and equivalent functionality (object
//! inspection, JS evaluation, autocompletion) in Servo.
-use actor::{Actor, ActorRegistry};
+use actor::{Actor, ActorRegistry, ActorMessageStatus};
use actors::object::ObjectActor;
use protocol::JsonPacketStream;
@@ -96,7 +96,7 @@ impl Actor for ConsoleActor {
registry: &ActorRegistry,
msg_type: &str,
msg: &json::Object,
- stream: &mut TcpStream) -> Result<bool, ()> {
+ stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"getCachedMessages" => {
let str_types = msg.get("messageTypes").unwrap().as_array().unwrap().into_iter().map(|json_type| {
@@ -124,7 +124,7 @@ impl Actor for ConsoleActor {
messages: messages,
};
stream.write_json_packet(&msg);
- true
+ ActorMessageStatus::Processed
}
"startListeners" => {
@@ -139,7 +139,7 @@ impl Actor for ConsoleActor {
}
};
stream.write_json_packet(&msg);
- true
+ ActorMessageStatus::Processed
}
"stopListeners" => {
@@ -155,7 +155,7 @@ impl Actor for ConsoleActor {
.collect(),
};
stream.write_json_packet(&msg);
- true
+ ActorMessageStatus::Processed
}
//TODO: implement autocompletion like onAutocomplete in
@@ -167,7 +167,7 @@ impl Actor for ConsoleActor {
matchProp: "".to_string(),
};
stream.write_json_packet(&msg);
- true
+ ActorMessageStatus::Processed
}
"evaluateJS" => {
@@ -237,10 +237,10 @@ impl Actor for ConsoleActor {
helperResult: Json::Object(BTreeMap::new()),
};
stream.write_json_packet(&msg);
- true
+ ActorMessageStatus::Processed
}
- _ => false
+ _ => ActorMessageStatus::Ignored
})
}
}
diff --git a/components/devtools/actors/framerate.rs b/components/devtools/actors/framerate.rs
index ebb6561a9e5..4713046b6c9 100644
--- a/components/devtools/actors/framerate.rs
+++ b/components/devtools/actors/framerate.rs
@@ -10,7 +10,7 @@ use std::sync::{Arc, Mutex};
use time::precise_time_ns;
use msg::constellation_msg::PipelineId;
-use actor::{Actor, ActorRegistry};
+use actor::{Actor, ActorRegistry, ActorMessageStatus};
use actors::timeline::HighResolutionStamp;
use devtools_traits::DevtoolScriptControlMsg;
@@ -33,8 +33,8 @@ impl Actor for FramerateActor {
_registry: &ActorRegistry,
_msg_type: &str,
_msg: &json::Object,
- _stream: &mut TcpStream) -> Result<bool, ()> {
- Ok(false)
+ _stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
+ Ok(ActorMessageStatus::Ignored)
}
}
diff --git a/components/devtools/actors/inspector.rs b/components/devtools/actors/inspector.rs
index 51c31d7e67f..c8508cebefa 100644
--- a/components/devtools/actors/inspector.rs
+++ b/components/devtools/actors/inspector.rs
@@ -9,7 +9,7 @@ use devtools_traits::{DevtoolScriptControlMsg, NodeInfo, ComputedNodeLayout};
use devtools_traits::DevtoolScriptControlMsg::{GetRootNode, GetDocumentElement, GetChildren};
use devtools_traits::DevtoolScriptControlMsg::{GetLayout, ModifyAttribute};
-use actor::{Actor, ActorRegistry};
+use actor::{Actor, ActorRegistry, ActorMessageStatus};
use protocol::JsonPacketStream;
use ipc_channel::ipc::{self, IpcSender};
@@ -69,14 +69,14 @@ impl Actor for HighlighterActor {
_registry: &ActorRegistry,
msg_type: &str,
_msg: &json::Object,
- stream: &mut TcpStream) -> Result<bool, ()> {
+ stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"showBoxModel" => {
let msg = ShowBoxModelReply {
from: self.name(),
};
stream.write_json_packet(&msg);
- true
+ ActorMessageStatus::Processed
}
"hideBoxModel" => {
@@ -84,10 +84,10 @@ impl Actor for HighlighterActor {
from: self.name(),
};
stream.write_json_packet(&msg);
- true
+ ActorMessageStatus::Processed
}
- _ => false,
+ _ => ActorMessageStatus::Ignored,
})
}
}
@@ -106,7 +106,7 @@ impl Actor for NodeActor {
registry: &ActorRegistry,
msg_type: &str,
msg: &json::Object,
- stream: &mut TcpStream) -> Result<bool, ()> {
+ stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"modifyAttributes" => {
let target = msg.get(&"to".to_string()).unwrap().as_string().unwrap();
@@ -123,10 +123,10 @@ impl Actor for NodeActor {
from: self.name(),
};
stream.write_json_packet(&reply);
- true
+ ActorMessageStatus::Processed
}
- _ => false,
+ _ => ActorMessageStatus::Ignored,
})
}
}
@@ -280,14 +280,14 @@ impl Actor for WalkerActor {
registry: &ActorRegistry,
msg_type: &str,
msg: &json::Object,
- stream: &mut TcpStream) -> Result<bool, ()> {
+ stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"querySelector" => {
let msg = QuerySelectorReply {
from: self.name(),
};
stream.write_json_packet(&msg);
- true
+ ActorMessageStatus::Processed
}
"documentElement" => {
@@ -301,7 +301,7 @@ impl Actor for WalkerActor {
node: node,
};
stream.write_json_packet(&msg);
- true
+ ActorMessageStatus::Processed
}
"clearPseudoClassLocks" => {
@@ -309,7 +309,7 @@ impl Actor for WalkerActor {
from: self.name(),
};
stream.write_json_packet(&msg);
- true
+ ActorMessageStatus::Processed
}
"children" => {
@@ -330,10 +330,10 @@ impl Actor for WalkerActor {
from: self.name(),
};
stream.write_json_packet(&msg);
- true
+ ActorMessageStatus::Processed
}
- _ => false,
+ _ => ActorMessageStatus::Ignored,
})
}
}
@@ -426,7 +426,7 @@ impl Actor for PageStyleActor {
registry: &ActorRegistry,
msg_type: &str,
msg: &json::Object,
- stream: &mut TcpStream) -> Result<bool, ()> {
+ stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"getApplied" => {
//TODO: query script for relevant applied styles to node (msg.node)
@@ -437,7 +437,7 @@ impl Actor for PageStyleActor {
from: self.name(),
};
stream.write_json_packet(&msg);
- true
+ ActorMessageStatus::Processed
}
"getComputed" => {
@@ -447,7 +447,7 @@ impl Actor for PageStyleActor {
from: self.name(),
};
stream.write_json_packet(&msg);
- true
+ ActorMessageStatus::Processed
}
//TODO: query script for box layout properties of node (msg.node)
@@ -484,10 +484,10 @@ impl Actor for PageStyleActor {
from: self.name(),
};
stream.write_json_packet(&msg);
- true
+ ActorMessageStatus::Processed
}
- _ => false,
+ _ => ActorMessageStatus::Ignored,
})
}
}
@@ -501,7 +501,7 @@ impl Actor for InspectorActor {
registry: &ActorRegistry,
msg_type: &str,
_msg: &json::Object,
- stream: &mut TcpStream) -> Result<bool, ()> {
+ stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"getWalker" => {
if self.walker.borrow().is_none() {
@@ -529,7 +529,7 @@ impl Actor for InspectorActor {
}
};
stream.write_json_packet(&msg);
- true
+ ActorMessageStatus::Processed
}
"getPageStyle" => {
@@ -551,7 +551,7 @@ impl Actor for InspectorActor {
},
};
stream.write_json_packet(&msg);
- true
+ ActorMessageStatus::Processed
}
//TODO: this is an old message; try adding highlightable to the root traits instead
@@ -574,10 +574,10 @@ impl Actor for InspectorActor {
},
};
stream.write_json_packet(&msg);
- true
+ ActorMessageStatus::Processed
}
- _ => false,
+ _ => ActorMessageStatus::Ignored,
})
}
}
diff --git a/components/devtools/actors/memory.rs b/components/devtools/actors/memory.rs
index a651f3f3d4d..1011cfd9dab 100644
--- a/components/devtools/actors/memory.rs
+++ b/components/devtools/actors/memory.rs
@@ -5,7 +5,7 @@
use rustc_serialize::json;
use std::net::TcpStream;
-use actor::{Actor, ActorRegistry};
+use actor::{Actor, ActorRegistry, ActorMessageStatus};
#[derive(RustcEncodable)]
pub struct TimelineMemoryReply {
@@ -33,8 +33,8 @@ impl Actor for MemoryActor {
_registry: &ActorRegistry,
_msg_type: &str,
_msg: &json::Object,
- _stream: &mut TcpStream) -> Result<bool, ()> {
- Ok(false)
+ _stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
+ Ok(ActorMessageStatus::Ignored)
}
}
diff --git a/components/devtools/actors/network_event.rs b/components/devtools/actors/network_event.rs
index 37de41a0722..d73dd300e2c 100644
--- a/components/devtools/actors/network_event.rs
+++ b/components/devtools/actors/network_event.rs
@@ -8,7 +8,7 @@
extern crate hyper;
-use actor::{Actor, ActorRegistry};
+use actor::{Actor, ActorRegistry, ActorMessageStatus};
use protocol::JsonPacketStream;
use rustc_serialize::json;
use std::net::TcpStream;
@@ -74,7 +74,7 @@ impl Actor for NetworkEventActor {
_registry: &ActorRegistry,
msg_type: &str,
_msg: &json::Object,
- stream: &mut TcpStream) -> Result<bool, ()> {
+ stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"getRequestHeaders" => {
// TODO: Pass the correct values for headers, headerSize, rawHeaders
@@ -85,24 +85,24 @@ impl Actor for NetworkEventActor {
rawHeaders: "Raw headers".to_string(),
};
stream.write_json_packet(&msg);
- true
+ ActorMessageStatus::Processed
}
"getRequestCookies" => {
- false
+ ActorMessageStatus::Ignored
}
"getRequestPostData" => {
- false
+ ActorMessageStatus::Ignored
}
"getResponseHeaders" => {
- false
+ ActorMessageStatus::Ignored
}
"getResponseCookies" => {
- false
+ ActorMessageStatus::Ignored
}
"getResponseContent" => {
- false
+ ActorMessageStatus::Ignored
}
- _ => false
+ _ => ActorMessageStatus::Ignored
})
}
}
diff --git a/components/devtools/actors/object.rs b/components/devtools/actors/object.rs
index d6103a5ed3f..d77fbd396b3 100644
--- a/components/devtools/actors/object.rs
+++ b/components/devtools/actors/object.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-use actor::{Actor, ActorRegistry};
+use actor::{Actor, ActorRegistry, ActorMessageStatus};
use rustc_serialize::json;
use std::net::TcpStream;
@@ -19,8 +19,8 @@ impl Actor for ObjectActor {
_: &ActorRegistry,
_: &str,
_: &json::Object,
- _: &mut TcpStream) -> Result<bool, ()> {
- Ok(false)
+ _: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
+ Ok(ActorMessageStatus::Ignored)
}
}
diff --git a/components/devtools/actors/profiler.rs b/components/devtools/actors/profiler.rs
index 3db8b7074d0..fab3cc18249 100644
--- a/components/devtools/actors/profiler.rs
+++ b/components/devtools/actors/profiler.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-use actor::{Actor, ActorRegistry};
+use actor::{Actor, ActorRegistry, ActorMessageStatus};
use rustc_serialize::json;
use std::net::TcpStream;
@@ -20,8 +20,8 @@ impl Actor for ProfilerActor {
_registry: &ActorRegistry,
_msg_type: &str,
_msg: &json::Object,
- _stream: &mut TcpStream) -> Result<bool, ()> {
- Ok(false)
+ _stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
+ Ok(ActorMessageStatus::Ignored)
}
}
diff --git a/components/devtools/actors/root.rs b/components/devtools/actors/root.rs
index bd01889bce5..2881eedac62 100644
--- a/components/devtools/actors/root.rs
+++ b/components/devtools/actors/root.rs
@@ -7,7 +7,7 @@
/// Connection point for all new remote devtools interactions, providing lists of know actors
/// that perform more specific actions (tabs, addons, browser chrome, etc.)
-use actor::{Actor, ActorRegistry};
+use actor::{Actor, ActorRegistry, ActorMessageStatus};
use actors::tab::{TabActor, TabActorMsg};
use protocol::JsonPacketStream;
@@ -55,7 +55,7 @@ impl Actor for RootActor {
registry: &ActorRegistry,
msg_type: &str,
_msg: &json::Object,
- stream: &mut TcpStream) -> Result<bool, ()> {
+ stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"listAddons" => {
let actor = ErrorReply {
@@ -64,7 +64,7 @@ impl Actor for RootActor {
message: "This root actor has no browser addons.".to_string(),
};
stream.write_json_packet(&actor);
- true
+ ActorMessageStatus::Processed
}
//https://wiki.mozilla.org/Remote_Debugging_Protocol#Listing_Browser_Tabs
@@ -77,10 +77,10 @@ impl Actor for RootActor {
}).collect()
};
stream.write_json_packet(&actor);
- true
+ ActorMessageStatus::Processed
}
- _ => false
+ _ => ActorMessageStatus::Ignored
})
}
}
diff --git a/components/devtools/actors/tab.rs b/components/devtools/actors/tab.rs
index 73772c7e277..ef972245378 100644
--- a/components/devtools/actors/tab.rs
+++ b/components/devtools/actors/tab.rs
@@ -7,7 +7,7 @@
//! Connection point for remote devtools that wish to investigate a particular tab's contents.
//! Supports dynamic attaching and detaching which control notifications of navigation, etc.
-use actor::{Actor, ActorRegistry};
+use actor::{Actor, ActorRegistry, ActorMessageStatus};
use actors::console::ConsoleActor;
use devtools_traits::DevtoolScriptControlMsg::WantsLiveNotifications;
use protocol::JsonPacketStream;
@@ -84,11 +84,11 @@ impl Actor for TabActor {
registry: &ActorRegistry,
msg_type: &str,
_msg: &json::Object,
- stream: &mut TcpStream) -> Result<bool, ()> {
+ stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"reconfigure" => {
stream.write_json_packet(&ReconfigureReply { from: self.name() });
- true
+ ActorMessageStatus::Processed
}
// https://wiki.mozilla.org/Remote_Debugging_Protocol#Listing_Browser_Tabs
@@ -107,7 +107,7 @@ impl Actor for TabActor {
stream.write_json_packet(&msg);
console_actor.script_chan.send(
WantsLiveNotifications(console_actor.pipeline, true)).unwrap();
- true
+ ActorMessageStatus::Processed
}
//FIXME: The current implementation won't work for multiple connections. Need to ensure 105
@@ -122,7 +122,7 @@ impl Actor for TabActor {
stream.write_json_packet(&msg);
console_actor.script_chan.send(
WantsLiveNotifications(console_actor.pipeline, false)).unwrap();
- true
+ ActorMessageStatus::Processed
}
"listFrames" => {
@@ -131,10 +131,10 @@ impl Actor for TabActor {
frames: vec!(),
};
stream.write_json_packet(&msg);
- true
+ ActorMessageStatus::Processed
}
- _ => false
+ _ => ActorMessageStatus::Ignored
})
}
}
diff --git a/components/devtools/actors/timeline.rs b/components/devtools/actors/timeline.rs
index ca29b68b9f2..8f55b9853ea 100644
--- a/components/devtools/actors/timeline.rs
+++ b/components/devtools/actors/timeline.rs
@@ -13,7 +13,7 @@ use std::thread::sleep_ms;
use std::sync::{Arc, Mutex};
use std::sync::mpsc::channel;
-use actor::{Actor, ActorRegistry};
+use actor::{Actor, ActorRegistry, ActorMessageStatus};
use actors::memory::{MemoryActor, TimelineMemoryReply};
use actors::framerate::FramerateActor;
use devtools_traits::DevtoolScriptControlMsg;
@@ -232,7 +232,7 @@ impl Actor for TimelineActor {
registry: &ActorRegistry,
msg_type: &str,
msg: &json::Object,
- stream: &mut TcpStream) -> Result<bool, ()> {
+ stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
Ok(match msg_type {
"start" => {
**self.is_recording.lock().as_mut().unwrap() = true;
@@ -275,7 +275,7 @@ impl Actor for TimelineActor {
value: HighResolutionStamp::new(registry.start_stamp(), PreciseTime::now()),
};
stream.write_json_packet(&msg);
- true
+ ActorMessageStatus::Processed
}
"stop" => {
@@ -297,7 +297,7 @@ impl Actor for TimelineActor {
**self.is_recording.lock().as_mut().unwrap() = false;
self.stream.borrow_mut().take();
- true
+ ActorMessageStatus::Processed
}
"isRecording" => {
@@ -307,11 +307,11 @@ impl Actor for TimelineActor {
};
stream.write_json_packet(&msg);
- true
+ ActorMessageStatus::Processed
}
_ => {
- false
+ ActorMessageStatus::Ignored
}
})
}
diff --git a/components/devtools/actors/worker.rs b/components/devtools/actors/worker.rs
index 9f32abbed22..1b94e987b1a 100644
--- a/components/devtools/actors/worker.rs
+++ b/components/devtools/actors/worker.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-use actor::{Actor, ActorRegistry};
+use actor::{Actor, ActorRegistry, ActorMessageStatus};
use msg::constellation_msg::WorkerId;
use rustc_serialize::json;
use std::net::TcpStream;
@@ -21,7 +21,7 @@ impl Actor for WorkerActor {
_: &ActorRegistry,
_: &str,
_: &json::Object,
- _: &mut TcpStream) -> Result<bool, ()> {
- Ok(true)
+ _: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
+ Ok(ActorMessageStatus::Processed)
}
}