Actor::handle_message should return an enum instad of a boolean #7110 r=jdm

This commit is contained in:
Fabrice Desré 2015-08-13 18:14:34 -07:00
parent f5e97ef1b5
commit c7b48240b0
12 changed files with 83 additions and 76 deletions

View file

@ -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
})
}
}