mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Implement a dummy protocolDescription in the root actor
This commit is contained in:
parent
9a2955d4da
commit
14653e2875
3 changed files with 47 additions and 2 deletions
|
@ -3,7 +3,7 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
||||||
use protocol::JsonPacketStream;
|
use protocol::{ActorDescription, JsonPacketStream, Method};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
|
@ -70,4 +70,12 @@ impl PerformanceActor {
|
||||||
name: name,
|
name: name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn description() -> ActorDescription {
|
||||||
|
ActorDescription {
|
||||||
|
category: "actor",
|
||||||
|
typeName: "performance",
|
||||||
|
methods: vec![],
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,9 @@
|
||||||
/// that perform more specific actions (tabs, addons, browser chrome, etc.)
|
/// that perform more specific actions (tabs, addons, browser chrome, etc.)
|
||||||
|
|
||||||
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
||||||
|
use actors::performance::PerformanceActor;
|
||||||
use actors::tab::{TabActor, TabActorMsg};
|
use actors::tab::{TabActor, TabActorMsg};
|
||||||
use protocol::JsonPacketStream;
|
use protocol::{ActorDescription, JsonPacketStream};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
|
@ -44,6 +45,17 @@ pub struct RootActorMsg {
|
||||||
traits: ActorTraits,
|
traits: ActorTraits,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
pub struct ProtocolDescriptionReply {
|
||||||
|
from: String,
|
||||||
|
types: Types,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
pub struct Types {
|
||||||
|
performance: ActorDescription,
|
||||||
|
}
|
||||||
|
|
||||||
pub struct RootActor {
|
pub struct RootActor {
|
||||||
pub tabs: Vec<String>,
|
pub tabs: Vec<String>,
|
||||||
}
|
}
|
||||||
|
@ -81,6 +93,17 @@ impl Actor for RootActor {
|
||||||
ActorMessageStatus::Processed
|
ActorMessageStatus::Processed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"protocolDescription" => {
|
||||||
|
let msg = ProtocolDescriptionReply {
|
||||||
|
from: self.name(),
|
||||||
|
types: Types {
|
||||||
|
performance: PerformanceActor::description(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
stream.write_json_packet(&msg);
|
||||||
|
ActorMessageStatus::Processed
|
||||||
|
}
|
||||||
|
|
||||||
_ => ActorMessageStatus::Ignored
|
_ => ActorMessageStatus::Ignored
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,20 @@ use std::error::Error;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
pub struct ActorDescription {
|
||||||
|
pub category: &'static str,
|
||||||
|
pub typeName: &'static str,
|
||||||
|
pub methods: Vec<Method>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
pub struct Method {
|
||||||
|
pub name: &'static str,
|
||||||
|
pub request: Value,
|
||||||
|
pub response: Value,
|
||||||
|
}
|
||||||
|
|
||||||
pub trait JsonPacketStream {
|
pub trait JsonPacketStream {
|
||||||
fn write_json_packet<T: Serialize>(&mut self, obj: &T);
|
fn write_json_packet<T: Serialize>(&mut self, obj: &T);
|
||||||
fn read_json_packet(&mut self) -> Result<Option<Value>, String>;
|
fn read_json_packet(&mut self) -> Result<Option<Value>, String>;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue