From 9a2955d4daa6b6db4efffca5ebd7312e53ba1723 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Thu, 24 Mar 2016 15:26:40 +0100 Subject: [PATCH 1/3] Implement a dummy sources message in the thread actor --- components/devtools/actors/thread.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/components/devtools/actors/thread.rs b/components/devtools/actors/thread.rs index d5037682baf..102f428bc8b 100644 --- a/components/devtools/actors/thread.rs +++ b/components/devtools/actors/thread.rs @@ -39,6 +39,15 @@ struct ReconfigureReply { from: String } +#[derive(Serialize)] +struct SourcesReply { + from: String, + sources: Vec, +} + +#[derive(Serialize)] +enum Source {} + pub struct ThreadActor { name: String, } @@ -88,6 +97,15 @@ impl Actor for ThreadActor { ActorMessageStatus::Processed } + "sources" => { + let msg = SourcesReply { + from: self.name(), + sources: vec![], + }; + stream.write_json_packet(&msg); + ActorMessageStatus::Processed + } + _ => ActorMessageStatus::Ignored, }) } From 14653e2875457dabd4accdbee56b25fa5beb66e1 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Thu, 24 Mar 2016 17:12:47 +0100 Subject: [PATCH 2/3] Implement a dummy protocolDescription in the root actor --- components/devtools/actors/performance.rs | 10 ++++++++- components/devtools/actors/root.rs | 25 ++++++++++++++++++++++- components/devtools/protocol.rs | 14 +++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/components/devtools/actors/performance.rs b/components/devtools/actors/performance.rs index 17687f10ff2..78c36885e5a 100644 --- a/components/devtools/actors/performance.rs +++ b/components/devtools/actors/performance.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use actor::{Actor, ActorMessageStatus, ActorRegistry}; -use protocol::JsonPacketStream; +use protocol::{ActorDescription, JsonPacketStream, Method}; use serde_json::Value; use std::collections::BTreeMap; use std::net::TcpStream; @@ -70,4 +70,12 @@ impl PerformanceActor { name: name, } } + + pub fn description() -> ActorDescription { + ActorDescription { + category: "actor", + typeName: "performance", + methods: vec![], + } + } } diff --git a/components/devtools/actors/root.rs b/components/devtools/actors/root.rs index 1ce308403e8..6103e5a9a4f 100644 --- a/components/devtools/actors/root.rs +++ b/components/devtools/actors/root.rs @@ -8,8 +8,9 @@ /// that perform more specific actions (tabs, addons, browser chrome, etc.) use actor::{Actor, ActorMessageStatus, ActorRegistry}; +use actors::performance::PerformanceActor; use actors::tab::{TabActor, TabActorMsg}; -use protocol::JsonPacketStream; +use protocol::{ActorDescription, JsonPacketStream}; use serde_json::Value; use std::collections::BTreeMap; use std::net::TcpStream; @@ -44,6 +45,17 @@ pub struct RootActorMsg { traits: ActorTraits, } +#[derive(Serialize)] +pub struct ProtocolDescriptionReply { + from: String, + types: Types, +} + +#[derive(Serialize)] +pub struct Types { + performance: ActorDescription, +} + pub struct RootActor { pub tabs: Vec, } @@ -81,6 +93,17 @@ impl Actor for RootActor { ActorMessageStatus::Processed } + "protocolDescription" => { + let msg = ProtocolDescriptionReply { + from: self.name(), + types: Types { + performance: PerformanceActor::description(), + }, + }; + stream.write_json_packet(&msg); + ActorMessageStatus::Processed + } + _ => ActorMessageStatus::Ignored }) } diff --git a/components/devtools/protocol.rs b/components/devtools/protocol.rs index cb75572f3b8..3da44cc5323 100644 --- a/components/devtools/protocol.rs +++ b/components/devtools/protocol.rs @@ -12,6 +12,20 @@ use std::error::Error; use std::io::{Read, Write}; use std::net::TcpStream; +#[derive(Serialize)] +pub struct ActorDescription { + pub category: &'static str, + pub typeName: &'static str, + pub methods: Vec, +} + +#[derive(Serialize)] +pub struct Method { + pub name: &'static str, + pub request: Value, + pub response: Value, +} + pub trait JsonPacketStream { fn write_json_packet(&mut self, obj: &T); fn read_json_packet(&mut self) -> Result, String>; From 50bca7319b79f0894d85151758231676971f726f Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Fri, 25 Mar 2016 10:36:00 +0100 Subject: [PATCH 3/3] Implement a dummy canCurrentlyRecord method in performance actor --- components/devtools/actors/performance.rs | 40 ++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/components/devtools/actors/performance.rs b/components/devtools/actors/performance.rs index 78c36885e5a..6d0bc2556e0 100644 --- a/components/devtools/actors/performance.rs +++ b/components/devtools/actors/performance.rs @@ -32,6 +32,21 @@ struct ConnectReply { traits: PerformanceTraits, } +#[derive(Serialize)] +struct CanCurrentlyRecordReply { + from: String, + value: SuccessMsg, +} + +#[derive(Serialize)] +struct SuccessMsg { + success: bool, + errors: Vec, +} + +#[derive(Serialize)] +enum Error {} + impl Actor for PerformanceActor { fn name(&self) -> String { self.name.clone() @@ -59,6 +74,17 @@ impl Actor for PerformanceActor { stream.write_json_packet(&msg); ActorMessageStatus::Processed }, + "canCurrentlyRecord" => { + let msg = CanCurrentlyRecordReply { + from: self.name(), + value: SuccessMsg { + success: true, + errors: vec![], + } + }; + stream.write_json_packet(&msg); + ActorMessageStatus::Processed + } _ => ActorMessageStatus::Ignored, }) } @@ -75,7 +101,19 @@ impl PerformanceActor { ActorDescription { category: "actor", typeName: "performance", - methods: vec![], + methods: vec![ + Method { + name: "canCurrentlyRecord", + request: Value::Object(vec![ + ("type".to_owned(), Value::String("canCurrentlyRecord".to_owned())), + ].into_iter().collect()), + response: Value::Object(vec![ + ("value".to_owned(), Value::Object(vec![ + ("_retval".to_owned(), Value::String("json".to_owned())), + ].into_iter().collect())), + ].into_iter().collect()), + }, + ], } } }