mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Auto merge of #10158 - nox:devtools, r=Ms2ger
Allow Firefox to be able to connect to devtools again This doesn't fix the performance tab, but at least lets Firefox initialise the devtools window. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10158) <!-- Reviewable:end -->
This commit is contained in:
commit
5faab270c6
5 changed files with 122 additions and 9 deletions
|
@ -77,6 +77,12 @@ struct EvaluateJSReply {
|
||||||
helperResult: Json,
|
helperResult: Json,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(RustcEncodable)]
|
||||||
|
struct SetPreferencesReply {
|
||||||
|
from: String,
|
||||||
|
updated: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
pub struct ConsoleActor {
|
pub struct ConsoleActor {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub pipeline: PipelineId,
|
pub pipeline: PipelineId,
|
||||||
|
@ -237,6 +243,15 @@ impl Actor for ConsoleActor {
|
||||||
ActorMessageStatus::Processed
|
ActorMessageStatus::Processed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"setPreferences" => {
|
||||||
|
let msg = SetPreferencesReply {
|
||||||
|
from: self.name(),
|
||||||
|
updated: vec![],
|
||||||
|
};
|
||||||
|
stream.write_json_packet(&msg);
|
||||||
|
ActorMessageStatus::Processed
|
||||||
|
}
|
||||||
|
|
||||||
_ => ActorMessageStatus::Ignored
|
_ => ActorMessageStatus::Ignored
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,12 +21,14 @@ struct ActorTraits {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(RustcEncodable)]
|
||||||
struct ErrorReply {
|
struct ListAddonsReply {
|
||||||
from: String,
|
from: String,
|
||||||
error: String,
|
addons: Vec<AddonMsg>,
|
||||||
message: String,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(RustcEncodable)]
|
||||||
|
enum AddonMsg {}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(RustcEncodable)]
|
||||||
struct ListTabsReply {
|
struct ListTabsReply {
|
||||||
from: String,
|
from: String,
|
||||||
|
@ -57,10 +59,9 @@ impl Actor for RootActor {
|
||||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||||
Ok(match msg_type {
|
Ok(match msg_type {
|
||||||
"listAddons" => {
|
"listAddons" => {
|
||||||
let actor = ErrorReply {
|
let actor = ListAddonsReply {
|
||||||
from: "root".to_owned(),
|
from: "root".to_owned(),
|
||||||
error: "noAddons".to_owned(),
|
addons: vec![],
|
||||||
message: "This root actor has no browser addons.".to_owned(),
|
|
||||||
};
|
};
|
||||||
stream.write_json_packet(&actor);
|
stream.write_json_packet(&actor);
|
||||||
ActorMessageStatus::Processed
|
ActorMessageStatus::Processed
|
||||||
|
|
|
@ -74,6 +74,7 @@ pub struct TabActor {
|
||||||
pub timeline: String,
|
pub timeline: String,
|
||||||
pub profiler: String,
|
pub profiler: String,
|
||||||
pub performance: String,
|
pub performance: String,
|
||||||
|
pub thread: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Actor for TabActor {
|
impl Actor for TabActor {
|
||||||
|
@ -98,7 +99,7 @@ impl Actor for TabActor {
|
||||||
let msg = TabAttachedReply {
|
let msg = TabAttachedReply {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
__type__: "tabAttached".to_owned(),
|
__type__: "tabAttached".to_owned(),
|
||||||
threadActor: self.name(),
|
threadActor: self.thread.clone(),
|
||||||
cacheDisabled: false,
|
cacheDisabled: false,
|
||||||
javascriptEnabled: true,
|
javascriptEnabled: true,
|
||||||
traits: TabTraits,
|
traits: TabTraits,
|
||||||
|
|
90
components/devtools/actors/thread.rs
Normal file
90
components/devtools/actors/thread.rs
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* 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, ActorMessageStatus, ActorRegistry};
|
||||||
|
use protocol::JsonPacketStream;
|
||||||
|
use rustc_serialize::json;
|
||||||
|
use std::net::TcpStream;
|
||||||
|
|
||||||
|
#[derive(RustcEncodable)]
|
||||||
|
struct ThreadAttachedReply {
|
||||||
|
from: String,
|
||||||
|
__type__: String,
|
||||||
|
actor: String,
|
||||||
|
poppedFrames: Vec<PoppedFrameMsg>,
|
||||||
|
why: WhyMsg,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(RustcEncodable)]
|
||||||
|
enum PoppedFrameMsg {}
|
||||||
|
|
||||||
|
#[derive(RustcEncodable)]
|
||||||
|
struct WhyMsg {
|
||||||
|
__type__: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(RustcEncodable)]
|
||||||
|
struct ThreadResumedReply {
|
||||||
|
from: String,
|
||||||
|
__type__: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(RustcEncodable)]
|
||||||
|
struct ReconfigureReply {
|
||||||
|
from: String
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ThreadActor {
|
||||||
|
name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ThreadActor {
|
||||||
|
pub fn new(name: String) -> ThreadActor {
|
||||||
|
ThreadActor {
|
||||||
|
name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Actor for ThreadActor {
|
||||||
|
fn name(&self) -> String {
|
||||||
|
self.name.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_message(&self,
|
||||||
|
registry: &ActorRegistry,
|
||||||
|
msg_type: &str,
|
||||||
|
_msg: &json::Object,
|
||||||
|
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||||
|
Ok(match msg_type {
|
||||||
|
"attach" => {
|
||||||
|
let msg = ThreadAttachedReply {
|
||||||
|
from: self.name(),
|
||||||
|
__type__: "paused".to_owned(),
|
||||||
|
actor: registry.new_name("pause"),
|
||||||
|
poppedFrames: vec![],
|
||||||
|
why: WhyMsg { __type__: "attached".to_owned() },
|
||||||
|
};
|
||||||
|
stream.write_json_packet(&msg);
|
||||||
|
ActorMessageStatus::Processed
|
||||||
|
},
|
||||||
|
|
||||||
|
"resume" => {
|
||||||
|
let msg = ThreadResumedReply {
|
||||||
|
from: self.name(),
|
||||||
|
__type__: "resumed".to_owned(),
|
||||||
|
};
|
||||||
|
stream.write_json_packet(&msg);
|
||||||
|
ActorMessageStatus::Processed
|
||||||
|
},
|
||||||
|
|
||||||
|
"reconfigure" => {
|
||||||
|
stream.write_json_packet(&ReconfigureReply { from: self.name() });
|
||||||
|
ActorMessageStatus::Processed
|
||||||
|
}
|
||||||
|
|
||||||
|
_ => ActorMessageStatus::Ignored,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -42,6 +42,7 @@ use actors::performance::PerformanceActor;
|
||||||
use actors::profiler::ProfilerActor;
|
use actors::profiler::ProfilerActor;
|
||||||
use actors::root::RootActor;
|
use actors::root::RootActor;
|
||||||
use actors::tab::TabActor;
|
use actors::tab::TabActor;
|
||||||
|
use actors::thread::ThreadActor;
|
||||||
use actors::timeline::TimelineActor;
|
use actors::timeline::TimelineActor;
|
||||||
use actors::worker::WorkerActor;
|
use actors::worker::WorkerActor;
|
||||||
use devtools_traits::{ChromeToDevtoolsControlMsg, ConsoleMessage, DevtoolsControlMsg};
|
use devtools_traits::{ChromeToDevtoolsControlMsg, ConsoleMessage, DevtoolsControlMsg};
|
||||||
|
@ -73,6 +74,7 @@ mod actors {
|
||||||
pub mod profiler;
|
pub mod profiler;
|
||||||
pub mod root;
|
pub mod root;
|
||||||
pub mod tab;
|
pub mod tab;
|
||||||
|
pub mod thread;
|
||||||
pub mod timeline;
|
pub mod timeline;
|
||||||
pub mod worker;
|
pub mod worker;
|
||||||
}
|
}
|
||||||
|
@ -248,7 +250,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||||
let (pipeline, worker_id) = ids;
|
let (pipeline, worker_id) = ids;
|
||||||
|
|
||||||
//TODO: move all this actor creation into a constructor method on TabActor
|
//TODO: move all this actor creation into a constructor method on TabActor
|
||||||
let (tab, console, inspector, timeline, profiler, performance) = {
|
let (tab, console, inspector, timeline, profiler, performance, thread) = {
|
||||||
let console = ConsoleActor {
|
let console = ConsoleActor {
|
||||||
name: actors.new_name("console"),
|
name: actors.new_name("console"),
|
||||||
script_chan: script_sender.clone(),
|
script_chan: script_sender.clone(),
|
||||||
|
@ -271,6 +273,8 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||||
let profiler = ProfilerActor::new(actors.new_name("profiler"));
|
let profiler = ProfilerActor::new(actors.new_name("profiler"));
|
||||||
let performance = PerformanceActor::new(actors.new_name("performance"));
|
let performance = PerformanceActor::new(actors.new_name("performance"));
|
||||||
|
|
||||||
|
let thread = ThreadActor::new(actors.new_name("context"));
|
||||||
|
|
||||||
let DevtoolsPageInfo { title, url } = page_info;
|
let DevtoolsPageInfo { title, url } = page_info;
|
||||||
let tab = TabActor {
|
let tab = TabActor {
|
||||||
name: actors.new_name("tab"),
|
name: actors.new_name("tab"),
|
||||||
|
@ -281,12 +285,13 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||||
timeline: timeline.name(),
|
timeline: timeline.name(),
|
||||||
profiler: profiler.name(),
|
profiler: profiler.name(),
|
||||||
performance: performance.name(),
|
performance: performance.name(),
|
||||||
|
thread: thread.name(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let root = actors.find_mut::<RootActor>("root");
|
let root = actors.find_mut::<RootActor>("root");
|
||||||
root.tabs.push(tab.name.clone());
|
root.tabs.push(tab.name.clone());
|
||||||
|
|
||||||
(tab, console, inspector, timeline, profiler, performance)
|
(tab, console, inspector, timeline, profiler, performance, thread)
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(id) = worker_id {
|
if let Some(id) = worker_id {
|
||||||
|
@ -306,6 +311,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||||
actors.register(box timeline);
|
actors.register(box timeline);
|
||||||
actors.register(box profiler);
|
actors.register(box profiler);
|
||||||
actors.register(box performance);
|
actors.register(box performance);
|
||||||
|
actors.register(box thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_console_message(actors: Arc<Mutex<ActorRegistry>>,
|
fn handle_console_message(actors: Arc<Mutex<ActorRegistry>>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue