mirror of
https://github.com/servo/servo.git
synced 2025-07-05 14:33:38 +01:00
feat(constellation): expose msg for bluetooth thread
This commit is contained in:
parent
3695fc4efc
commit
c141090d61
4 changed files with 24 additions and 5 deletions
|
@ -123,12 +123,12 @@ use pipeline::{InitialPipelineState, Pipeline};
|
||||||
use profile_traits::mem;
|
use profile_traits::mem;
|
||||||
use profile_traits::time;
|
use profile_traits::time;
|
||||||
use script_traits::{AnimationState, AnimationTickType, CompositorEvent};
|
use script_traits::{AnimationState, AnimationTickType, CompositorEvent};
|
||||||
|
use script_traits::{BluetoothManagerMsg, SWManagerMsg, ScopeThings, UpdatePipelineIdReason, WebDriverCommandMsg};
|
||||||
use script_traits::{ConstellationControlMsg, ConstellationMsg as FromCompositorMsg, DiscardBrowsingContext};
|
use script_traits::{ConstellationControlMsg, ConstellationMsg as FromCompositorMsg, DiscardBrowsingContext};
|
||||||
use script_traits::{DocumentActivity, DocumentState, LayoutControlMsg, LoadData};
|
use script_traits::{DocumentActivity, DocumentState, LayoutControlMsg, LoadData};
|
||||||
use script_traits::{IFrameLoadInfo, IFrameLoadInfoWithData, IFrameSandboxState, TimerSchedulerMsg};
|
use script_traits::{IFrameLoadInfo, IFrameLoadInfoWithData, IFrameSandboxState, TimerSchedulerMsg};
|
||||||
use script_traits::{LayoutMsg as FromLayoutMsg, ScriptMsg as FromScriptMsg, ScriptThreadFactory};
|
use script_traits::{LayoutMsg as FromLayoutMsg, ScriptMsg as FromScriptMsg, ScriptThreadFactory};
|
||||||
use script_traits::{LogEntry, ScriptToConstellationChan, ServiceWorkerMsg, webdriver_msg};
|
use script_traits::{LogEntry, ScriptToConstellationChan, ServiceWorkerMsg, webdriver_msg};
|
||||||
use script_traits::{SWManagerMsg, ScopeThings, UpdatePipelineIdReason, WebDriverCommandMsg};
|
|
||||||
use script_traits::{WindowSizeData, WindowSizeType};
|
use script_traits::{WindowSizeData, WindowSizeType};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use servo_config::opts;
|
use servo_config::opts;
|
||||||
|
@ -174,6 +174,9 @@ pub struct Constellation<Message, LTF, STF> {
|
||||||
/// This is the constellation's view of `script_sender`.
|
/// This is the constellation's view of `script_sender`.
|
||||||
script_receiver: Receiver<Result<(PipelineId, FromScriptMsg), IpcError>>,
|
script_receiver: Receiver<Result<(PipelineId, FromScriptMsg), IpcError>>,
|
||||||
|
|
||||||
|
/// A channel for the constellation to receive messages from bluetooth threads.
|
||||||
|
bluetoothmanager_receiver: Receiver<Result<BluetoothManagerMsg, IpcError>>,
|
||||||
|
|
||||||
/// An IPC channel for layout threads to send messages to the constellation.
|
/// An IPC channel for layout threads to send messages to the constellation.
|
||||||
/// This is the layout threads' view of `layout_receiver`.
|
/// This is the layout threads' view of `layout_receiver`.
|
||||||
layout_sender: IpcSender<FromLayoutMsg>,
|
layout_sender: IpcSender<FromLayoutMsg>,
|
||||||
|
@ -546,17 +549,23 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
||||||
STF: ScriptThreadFactory<Message=Message>
|
STF: ScriptThreadFactory<Message=Message>
|
||||||
{
|
{
|
||||||
/// Create a new constellation thread.
|
/// Create a new constellation thread.
|
||||||
pub fn start(state: InitialConstellationState) -> (Sender<FromCompositorMsg>, IpcSender<SWManagerMsg>) {
|
pub fn start(state: InitialConstellationState)
|
||||||
|
-> (Sender<FromCompositorMsg>, IpcSender<SWManagerMsg>, IpcSender<BluetoothManagerMsg>) {
|
||||||
let (compositor_sender, compositor_receiver) = channel();
|
let (compositor_sender, compositor_receiver) = channel();
|
||||||
|
|
||||||
// service worker manager to communicate with constellation
|
// service worker manager to communicate with constellation
|
||||||
let (swmanager_sender, swmanager_receiver) = ipc::channel().expect("ipc channel failure");
|
let (swmanager_sender, swmanager_receiver) = ipc::channel().expect("ipc channel failure");
|
||||||
let sw_mgr_clone = swmanager_sender.clone();
|
let sw_mgr_clone = swmanager_sender.clone();
|
||||||
|
|
||||||
|
let (bluetoothmanager_sender, bluetoothmanager_receiver) = ipc::channel().expect("ipc channel failure");
|
||||||
|
|
||||||
thread::Builder::new().name("Constellation".to_owned()).spawn(move || {
|
thread::Builder::new().name("Constellation".to_owned()).spawn(move || {
|
||||||
let (ipc_script_sender, ipc_script_receiver) = ipc::channel().expect("ipc channel failure");
|
let (ipc_script_sender, ipc_script_receiver) = ipc::channel().expect("ipc channel failure");
|
||||||
let script_receiver = route_ipc_receiver_to_new_mpsc_receiver_preserving_errors(ipc_script_receiver);
|
let script_receiver = route_ipc_receiver_to_new_mpsc_receiver_preserving_errors(ipc_script_receiver);
|
||||||
|
|
||||||
|
let bluetoothmanager_receiver =
|
||||||
|
route_ipc_receiver_to_new_mpsc_receiver_preserving_errors(bluetoothmanager_receiver);
|
||||||
|
|
||||||
let (ipc_layout_sender, ipc_layout_receiver) = ipc::channel().expect("ipc channel failure");
|
let (ipc_layout_sender, ipc_layout_receiver) = ipc::channel().expect("ipc channel failure");
|
||||||
let layout_receiver = route_ipc_receiver_to_new_mpsc_receiver_preserving_errors(ipc_layout_receiver);
|
let layout_receiver = route_ipc_receiver_to_new_mpsc_receiver_preserving_errors(ipc_layout_receiver);
|
||||||
|
|
||||||
|
@ -570,6 +579,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
||||||
script_sender: ipc_script_sender,
|
script_sender: ipc_script_sender,
|
||||||
layout_sender: ipc_layout_sender,
|
layout_sender: ipc_layout_sender,
|
||||||
script_receiver: script_receiver,
|
script_receiver: script_receiver,
|
||||||
|
bluetoothmanager_receiver: bluetoothmanager_receiver,
|
||||||
compositor_receiver: compositor_receiver,
|
compositor_receiver: compositor_receiver,
|
||||||
layout_receiver: layout_receiver,
|
layout_receiver: layout_receiver,
|
||||||
network_listener_sender: network_listener_sender,
|
network_listener_sender: network_listener_sender,
|
||||||
|
@ -636,7 +646,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
||||||
constellation.run();
|
constellation.run();
|
||||||
}).expect("Thread spawning failed");
|
}).expect("Thread spawning failed");
|
||||||
|
|
||||||
(compositor_sender, swmanager_sender)
|
(compositor_sender, swmanager_sender, bluetoothmanager_sender)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The main event loop for the constellation.
|
/// The main event loop for the constellation.
|
||||||
|
|
|
@ -73,7 +73,7 @@ use webrender_api::{ExternalScrollId, DevicePixel, DeviceUintSize, DocumentId, I
|
||||||
use webvr_traits::{WebVREvent, WebVRMsg};
|
use webvr_traits::{WebVREvent, WebVRMsg};
|
||||||
|
|
||||||
pub use script_msg::{LayoutMsg, ScriptMsg, EventResult, LogEntry};
|
pub use script_msg::{LayoutMsg, ScriptMsg, EventResult, LogEntry};
|
||||||
pub use script_msg::{ServiceWorkerMsg, ScopeThings, SWManagerMsg, SWManagerSenders, DOMMessage};
|
pub use script_msg::{BluetoothManagerMsg, ServiceWorkerMsg, ScopeThings, SWManagerMsg, SWManagerSenders, DOMMessage};
|
||||||
|
|
||||||
/// The address of a node. Layout sends these back. They must be validated via
|
/// The address of a node. Layout sends these back. They must be validated via
|
||||||
/// `from_untrusted_node_address` before they can be used, because we do not trust layout.
|
/// `from_untrusted_node_address` before they can be used, because we do not trust layout.
|
||||||
|
|
|
@ -213,3 +213,10 @@ pub enum SWManagerMsg {
|
||||||
/// Provide the constellation with a means of communicating with the Service Worker Manager
|
/// Provide the constellation with a means of communicating with the Service Worker Manager
|
||||||
OwnSender(IpcSender<ServiceWorkerMsg>),
|
OwnSender(IpcSender<ServiceWorkerMsg>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Messages outgoing from the Bluetooth Manager thread to constellation
|
||||||
|
#[derive(Deserialize, Serialize)]
|
||||||
|
pub enum BluetoothManagerMsg {
|
||||||
|
/// Requesting to open device select dialog
|
||||||
|
OpenDeviceSelectDialog(Vec<String>, IpcSender<Option<String>>)
|
||||||
|
}
|
||||||
|
|
|
@ -526,7 +526,9 @@ fn create_constellation(user_agent: Cow<'static, str>,
|
||||||
webgl_threads,
|
webgl_threads,
|
||||||
webvr_chan,
|
webvr_chan,
|
||||||
};
|
};
|
||||||
let (constellation_chan, from_swmanager_sender) =
|
let (constellation_chan,
|
||||||
|
from_swmanager_sender,
|
||||||
|
from_bluetoothmanager_sender) =
|
||||||
Constellation::<script_layout_interface::message::Msg,
|
Constellation::<script_layout_interface::message::Msg,
|
||||||
layout_thread::LayoutThread,
|
layout_thread::LayoutThread,
|
||||||
script::script_thread::ScriptThread>::start(initial_state);
|
script::script_thread::ScriptThread>::start(initial_state);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue