mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Implement a ProfilerActor struct.
This is sufficient to make the profiler tab show up in Firefox's devtools.
This commit is contained in:
parent
9fda72d60f
commit
c10bf0dcaa
3 changed files with 46 additions and 2 deletions
34
components/devtools/actors/profiler.rs
Normal file
34
components/devtools/actors/profiler.rs
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* 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, ActorRegistry};
|
||||
|
||||
use rustc_serialize::json;
|
||||
use std::net::TcpStream;
|
||||
|
||||
pub struct ProfilerActor {
|
||||
name: String,
|
||||
}
|
||||
|
||||
impl Actor for ProfilerActor {
|
||||
fn name(&self) -> String {
|
||||
self.name.clone()
|
||||
}
|
||||
|
||||
fn handle_message(&self,
|
||||
_registry: &ActorRegistry,
|
||||
_msg_type: &str,
|
||||
_msg: &json::Object,
|
||||
_stream: &mut TcpStream) -> Result<bool, ()> {
|
||||
Ok(false)
|
||||
}
|
||||
}
|
||||
|
||||
impl ProfilerActor {
|
||||
pub fn new(name: String) -> ProfilerActor {
|
||||
ProfilerActor {
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -62,6 +62,7 @@ pub struct TabActorMsg {
|
|||
consoleActor: String,
|
||||
inspectorActor: String,
|
||||
timelineActor: String,
|
||||
profilerActor: String,
|
||||
}
|
||||
|
||||
pub struct TabActor {
|
||||
|
@ -71,6 +72,7 @@ pub struct TabActor {
|
|||
pub console: String,
|
||||
pub inspector: String,
|
||||
pub timeline: String,
|
||||
pub profiler: String,
|
||||
}
|
||||
|
||||
impl Actor for TabActor {
|
||||
|
@ -147,6 +149,7 @@ impl TabActor {
|
|||
consoleActor: self.console.clone(),
|
||||
inspectorActor: self.inspector.clone(),
|
||||
timelineActor: self.timeline.clone(),
|
||||
profilerActor: self.profiler.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ use actors::console::ConsoleActor;
|
|||
use actors::network_event::{NetworkEventActor, EventActor, ResponseStartMsg};
|
||||
use actors::framerate::FramerateActor;
|
||||
use actors::inspector::InspectorActor;
|
||||
use actors::profiler::ProfilerActor;
|
||||
use actors::root::RootActor;
|
||||
use actors::tab::TabActor;
|
||||
use actors::timeline::TimelineActor;
|
||||
|
@ -73,6 +74,7 @@ mod actors {
|
|||
pub mod memory;
|
||||
pub mod network_event;
|
||||
pub mod object;
|
||||
pub mod profiler;
|
||||
pub mod root;
|
||||
pub mod tab;
|
||||
pub mod timeline;
|
||||
|
@ -203,7 +205,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
|||
let (pipeline, worker_id) = ids;
|
||||
|
||||
//TODO: move all this actor creation into a constructor method on TabActor
|
||||
let (tab, console, inspector, timeline) = {
|
||||
let (tab, console, inspector, timeline, profiler) = {
|
||||
let console = ConsoleActor {
|
||||
name: actors.new_name("console"),
|
||||
script_chan: script_sender.clone(),
|
||||
|
@ -224,6 +226,8 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
|||
script_sender,
|
||||
devtools_sender);
|
||||
|
||||
let profiler = ProfilerActor::new(actors.new_name("profiler"));
|
||||
|
||||
let DevtoolsPageInfo { title, url } = page_info;
|
||||
let tab = TabActor {
|
||||
name: actors.new_name("tab"),
|
||||
|
@ -232,11 +236,13 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
|||
console: console.name(),
|
||||
inspector: inspector.name(),
|
||||
timeline: timeline.name(),
|
||||
profiler: profiler.name(),
|
||||
};
|
||||
|
||||
let root = actors.find_mut::<RootActor>("root");
|
||||
root.tabs.push(tab.name.clone());
|
||||
(tab, console, inspector, timeline)
|
||||
|
||||
(tab, console, inspector, timeline, profiler)
|
||||
};
|
||||
|
||||
if let Some(id) = worker_id {
|
||||
|
@ -254,6 +260,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
|||
actors.register(box console);
|
||||
actors.register(box inspector);
|
||||
actors.register(box timeline);
|
||||
actors.register(box profiler);
|
||||
}
|
||||
|
||||
fn handle_console_message(actors: Arc<Mutex<ActorRegistry>>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue