mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
clippy: Fix several warnings in components/devtools (#31501)
This commit is contained in:
parent
da873779b4
commit
3552bb2464
18 changed files with 85 additions and 86 deletions
|
@ -5,7 +5,7 @@
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::mem::replace;
|
use std::mem;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ impl ActorRegistry {
|
||||||
|
|
||||||
/// Get start stamp when registry was started
|
/// Get start stamp when registry was started
|
||||||
pub fn start_stamp(&self) -> PreciseTime {
|
pub fn start_stamp(&self) -> PreciseTime {
|
||||||
self.start_stamp.clone()
|
self.start_stamp
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn register_script_actor(&self, script_id: String, actor: String) {
|
pub fn register_script_actor(&self, script_id: String, actor: String) {
|
||||||
|
@ -194,12 +194,12 @@ impl ActorRegistry {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
let new_actors = replace(&mut *self.new_actors.borrow_mut(), vec![]);
|
let new_actors = mem::take(&mut *self.new_actors.borrow_mut());
|
||||||
for actor in new_actors.into_iter() {
|
for actor in new_actors.into_iter() {
|
||||||
self.actors.insert(actor.name().to_owned(), actor);
|
self.actors.insert(actor.name().to_owned(), actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
let old_actors = replace(&mut *self.old_actors.borrow_mut(), vec![]);
|
let old_actors = mem::take(&mut *self.old_actors.borrow_mut());
|
||||||
for name in old_actors {
|
for name in old_actors {
|
||||||
self.drop_actor(name);
|
self.drop_actor(name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,11 +284,11 @@ impl BrowsingContextActor {
|
||||||
let tabdesc = TabDescriptorActor::new(actors, name.clone());
|
let tabdesc = TabDescriptorActor::new(actors, name.clone());
|
||||||
|
|
||||||
let target = BrowsingContextActor {
|
let target = BrowsingContextActor {
|
||||||
name: name,
|
name,
|
||||||
script_chan: script_sender,
|
script_chan: script_sender,
|
||||||
title: RefCell::new(String::from(title)),
|
title: RefCell::new(title),
|
||||||
url: RefCell::new(url.into_string()),
|
url: RefCell::new(url.into_string()),
|
||||||
console: console,
|
console,
|
||||||
_emulation: emulation.name(),
|
_emulation: emulation.name(),
|
||||||
_inspector: inspector.name(),
|
_inspector: inspector.name(),
|
||||||
_timeline: timeline.name(),
|
_timeline: timeline.name(),
|
||||||
|
@ -355,7 +355,7 @@ impl BrowsingContextActor {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
type_: "tabNavigated".to_owned(),
|
type_: "tabNavigated".to_owned(),
|
||||||
url: url.as_str().to_owned(),
|
url: url.as_str().to_owned(),
|
||||||
title: title,
|
title,
|
||||||
nativeConsoleAPI: true,
|
nativeConsoleAPI: true,
|
||||||
state: state.to_owned(),
|
state: state.to_owned(),
|
||||||
isFrameSwitching: false,
|
isFrameSwitching: false,
|
||||||
|
|
|
@ -133,7 +133,7 @@ impl ConsoleActor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn streams_mut<'a>(&self, registry: &'a ActorRegistry, cb: impl Fn(&mut TcpStream)) {
|
fn streams_mut(&self, registry: &ActorRegistry, cb: impl Fn(&mut TcpStream)) {
|
||||||
match &self.root {
|
match &self.root {
|
||||||
Root::BrowsingContext(bc) => registry
|
Root::BrowsingContext(bc) => registry
|
||||||
.find::<BrowsingContextActor>(bc)
|
.find::<BrowsingContextActor>(bc)
|
||||||
|
@ -221,7 +221,7 @@ impl ConsoleActor {
|
||||||
ActorValue { class, uuid } => {
|
ActorValue { class, uuid } => {
|
||||||
//TODO: make initial ActorValue message include these properties?
|
//TODO: make initial ActorValue message include these properties?
|
||||||
let mut m = Map::new();
|
let mut m = Map::new();
|
||||||
let actor = ObjectActor::new(registry, uuid);
|
let actor = ObjectActor::register(registry, uuid);
|
||||||
|
|
||||||
m.insert("type".to_owned(), Value::String("object".to_owned()));
|
m.insert("type".to_owned(), Value::String("object".to_owned()));
|
||||||
m.insert("class".to_owned(), Value::String(class));
|
m.insert("class".to_owned(), Value::String(class));
|
||||||
|
@ -236,8 +236,8 @@ impl ConsoleActor {
|
||||||
//TODO: catch and return exception values from JS evaluation
|
//TODO: catch and return exception values from JS evaluation
|
||||||
let reply = EvaluateJSReply {
|
let reply = EvaluateJSReply {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
input: input,
|
input,
|
||||||
result: result,
|
result,
|
||||||
timestamp: 0,
|
timestamp: 0,
|
||||||
exception: Value::Null,
|
exception: Value::Null,
|
||||||
exceptionMessage: Value::Null,
|
exceptionMessage: Value::Null,
|
||||||
|
@ -255,7 +255,7 @@ impl ConsoleActor {
|
||||||
self.cached_events
|
self.cached_events
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.entry(id.clone())
|
.entry(id.clone())
|
||||||
.or_insert(vec![])
|
.or_default()
|
||||||
.push(CachedConsoleMessage::PageError(page_error.clone()));
|
.push(CachedConsoleMessage::PageError(page_error.clone()));
|
||||||
if id == self.current_unique_id(registry) {
|
if id == self.current_unique_id(registry) {
|
||||||
let msg = PageErrorMsg {
|
let msg = PageErrorMsg {
|
||||||
|
@ -287,7 +287,7 @@ impl ConsoleActor {
|
||||||
self.cached_events
|
self.cached_events
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.entry(id.clone())
|
.entry(id.clone())
|
||||||
.or_insert(vec![])
|
.or_default()
|
||||||
.push(CachedConsoleMessage::ConsoleAPI(ConsoleAPI {
|
.push(CachedConsoleMessage::ConsoleAPI(ConsoleAPI {
|
||||||
type_: "ConsoleAPI".to_owned(),
|
type_: "ConsoleAPI".to_owned(),
|
||||||
level: level.clone(),
|
level: level.clone(),
|
||||||
|
@ -306,7 +306,7 @@ impl ConsoleActor {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
type_: "consoleAPICall".to_owned(),
|
type_: "consoleAPICall".to_owned(),
|
||||||
message: ConsoleMsg {
|
message: ConsoleMsg {
|
||||||
level: level,
|
level,
|
||||||
timeStamp: SystemTime::now()
|
timeStamp: SystemTime::now()
|
||||||
.duration_since(UNIX_EPOCH)
|
.duration_since(UNIX_EPOCH)
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
|
@ -351,7 +351,7 @@ impl Actor for ConsoleActor {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.as_array()
|
.as_array()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.into_iter()
|
.iter()
|
||||||
.map(|json_type| json_type.as_str().unwrap());
|
.map(|json_type| json_type.as_str().unwrap());
|
||||||
let mut message_types = CachedConsoleMessageTypes::empty();
|
let mut message_types = CachedConsoleMessageTypes::empty();
|
||||||
for str_type in str_types {
|
for str_type in str_types {
|
||||||
|
@ -393,7 +393,7 @@ impl Actor for ConsoleActor {
|
||||||
|
|
||||||
let msg = GetCachedMessagesReply {
|
let msg = GetCachedMessagesReply {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
messages: messages,
|
messages,
|
||||||
};
|
};
|
||||||
let _ = stream.write_json_packet(&msg);
|
let _ = stream.write_json_packet(&msg);
|
||||||
ActorMessageStatus::Processed
|
ActorMessageStatus::Processed
|
||||||
|
@ -445,7 +445,7 @@ impl Actor for ConsoleActor {
|
||||||
},
|
},
|
||||||
|
|
||||||
"evaluateJS" => {
|
"evaluateJS" => {
|
||||||
let msg = self.evaluateJS(®istry, &msg);
|
let msg = self.evaluateJS(registry, msg);
|
||||||
let _ = stream.write_json_packet(&msg);
|
let _ = stream.write_json_packet(&msg);
|
||||||
ActorMessageStatus::Processed
|
ActorMessageStatus::Processed
|
||||||
},
|
},
|
||||||
|
@ -468,14 +468,14 @@ impl Actor for ConsoleActor {
|
||||||
return Ok(ActorMessageStatus::Processed);
|
return Ok(ActorMessageStatus::Processed);
|
||||||
}
|
}
|
||||||
|
|
||||||
let reply = self.evaluateJS(®istry, &msg).unwrap();
|
let reply = self.evaluateJS(registry, msg).unwrap();
|
||||||
let msg = EvaluateJSEvent {
|
let msg = EvaluateJSEvent {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
r#type: "evaluationResult".to_owned(),
|
r#type: "evaluationResult".to_owned(),
|
||||||
input: reply.input,
|
input: reply.input,
|
||||||
result: reply.result,
|
result: reply.result,
|
||||||
timestamp: reply.timestamp,
|
timestamp: reply.timestamp,
|
||||||
resultID: resultID,
|
resultID,
|
||||||
exception: reply.exception,
|
exception: reply.exception,
|
||||||
exceptionMessage: reply.exceptionMessage,
|
exceptionMessage: reply.exceptionMessage,
|
||||||
helperResult: reply.helperResult,
|
helperResult: reply.helperResult,
|
||||||
|
|
|
@ -59,7 +59,7 @@ impl Actor for DeviceActor {
|
||||||
|
|
||||||
impl DeviceActor {
|
impl DeviceActor {
|
||||||
pub fn new(name: String) -> DeviceActor {
|
pub fn new(name: String) -> DeviceActor {
|
||||||
DeviceActor { name: name }
|
DeviceActor { name }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn description() -> ActorDescription {
|
pub fn description() -> ActorDescription {
|
||||||
|
|
|
@ -21,19 +21,17 @@ impl Actor for EmulationActor {
|
||||||
fn handle_message(
|
fn handle_message(
|
||||||
&self,
|
&self,
|
||||||
_registry: &ActorRegistry,
|
_registry: &ActorRegistry,
|
||||||
msg_type: &str,
|
_msg_type: &str,
|
||||||
_msg: &Map<String, Value>,
|
_msg: &Map<String, Value>,
|
||||||
_stream: &mut TcpStream,
|
_stream: &mut TcpStream,
|
||||||
_id: StreamId,
|
_id: StreamId,
|
||||||
) -> Result<ActorMessageStatus, ()> {
|
) -> Result<ActorMessageStatus, ()> {
|
||||||
Ok(match msg_type {
|
Ok(ActorMessageStatus::Ignored)
|
||||||
_ => ActorMessageStatus::Ignored,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EmulationActor {
|
impl EmulationActor {
|
||||||
pub fn new(name: String) -> EmulationActor {
|
pub fn new(name: String) -> EmulationActor {
|
||||||
EmulationActor { name: name }
|
EmulationActor { name }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ impl FramerateActor {
|
||||||
let mut actor = FramerateActor {
|
let mut actor = FramerateActor {
|
||||||
name: actor_name.clone(),
|
name: actor_name.clone(),
|
||||||
pipeline: pipeline_id,
|
pipeline: pipeline_id,
|
||||||
script_sender: script_sender,
|
script_sender,
|
||||||
is_recording: false,
|
is_recording: false,
|
||||||
ticks: Vec::new(),
|
ticks: Vec::new(),
|
||||||
};
|
};
|
||||||
|
@ -71,7 +71,7 @@ impl FramerateActor {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn take_pending_ticks(&mut self) -> Vec<HighResolutionStamp> {
|
pub fn take_pending_ticks(&mut self) -> Vec<HighResolutionStamp> {
|
||||||
mem::replace(&mut self.ticks, Vec::new())
|
mem::take(&mut self.ticks)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start_recording(&mut self) {
|
fn start_recording(&mut self) {
|
||||||
|
|
|
@ -207,8 +207,8 @@ impl NodeInfoToProtocol for NodeInfo {
|
||||||
let name = actors.new_name("node");
|
let name = actors.new_name("node");
|
||||||
let node_actor = NodeActor {
|
let node_actor = NodeActor {
|
||||||
name: name.clone(),
|
name: name.clone(),
|
||||||
script_chan: script_chan,
|
script_chan,
|
||||||
pipeline: pipeline.clone(),
|
pipeline,
|
||||||
};
|
};
|
||||||
actors.register_script_actor(self.uniqueId, name.clone());
|
actors.register_script_actor(self.uniqueId, name.clone());
|
||||||
actors.register_later(Box::new(node_actor));
|
actors.register_later(Box::new(node_actor));
|
||||||
|
@ -315,7 +315,7 @@ impl Actor for WalkerActor {
|
||||||
|
|
||||||
let msg = DocumentElementReply {
|
let msg = DocumentElementReply {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
node: node,
|
node,
|
||||||
};
|
};
|
||||||
let _ = stream.write_json_packet(&msg);
|
let _ = stream.write_json_packet(&msg);
|
||||||
ActorMessageStatus::Processed
|
ActorMessageStatus::Processed
|
||||||
|
@ -538,16 +538,16 @@ impl Actor for PageStyleActor {
|
||||||
|
|
||||||
let auto_margins = msg
|
let auto_margins = msg
|
||||||
.get("autoMargins")
|
.get("autoMargins")
|
||||||
.and_then(&Value::as_bool)
|
.and_then(Value::as_bool)
|
||||||
.unwrap_or(false);
|
.unwrap_or(false);
|
||||||
|
|
||||||
// http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/styles.js
|
// http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/styles.js
|
||||||
let msg = GetLayoutReply {
|
let msg = GetLayoutReply {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
display: display,
|
display,
|
||||||
position: position,
|
position,
|
||||||
zIndex: zIndex,
|
zIndex,
|
||||||
boxSizing: boxSizing,
|
boxSizing,
|
||||||
autoMargins: if auto_margins {
|
autoMargins: if auto_margins {
|
||||||
let mut m = Map::new();
|
let mut m = Map::new();
|
||||||
let auto = serde_json::value::Value::String("auto".to_owned());
|
let auto = serde_json::value::Value::String("auto".to_owned());
|
||||||
|
@ -567,20 +567,20 @@ impl Actor for PageStyleActor {
|
||||||
} else {
|
} else {
|
||||||
serde_json::value::Value::Null
|
serde_json::value::Value::Null
|
||||||
},
|
},
|
||||||
marginTop: marginTop,
|
marginTop,
|
||||||
marginRight: marginRight,
|
marginRight,
|
||||||
marginBottom: marginBottom,
|
marginBottom,
|
||||||
marginLeft: marginLeft,
|
marginLeft,
|
||||||
borderTopWidth: borderTopWidth,
|
borderTopWidth,
|
||||||
borderRightWidth: borderRightWidth,
|
borderRightWidth,
|
||||||
borderBottomWidth: borderBottomWidth,
|
borderBottomWidth,
|
||||||
borderLeftWidth: borderLeftWidth,
|
borderLeftWidth,
|
||||||
paddingTop: paddingTop,
|
paddingTop,
|
||||||
paddingRight: paddingRight,
|
paddingRight,
|
||||||
paddingBottom: paddingBottom,
|
paddingBottom,
|
||||||
paddingLeft: paddingLeft,
|
paddingLeft,
|
||||||
width: width,
|
width,
|
||||||
height: height,
|
height,
|
||||||
};
|
};
|
||||||
let msg = serde_json::to_string(&msg).unwrap();
|
let msg = serde_json::to_string(&msg).unwrap();
|
||||||
let msg = serde_json::from_str::<Value>(&msg).unwrap();
|
let msg = serde_json::from_str::<Value>(&msg).unwrap();
|
||||||
|
@ -614,7 +614,7 @@ impl Actor for InspectorActor {
|
||||||
let walker = WalkerActor {
|
let walker = WalkerActor {
|
||||||
name: registry.new_name("walker"),
|
name: registry.new_name("walker"),
|
||||||
script_chan: self.script_chan.clone(),
|
script_chan: self.script_chan.clone(),
|
||||||
pipeline: pipeline,
|
pipeline,
|
||||||
};
|
};
|
||||||
let mut walker_name = self.walker.borrow_mut();
|
let mut walker_name = self.walker.borrow_mut();
|
||||||
*walker_name = Some(walker.name());
|
*walker_name = Some(walker.name());
|
||||||
|
@ -643,7 +643,7 @@ impl Actor for InspectorActor {
|
||||||
let style = PageStyleActor {
|
let style = PageStyleActor {
|
||||||
name: registry.new_name("pageStyle"),
|
name: registry.new_name("pageStyle"),
|
||||||
script_chan: self.script_chan.clone(),
|
script_chan: self.script_chan.clone(),
|
||||||
pipeline: pipeline,
|
pipeline,
|
||||||
};
|
};
|
||||||
let mut pageStyle = self.pageStyle.borrow_mut();
|
let mut pageStyle = self.pageStyle.borrow_mut();
|
||||||
*pageStyle = Some(style.name());
|
*pageStyle = Some(style.name());
|
||||||
|
|
|
@ -200,7 +200,7 @@ impl Actor for NetworkEventActor {
|
||||||
}
|
}
|
||||||
let msg = GetRequestHeadersReply {
|
let msg = GetRequestHeadersReply {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
headers: headers,
|
headers,
|
||||||
headerSize: headersSize,
|
headerSize: headersSize,
|
||||||
rawHeaders: rawHeadersString,
|
rawHeaders: rawHeadersString,
|
||||||
};
|
};
|
||||||
|
@ -218,7 +218,7 @@ impl Actor for NetworkEventActor {
|
||||||
|
|
||||||
let msg = GetRequestCookiesReply {
|
let msg = GetRequestCookiesReply {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
cookies: cookies,
|
cookies,
|
||||||
};
|
};
|
||||||
let _ = stream.write_json_packet(&msg);
|
let _ = stream.write_json_packet(&msg);
|
||||||
ActorMessageStatus::Processed
|
ActorMessageStatus::Processed
|
||||||
|
@ -244,13 +244,13 @@ impl Actor for NetworkEventActor {
|
||||||
});
|
});
|
||||||
headersSize += name.as_str().len() + value.len();
|
headersSize += name.as_str().len() + value.len();
|
||||||
rawHeadersString.push_str(name.as_str());
|
rawHeadersString.push_str(name.as_str());
|
||||||
rawHeadersString.push_str(":");
|
rawHeadersString.push(':');
|
||||||
rawHeadersString.push_str(value.to_str().unwrap());
|
rawHeadersString.push_str(value.to_str().unwrap());
|
||||||
rawHeadersString.push_str("\r\n");
|
rawHeadersString.push_str("\r\n");
|
||||||
}
|
}
|
||||||
let msg = GetResponseHeadersReply {
|
let msg = GetResponseHeadersReply {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
headers: headers,
|
headers,
|
||||||
headerSize: headersSize,
|
headerSize: headersSize,
|
||||||
rawHeaders: rawHeadersString,
|
rawHeaders: rawHeadersString,
|
||||||
};
|
};
|
||||||
|
@ -269,7 +269,7 @@ impl Actor for NetworkEventActor {
|
||||||
|
|
||||||
let msg = GetResponseCookiesReply {
|
let msg = GetResponseCookiesReply {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
cookies: cookies,
|
cookies,
|
||||||
};
|
};
|
||||||
let _ = stream.write_json_packet(&msg);
|
let _ = stream.write_json_packet(&msg);
|
||||||
ActorMessageStatus::Processed
|
ActorMessageStatus::Processed
|
||||||
|
@ -322,7 +322,7 @@ impl Actor for NetworkEventActor {
|
||||||
impl NetworkEventActor {
|
impl NetworkEventActor {
|
||||||
pub fn new(name: String) -> NetworkEventActor {
|
pub fn new(name: String) -> NetworkEventActor {
|
||||||
NetworkEventActor {
|
NetworkEventActor {
|
||||||
name: name,
|
name,
|
||||||
request: HttpRequest {
|
request: HttpRequest {
|
||||||
url: String::new(),
|
url: String::new(),
|
||||||
method: Method::GET,
|
method: Method::GET,
|
||||||
|
@ -378,8 +378,8 @@ impl NetworkEventActor {
|
||||||
.as_millis() as i64,
|
.as_millis() as i64,
|
||||||
) {
|
) {
|
||||||
LocalResult::None => "".to_owned(),
|
LocalResult::None => "".to_owned(),
|
||||||
LocalResult::Single(dateTime) => format!("{}", dateTime.to_rfc3339()),
|
LocalResult::Single(dateTime) => dateTime.to_rfc3339().to_string(),
|
||||||
LocalResult::Ambiguous(dateTime, _) => format!("{}", dateTime.to_rfc3339()),
|
LocalResult::Ambiguous(dateTime, _) => dateTime.to_rfc3339().to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
EventActor {
|
EventActor {
|
||||||
|
|
|
@ -31,7 +31,7 @@ impl Actor for ObjectActor {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ObjectActor {
|
impl ObjectActor {
|
||||||
pub fn new(registry: &ActorRegistry, uuid: String) -> String {
|
pub fn register(registry: &ActorRegistry, uuid: String) -> String {
|
||||||
if !registry.script_actor_registered(uuid.clone()) {
|
if !registry.script_actor_registered(uuid.clone()) {
|
||||||
let name = registry.new_name("object");
|
let name = registry.new_name("object");
|
||||||
let actor = ObjectActor {
|
let actor = ObjectActor {
|
||||||
|
|
|
@ -98,7 +98,7 @@ impl Actor for PerformanceActor {
|
||||||
|
|
||||||
impl PerformanceActor {
|
impl PerformanceActor {
|
||||||
pub fn new(name: String) -> PerformanceActor {
|
pub fn new(name: String) -> PerformanceActor {
|
||||||
PerformanceActor { name: name }
|
PerformanceActor { name }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn description() -> ActorDescription {
|
pub fn description() -> ActorDescription {
|
||||||
|
|
|
@ -32,6 +32,6 @@ impl Actor for ProfilerActor {
|
||||||
|
|
||||||
impl ProfilerActor {
|
impl ProfilerActor {
|
||||||
pub fn new(name: String) -> ProfilerActor {
|
pub fn new(name: String) -> ProfilerActor {
|
||||||
ProfilerActor { name: name }
|
ProfilerActor { name }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,7 +189,7 @@ impl Actor for RootActor {
|
||||||
.map(|target| {
|
.map(|target| {
|
||||||
registry
|
registry
|
||||||
.find::<TabDescriptorActor>(target)
|
.find::<TabDescriptorActor>(target)
|
||||||
.encodable(®istry)
|
.encodable(registry)
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
};
|
};
|
||||||
|
@ -223,7 +223,7 @@ impl Actor for RootActor {
|
||||||
let tab = registry.find::<TabDescriptorActor>(&self.tabs[0]);
|
let tab = registry.find::<TabDescriptorActor>(&self.tabs[0]);
|
||||||
let reply = GetTabReply {
|
let reply = GetTabReply {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
tab: tab.encodable(®istry),
|
tab: tab.encodable(registry),
|
||||||
};
|
};
|
||||||
let _ = stream.write_json_packet(&reply);
|
let _ = stream.write_json_packet(&reply);
|
||||||
ActorMessageStatus::Processed
|
ActorMessageStatus::Processed
|
||||||
|
|
|
@ -50,6 +50,6 @@ impl Actor for StyleSheetsActor {
|
||||||
|
|
||||||
impl StyleSheetsActor {
|
impl StyleSheetsActor {
|
||||||
pub fn new(name: String) -> StyleSheetsActor {
|
pub fn new(name: String) -> StyleSheetsActor {
|
||||||
StyleSheetsActor { name: name }
|
StyleSheetsActor { name }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ impl TabDescriptorActor {
|
||||||
let root = actors.find_mut::<RootActor>("root");
|
let root = actors.find_mut::<RootActor>("root");
|
||||||
root.tabs.push(name.clone());
|
root.tabs.push(name.clone());
|
||||||
TabDescriptorActor {
|
TabDescriptorActor {
|
||||||
name: name,
|
name,
|
||||||
browsing_context_actor,
|
browsing_context_actor,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ pub struct ThreadActor {
|
||||||
|
|
||||||
impl ThreadActor {
|
impl ThreadActor {
|
||||||
pub fn new(name: String) -> ThreadActor {
|
pub fn new(name: String) -> ThreadActor {
|
||||||
ThreadActor { name: name }
|
ThreadActor { name }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ pub struct HighResolutionStamp(f64);
|
||||||
impl HighResolutionStamp {
|
impl HighResolutionStamp {
|
||||||
pub fn new(start_stamp: PreciseTime, time: PreciseTime) -> HighResolutionStamp {
|
pub fn new(start_stamp: PreciseTime, time: PreciseTime) -> HighResolutionStamp {
|
||||||
let duration = start_stamp.to(time).as_micros();
|
let duration = start_stamp.to(time).as_micros();
|
||||||
HighResolutionStamp(duration as f64 / 1000 as f64)
|
HighResolutionStamp(duration as f64 / 1000_f64)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wrap(time: f64) -> HighResolutionStamp {
|
pub fn wrap(time: f64) -> HighResolutionStamp {
|
||||||
|
@ -132,10 +132,10 @@ impl TimelineActor {
|
||||||
let marker_types = vec![TimelineMarkerType::Reflow, TimelineMarkerType::DOMEvent];
|
let marker_types = vec![TimelineMarkerType::Reflow, TimelineMarkerType::DOMEvent];
|
||||||
|
|
||||||
TimelineActor {
|
TimelineActor {
|
||||||
name: name,
|
name,
|
||||||
pipeline: pipeline,
|
pipeline,
|
||||||
marker_types: marker_types,
|
marker_types,
|
||||||
script_sender: script_sender,
|
script_sender,
|
||||||
is_recording: Arc::new(Mutex::new(false)),
|
is_recording: Arc::new(Mutex::new(false)),
|
||||||
stream: RefCell::new(None),
|
stream: RefCell::new(None),
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ impl Actor for TimelineActor {
|
||||||
if let Some(true) = with_ticks.as_bool() {
|
if let Some(true) = with_ticks.as_bool() {
|
||||||
let framerate_actor = Some(FramerateActor::create(
|
let framerate_actor = Some(FramerateActor::create(
|
||||||
registry,
|
registry,
|
||||||
self.pipeline.clone(),
|
self.pipeline,
|
||||||
self.script_sender.clone(),
|
self.script_sender.clone(),
|
||||||
));
|
));
|
||||||
*self.framerate_actor.borrow_mut() = framerate_actor;
|
*self.framerate_actor.borrow_mut() = framerate_actor;
|
||||||
|
@ -274,7 +274,7 @@ impl Actor for TimelineActor {
|
||||||
"isRecording" => {
|
"isRecording" => {
|
||||||
let msg = IsRecordingReply {
|
let msg = IsRecordingReply {
|
||||||
from: self.name(),
|
from: self.name(),
|
||||||
value: self.is_recording.lock().unwrap().clone(),
|
value: *self.is_recording.lock().unwrap(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = stream.write_json_packet(&msg);
|
let _ = stream.write_json_packet(&msg);
|
||||||
|
@ -297,9 +297,9 @@ impl Emitter {
|
||||||
) -> Emitter {
|
) -> Emitter {
|
||||||
Emitter {
|
Emitter {
|
||||||
from: name,
|
from: name,
|
||||||
stream: stream,
|
stream,
|
||||||
registry: registry,
|
registry,
|
||||||
start_stamp: start_stamp,
|
start_stamp,
|
||||||
|
|
||||||
framerate_actor: framerate_actor_name,
|
framerate_actor: framerate_actor_name,
|
||||||
memory_actor: memory_actor_name,
|
memory_actor: memory_actor_name,
|
||||||
|
@ -320,7 +320,7 @@ impl Emitter {
|
||||||
let end_time = PreciseTime::now();
|
let end_time = PreciseTime::now();
|
||||||
let reply = MarkersEmitterReply {
|
let reply = MarkersEmitterReply {
|
||||||
type_: "markers".to_owned(),
|
type_: "markers".to_owned(),
|
||||||
markers: markers,
|
markers,
|
||||||
from: self.from.clone(),
|
from: self.from.clone(),
|
||||||
endTime: HighResolutionStamp::new(self.start_stamp, end_time),
|
endTime: HighResolutionStamp::new(self.start_stamp, end_time),
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#![crate_name = "devtools"]
|
#![crate_name = "devtools"]
|
||||||
#![crate_type = "rlib"]
|
#![crate_type = "rlib"]
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
#![allow(clippy::too_many_arguments)]
|
||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
|
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
|
@ -135,7 +136,7 @@ fn run_server(
|
||||||
port: u16,
|
port: u16,
|
||||||
embedder: EmbedderProxy,
|
embedder: EmbedderProxy,
|
||||||
) {
|
) {
|
||||||
let bound = TcpListener::bind(&("0.0.0.0", port)).ok().and_then(|l| {
|
let bound = TcpListener::bind(("0.0.0.0", port)).ok().and_then(|l| {
|
||||||
l.local_addr()
|
l.local_addr()
|
||||||
.map(|addr| addr.port())
|
.map(|addr| addr.port())
|
||||||
.ok()
|
.ok()
|
||||||
|
@ -259,7 +260,7 @@ fn run_server(
|
||||||
Some(bc) => bc,
|
Some(bc) => bc,
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
let name = match browsing_contexts.get(&bc) {
|
let name = match browsing_contexts.get(bc) {
|
||||||
Some(name) => name,
|
Some(name) => name,
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
|
@ -299,7 +300,7 @@ fn run_server(
|
||||||
name: worker_name.clone(),
|
name: worker_name.clone(),
|
||||||
console: console_name.clone(),
|
console: console_name.clone(),
|
||||||
thread: thread_name,
|
thread: thread_name,
|
||||||
id: id,
|
id,
|
||||||
url: page_info.url.clone(),
|
url: page_info.url.clone(),
|
||||||
type_: WorkerType::Dedicated,
|
type_: WorkerType::Dedicated,
|
||||||
script_chan: script_sender,
|
script_chan: script_sender,
|
||||||
|
@ -324,7 +325,7 @@ fn run_server(
|
||||||
page_info,
|
page_info,
|
||||||
pipeline,
|
pipeline,
|
||||||
script_sender,
|
script_sender,
|
||||||
&mut *actors,
|
&mut actors,
|
||||||
);
|
);
|
||||||
let name = browsing_context_actor.name();
|
let name = browsing_context_actor.name();
|
||||||
browsing_contexts.insert(browsing_context, name.clone());
|
browsing_contexts.insert(browsing_context, name.clone());
|
||||||
|
@ -366,7 +367,7 @@ fn run_server(
|
||||||
let actors = actors.lock().unwrap();
|
let actors = actors.lock().unwrap();
|
||||||
let console_actor = actors.find::<ConsoleActor>(&console_actor_name);
|
let console_actor = actors.find::<ConsoleActor>(&console_actor_name);
|
||||||
let id = worker_id.map_or(UniqueId::Pipeline(id), UniqueId::Worker);
|
let id = worker_id.map_or(UniqueId::Pipeline(id), UniqueId::Worker);
|
||||||
console_actor.handle_page_error(page_error, id, &*actors);
|
console_actor.handle_page_error(page_error, id, &actors);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_console_message(
|
fn handle_console_message(
|
||||||
|
@ -392,7 +393,7 @@ fn run_server(
|
||||||
let actors = actors.lock().unwrap();
|
let actors = actors.lock().unwrap();
|
||||||
let console_actor = actors.find::<ConsoleActor>(&console_actor_name);
|
let console_actor = actors.find::<ConsoleActor>(&console_actor_name);
|
||||||
let id = worker_id.map_or(UniqueId::Pipeline(id), UniqueId::Worker);
|
let id = worker_id.map_or(UniqueId::Pipeline(id), UniqueId::Worker);
|
||||||
console_actor.handle_console_api(console_message, id, &*actors);
|
console_actor.handle_console_api(console_message, id, &actors);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_console_actor(
|
fn find_console_actor(
|
||||||
|
|
|
@ -80,7 +80,7 @@ impl JsonPacketStream for TcpStream {
|
||||||
Ok(packet_len) => packet_len,
|
Ok(packet_len) => packet_len,
|
||||||
Err(_) => return Err("nonvalid UTF8 in packet length".to_owned()),
|
Err(_) => return Err("nonvalid UTF8 in packet length".to_owned()),
|
||||||
};
|
};
|
||||||
let packet_len = match u64::from_str_radix(&packet_len_str, 10) {
|
let packet_len = match packet_len_str.parse::<u64>() {
|
||||||
Ok(packet_len) => packet_len,
|
Ok(packet_len) => packet_len,
|
||||||
Err(_) => return Err("packet length missing / not parsable".to_owned()),
|
Err(_) => return Err("packet length missing / not parsable".to_owned()),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue