mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01: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,
|
||||
timelineActor: String,
|
||||
profilerActor: String,
|
||||
performanceActor: String,
|
||||
}
|
||||
|
||||
pub struct TabActor {
|
||||
|
@ -73,6 +74,7 @@ pub struct TabActor {
|
|||
pub inspector: String,
|
||||
pub timeline: String,
|
||||
pub profiler: String,
|
||||
pub performance: String,
|
||||
}
|
||||
|
||||
impl Actor for TabActor {
|
||||
|
@ -150,6 +152,7 @@ impl TabActor {
|
|||
inspectorActor: self.inspector.clone(),
|
||||
timelineActor: self.timeline.clone(),
|
||||
profilerActor: self.profiler.clone(),
|
||||
performanceActor: self.performance.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue