diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 620e4b61460..fa2647ace38 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -123,12 +123,12 @@ use pipeline::{InitialPipelineState, Pipeline}; use profile_traits::mem; use profile_traits::time; 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::{DocumentActivity, DocumentState, LayoutControlMsg, LoadData}; use script_traits::{IFrameLoadInfo, IFrameLoadInfoWithData, IFrameSandboxState, TimerSchedulerMsg}; use script_traits::{LayoutMsg as FromLayoutMsg, ScriptMsg as FromScriptMsg, ScriptThreadFactory}; use script_traits::{LogEntry, ScriptToConstellationChan, ServiceWorkerMsg, webdriver_msg}; -use script_traits::{SWManagerMsg, ScopeThings, UpdatePipelineIdReason, WebDriverCommandMsg}; use script_traits::{WindowSizeData, WindowSizeType}; use serde::{Deserialize, Serialize}; use servo_config::opts; @@ -174,6 +174,9 @@ pub struct Constellation { /// This is the constellation's view of `script_sender`. script_receiver: Receiver>, + /// A channel for the constellation to receive messages from bluetooth threads. + bluetoothmanager_receiver: Receiver>, + /// An IPC channel for layout threads to send messages to the constellation. /// This is the layout threads' view of `layout_receiver`. layout_sender: IpcSender, @@ -546,17 +549,23 @@ impl Constellation STF: ScriptThreadFactory { /// Create a new constellation thread. - pub fn start(state: InitialConstellationState) -> (Sender, IpcSender) { + pub fn start(state: InitialConstellationState) + -> (Sender, IpcSender, IpcSender) { let (compositor_sender, compositor_receiver) = channel(); // service worker manager to communicate with constellation let (swmanager_sender, swmanager_receiver) = ipc::channel().expect("ipc channel failure"); 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 || { 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 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 layout_receiver = route_ipc_receiver_to_new_mpsc_receiver_preserving_errors(ipc_layout_receiver); @@ -570,6 +579,7 @@ impl Constellation script_sender: ipc_script_sender, layout_sender: ipc_layout_sender, script_receiver: script_receiver, + bluetoothmanager_receiver: bluetoothmanager_receiver, compositor_receiver: compositor_receiver, layout_receiver: layout_receiver, network_listener_sender: network_listener_sender, @@ -636,7 +646,7 @@ impl Constellation constellation.run(); }).expect("Thread spawning failed"); - (compositor_sender, swmanager_sender) + (compositor_sender, swmanager_sender, bluetoothmanager_sender) } /// The main event loop for the constellation. diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index d270d87a50c..316f4bc128e 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -73,7 +73,7 @@ use webrender_api::{ExternalScrollId, DevicePixel, DeviceUintSize, DocumentId, I use webvr_traits::{WebVREvent, WebVRMsg}; 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 /// `from_untrusted_node_address` before they can be used, because we do not trust layout. diff --git a/components/script_traits/script_msg.rs b/components/script_traits/script_msg.rs index 43812ad097a..65829b02406 100644 --- a/components/script_traits/script_msg.rs +++ b/components/script_traits/script_msg.rs @@ -213,3 +213,10 @@ pub enum SWManagerMsg { /// Provide the constellation with a means of communicating with the Service Worker Manager OwnSender(IpcSender), } + +/// Messages outgoing from the Bluetooth Manager thread to constellation +#[derive(Deserialize, Serialize)] +pub enum BluetoothManagerMsg { + /// Requesting to open device select dialog + OpenDeviceSelectDialog(Vec, IpcSender>) +} diff --git a/components/servo/lib.rs b/components/servo/lib.rs index 1d8e64ab8e4..9b17735b8ba 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -526,7 +526,9 @@ fn create_constellation(user_agent: Cow<'static, str>, webgl_threads, webvr_chan, }; - let (constellation_chan, from_swmanager_sender) = + let (constellation_chan, + from_swmanager_sender, + from_bluetoothmanager_sender) = Constellation::::start(initial_state);