mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Implement a PerformanceActor.
This is necessary for the devtools "Start Recording Performance" button to send a message. (This message is not yet supported, so it leads to 'unexpected message type "startRecording" found for actor "performance4"'.)
This commit is contained in:
parent
6a52ec9484
commit
238beec038
3 changed files with 83 additions and 2 deletions
73
components/devtools/actors/performance.rs
Normal file
73
components/devtools/actors/performance.rs
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
/* 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, ActorMessageStatus};
|
||||||
|
use protocol::JsonPacketStream;
|
||||||
|
|
||||||
|
use rustc_serialize::json;
|
||||||
|
use std::net::TcpStream;
|
||||||
|
|
||||||
|
pub struct PerformanceActor {
|
||||||
|
name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(RustcEncodable)]
|
||||||
|
struct PerformanceFeatures {
|
||||||
|
withMarkers: bool,
|
||||||
|
withMemory: bool,
|
||||||
|
withTicks: bool,
|
||||||
|
withAllocations: bool,
|
||||||
|
withJITOptimizations: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(RustcEncodable)]
|
||||||
|
struct PerformanceTraits {
|
||||||
|
features: PerformanceFeatures,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(RustcEncodable)]
|
||||||
|
struct ConnectReply {
|
||||||
|
from: String,
|
||||||
|
traits: PerformanceTraits,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Actor for PerformanceActor {
|
||||||
|
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 {
|
||||||
|
"connect" => {
|
||||||
|
let msg = ConnectReply {
|
||||||
|
from: self.name(),
|
||||||
|
traits: PerformanceTraits {
|
||||||
|
features: PerformanceFeatures {
|
||||||
|
withMarkers: true,
|
||||||
|
withMemory: true,
|
||||||
|
withTicks: true,
|
||||||
|
withAllocations: true,
|
||||||
|
withJITOptimizations: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
stream.write_json_packet(&msg);
|
||||||
|
ActorMessageStatus::Processed
|
||||||
|
},
|
||||||
|
_ => ActorMessageStatus::Ignored,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PerformanceActor {
|
||||||
|
pub fn new(name: String) -> PerformanceActor {
|
||||||
|
PerformanceActor {
|
||||||
|
name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -63,6 +63,7 @@ pub struct TabActorMsg {
|
||||||
inspectorActor: String,
|
inspectorActor: String,
|
||||||
timelineActor: String,
|
timelineActor: String,
|
||||||
profilerActor: String,
|
profilerActor: String,
|
||||||
|
performanceActor: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TabActor {
|
pub struct TabActor {
|
||||||
|
@ -73,6 +74,7 @@ pub struct TabActor {
|
||||||
pub inspector: String,
|
pub inspector: String,
|
||||||
pub timeline: String,
|
pub timeline: String,
|
||||||
pub profiler: String,
|
pub profiler: String,
|
||||||
|
pub performance: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Actor for TabActor {
|
impl Actor for TabActor {
|
||||||
|
@ -150,6 +152,7 @@ impl TabActor {
|
||||||
inspectorActor: self.inspector.clone(),
|
inspectorActor: self.inspector.clone(),
|
||||||
timelineActor: self.timeline.clone(),
|
timelineActor: self.timeline.clone(),
|
||||||
profilerActor: self.profiler.clone(),
|
profilerActor: self.profiler.clone(),
|
||||||
|
performanceActor: self.performance.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ use actors::console::ConsoleActor;
|
||||||
use actors::network_event::{NetworkEventActor, EventActor, ResponseStartMsg};
|
use actors::network_event::{NetworkEventActor, EventActor, ResponseStartMsg};
|
||||||
use actors::framerate::FramerateActor;
|
use actors::framerate::FramerateActor;
|
||||||
use actors::inspector::InspectorActor;
|
use actors::inspector::InspectorActor;
|
||||||
|
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;
|
||||||
|
@ -74,6 +75,7 @@ mod actors {
|
||||||
pub mod memory;
|
pub mod memory;
|
||||||
pub mod network_event;
|
pub mod network_event;
|
||||||
pub mod object;
|
pub mod object;
|
||||||
|
pub mod performance;
|
||||||
pub mod profiler;
|
pub mod profiler;
|
||||||
pub mod root;
|
pub mod root;
|
||||||
pub mod tab;
|
pub mod tab;
|
||||||
|
@ -204,7 +206,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) = {
|
let (tab, console, inspector, timeline, profiler, performance) = {
|
||||||
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(),
|
||||||
|
@ -225,6 +227,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||||
script_sender);
|
script_sender);
|
||||||
|
|
||||||
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 DevtoolsPageInfo { title, url } = page_info;
|
let DevtoolsPageInfo { title, url } = page_info;
|
||||||
let tab = TabActor {
|
let tab = TabActor {
|
||||||
|
@ -235,12 +238,13 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||||
inspector: inspector.name(),
|
inspector: inspector.name(),
|
||||||
timeline: timeline.name(),
|
timeline: timeline.name(),
|
||||||
profiler: profiler.name(),
|
profiler: profiler.name(),
|
||||||
|
performance: performance.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)
|
(tab, console, inspector, timeline, profiler, performance)
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(id) = worker_id {
|
if let Some(id) = worker_id {
|
||||||
|
@ -259,6 +263,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
||||||
actors.register(box inspector);
|
actors.register(box inspector);
|
||||||
actors.register(box timeline);
|
actors.register(box timeline);
|
||||||
actors.register(box profiler);
|
actors.register(box profiler);
|
||||||
|
actors.register(box performance);
|
||||||
}
|
}
|
||||||
|
|
||||||
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