diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2018-10-15 03:33:03 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-15 03:33:03 -0400 |
commit | d22b10391d361fe673d70b60c838e459f4ac6f5a (patch) | |
tree | 4236ba06cc2c5a7e8cc64767722f2545dfdbad6b | |
parent | 5327758b9bd48d3dc5c453a15092546f9e53b8b9 (diff) | |
parent | 9ccf7c0a57a7aa6dfd22bdd946cdf0fd14307e18 (diff) | |
download | servo-d22b10391d361fe673d70b60c838e459f4ac6f5a.tar.gz servo-d22b10391d361fe673d70b60c838e459f4ac6f5a.zip |
Auto merge of #21945 - codehag:devtools-add-emulation-actor, r=jdm
DevTools - add Emulation Actor
Last one for today, this one adds the Emulation actor, which allows the netmonitor panel to load. The emulation actor has no methods for now, but will eventually be used by the netmonitor to throttle connections.
Currently the netmonitor shows but doesn't have any values. will get to that soon!
<img width="901" alt="screen shot 2018-10-14 at 19 26 16" src="https://user-images.githubusercontent.com/26968615/46920018-30a0b180-cfe8-11e8-83ec-51ca71f0e8c3.png">
Combined with the changes for the stylesheets actor, the device actor, and the extra methods added in browserContext and threadActor, the devtools are now all loading \o/
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21945)
<!-- Reviewable:end -->
-rw-r--r-- | components/devtools/actors/browsing_context.rs | 3 | ||||
-rw-r--r-- | components/devtools/actors/emulation.rs | 35 | ||||
-rw-r--r-- | components/devtools/lib.rs | 10 |
3 files changed, 47 insertions, 1 deletions
diff --git a/components/devtools/actors/browsing_context.rs b/components/devtools/actors/browsing_context.rs index 13e304eceff..2c8589a9dda 100644 --- a/components/devtools/actors/browsing_context.rs +++ b/components/devtools/actors/browsing_context.rs @@ -72,6 +72,7 @@ pub struct BrowsingContextActorMsg { url: String, outerWindowID: u32, consoleActor: String, + emulationActor: String, inspectorActor: String, timelineActor: String, profilerActor: String, @@ -84,6 +85,7 @@ pub struct BrowsingContextActor { pub title: String, pub url: String, pub console: String, + pub emulation: String, pub inspector: String, pub timeline: String, pub profiler: String, @@ -192,6 +194,7 @@ impl BrowsingContextActor { url: self.url.clone(), outerWindowID: 0, //FIXME: this should probably be the pipeline id consoleActor: self.console.clone(), + emulationActor: self.emulation.clone(), inspectorActor: self.inspector.clone(), timelineActor: self.timeline.clone(), profilerActor: self.profiler.clone(), diff --git a/components/devtools/actors/emulation.rs b/components/devtools/actors/emulation.rs new file mode 100644 index 00000000000..3ab156791e0 --- /dev/null +++ b/components/devtools/actors/emulation.rs @@ -0,0 +1,35 @@ +/* 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 serde_json::{Map, Value}; +use std::net::TcpStream; + +pub struct EmulationActor { + pub name: String, +} + +impl Actor for EmulationActor { + fn name(&self) -> String { + self.name.clone() + } + + fn handle_message( + &self, + _registry: &ActorRegistry, + msg_type: &str, + _msg: &Map<String, Value>, + _stream: &mut TcpStream, + ) -> Result<ActorMessageStatus, ()> { + Ok(match msg_type { + _ => ActorMessageStatus::Ignored, + }) + } +} + +impl EmulationActor { + pub fn new(name: String) -> EmulationActor { + EmulationActor { name: name } + } +} diff --git a/components/devtools/lib.rs b/components/devtools/lib.rs index 1d76fbfb457..547f96bc445 100644 --- a/components/devtools/lib.rs +++ b/components/devtools/lib.rs @@ -28,6 +28,7 @@ use actor::{Actor, ActorRegistry}; use actors::browsing_context::BrowsingContextActor; use actors::console::ConsoleActor; use actors::device::DeviceActor; +use actors::emulation::EmulationActor; use actors::framerate::FramerateActor; use actors::inspector::InspectorActor; use actors::network_event::{EventActor, NetworkEventActor, ResponseStartMsg}; @@ -60,6 +61,7 @@ mod actors { pub mod browsing_context; pub mod console; pub mod device; + pub mod emulation; pub mod framerate; pub mod inspector; pub mod memory; @@ -230,13 +232,16 @@ fn run_server( let (pipeline, worker_id) = ids; //TODO: move all this actor creation into a constructor method on BrowsingContextActor - let (target, console, inspector, timeline, profiler, performance, styleSheets, thread) = { + let (target, console, emulation, inspector, timeline, profiler, performance, styleSheets, thread) = { let console = ConsoleActor { name: actors.new_name("console"), script_chan: script_sender.clone(), pipeline: pipeline, streams: RefCell::new(Vec::new()), }; + + let emulation = EmulationActor::new(actors.new_name("emulation")); + let inspector = InspectorActor { name: actors.new_name("inspector"), walker: RefCell::new(None), @@ -262,6 +267,7 @@ fn run_server( title: String::from(title), url: url.into_string(), console: console.name(), + emulation: emulation.name(), inspector: inspector.name(), timeline: timeline.name(), profiler: profiler.name(), @@ -276,6 +282,7 @@ fn run_server( ( target, console, + emulation, inspector, timeline, profiler, @@ -298,6 +305,7 @@ fn run_server( actor_pipelines.insert(pipeline, target.name.clone()); actors.register(Box::new(target)); actors.register(Box::new(console)); + actors.register(Box::new(emulation)); actors.register(Box::new(inspector)); actors.register(Box::new(timeline)); actors.register(Box::new(profiler)); |