mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
DevTools - add DeviceActor and update Root to own global actors
This commit is contained in:
parent
cdd7f0a658
commit
5c8492d760
3 changed files with 123 additions and 1 deletions
|
@ -8,6 +8,7 @@
|
|||
/// that perform more specific actions (targets, addons, browser chrome, etc.)
|
||||
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
||||
use actors::browsing_context::{BrowsingContextActor, BrowsingContextActorMsg};
|
||||
use actors::device::DeviceActor;
|
||||
use actors::performance::PerformanceActor;
|
||||
use protocol::{ActorDescription, JsonPacketStream};
|
||||
use serde_json::{Map, Value};
|
||||
|
@ -30,6 +31,14 @@ struct ListAddonsReply {
|
|||
#[derive(Serialize)]
|
||||
enum AddonMsg {}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct GetRootReply {
|
||||
from: String,
|
||||
selected: u32,
|
||||
performanceActor: String,
|
||||
deviceActor: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct ListTabsReply {
|
||||
from: String,
|
||||
|
@ -53,10 +62,13 @@ pub struct ProtocolDescriptionReply {
|
|||
#[derive(Serialize)]
|
||||
pub struct Types {
|
||||
performance: ActorDescription,
|
||||
device: ActorDescription,
|
||||
}
|
||||
|
||||
pub struct RootActor {
|
||||
pub tabs: Vec<String>,
|
||||
pub performance: String,
|
||||
pub device: String,
|
||||
}
|
||||
|
||||
impl Actor for RootActor {
|
||||
|
@ -81,6 +93,17 @@ impl Actor for RootActor {
|
|||
ActorMessageStatus::Processed
|
||||
},
|
||||
|
||||
"getRoot" => {
|
||||
let actor = GetRootReply {
|
||||
from: "root".to_owned(),
|
||||
selected: 0,
|
||||
performanceActor: self.performance.clone(),
|
||||
deviceActor: self.device.clone(),
|
||||
};
|
||||
stream.write_json_packet(&actor);
|
||||
ActorMessageStatus::Processed
|
||||
},
|
||||
|
||||
// https://docs.firefox-dev.tools/backend/protocol.html#listing-browser-tabs
|
||||
"listTabs" => {
|
||||
let actor = ListTabsReply {
|
||||
|
@ -101,6 +124,7 @@ impl Actor for RootActor {
|
|||
from: self.name(),
|
||||
types: Types {
|
||||
performance: PerformanceActor::description(),
|
||||
device: DeviceActor::description(),
|
||||
},
|
||||
};
|
||||
stream.write_json_packet(&msg);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue