diff options
author | bors-servo <servo-ops@mozilla.com> | 2020-04-05 11:02:08 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-05 11:02:08 -0400 |
commit | ae49473c25d61452d1cd02db03bc9760b6cd95c2 (patch) | |
tree | 3615866e8cf020b6e1efcadde7789df399d897d5 /components/servo/lib.rs | |
parent | 406eefb4b1e02a40638317290006ac8e828e0764 (diff) | |
parent | 1e017a7082e7649a4d2d2f2b8b8d1a1a23c7fb84 (diff) | |
download | servo-ae49473c25d61452d1cd02db03bc9760b6cd95c2.tar.gz servo-ae49473c25d61452d1cd02db03bc9760b6cd95c2.zip |
Auto merge of #26087 - gterzian:allow_service_workers_in_multiprocess, r=jdm
Fix ServiceWorker in multiprocess
<!-- Please describe your changes on the following line: -->
FIX #15217
FIX #26100
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./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. -->
Diffstat (limited to 'components/servo/lib.rs')
-rw-r--r-- | components/servo/lib.rs | 72 |
1 files changed, 34 insertions, 38 deletions
diff --git a/components/servo/lib.rs b/components/servo/lib.rs index 5c54f654881..dff8c842e4f 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -80,7 +80,7 @@ use compositing::{CompositingReason, ConstellationMsg, IOCompositor, ShutdownSta not(target_arch = "aarch64") ))] use constellation::content_process_sandbox_profile; -use constellation::{Constellation, InitialConstellationState, UnprivilegedPipelineContent}; +use constellation::{Constellation, InitialConstellationState, UnprivilegedContent}; use constellation::{FromCompositorLogger, FromScriptLogger}; use crossbeam_channel::{unbounded, Sender}; use embedder_traits::{EmbedderMsg, EmbedderProxy, EmbedderReceiver, EventLoopWaker}; @@ -105,8 +105,9 @@ use profile::mem as profile_mem; use profile::time as profile_time; use profile_traits::mem; use profile_traits::time; +use script::serviceworker_manager::ServiceWorkerManager; use script::JSEngineSetup; -use script_traits::{SWManagerSenders, ScriptToConstellationChan, WindowSizeData}; +use script_traits::{ScriptToConstellationChan, WindowSizeData}; use servo_config::opts; use servo_config::{pref, prefs}; use servo_media::player::context::GlContext; @@ -519,7 +520,7 @@ where // Create the constellation, which maintains the engine // pipelines, including the script and layout threads, as well // as the navigation context. - let (constellation_chan, sw_senders) = create_constellation( + let constellation_chan = create_constellation( opts.user_agent.clone(), opts.config_dir.clone(), embedder_proxy, @@ -541,9 +542,6 @@ where pending_wr_frame.clone(), ); - // Send the constellation's swmanager sender to service worker manager thread - script::init_service_workers(sw_senders); - if cfg!(feature = "webdriver") { if let Some(port) = opts.webdriver_port { webdriver(port, constellation_chan.clone()); @@ -879,7 +877,7 @@ fn create_constellation( event_loop_waker: Option<Box<dyn EventLoopWaker>>, initial_window_size: WindowSizeData, pending_wr_frame: Arc<AtomicBool>, -) -> (Sender<ConstellationMsg>, SWManagerSenders) { +) -> Sender<ConstellationMsg> { // Global configuration options, parsed from the command line. let opts = opts::get(); @@ -900,8 +898,6 @@ fn create_constellation( webrender_api_sender.create_api(), ); - let resource_sender = public_resource_threads.sender(); - let initial_state = InitialConstellationState { compositor_proxy, embedder_proxy, @@ -926,10 +922,11 @@ fn create_constellation( let (canvas_chan, ipc_canvas_chan) = canvas::canvas_paint_thread::CanvasPaintThread::start(); - let (constellation_chan, from_swmanager_sender) = Constellation::< + let constellation_chan = Constellation::< script_layout_interface::message::Msg, layout_thread::LayoutThread, script::script_thread::ScriptThread, + script::serviceworker_manager::ServiceWorkerManager, >::start( initial_state, initial_window_size, @@ -949,13 +946,7 @@ fn create_constellation( .unwrap(); } - // channels to communicate with Service Worker Manager - let sw_senders = SWManagerSenders { - swmanager_sender: from_swmanager_sender, - resource_sender: resource_sender, - }; - - (constellation_chan, sw_senders) + constellation_chan } // A logger that logs to two downstream loggers. @@ -997,45 +988,50 @@ pub fn set_logger(script_to_constellation_chan: ScriptToConstellationChan) { /// Content process entry point. pub fn run_content_process(token: String) { let (unprivileged_content_sender, unprivileged_content_receiver) = - ipc::channel::<UnprivilegedPipelineContent>().unwrap(); - let connection_bootstrap: IpcSender<IpcSender<UnprivilegedPipelineContent>> = + ipc::channel::<UnprivilegedContent>().unwrap(); + let connection_bootstrap: IpcSender<IpcSender<UnprivilegedContent>> = IpcSender::connect(token).unwrap(); connection_bootstrap .send(unprivileged_content_sender) .unwrap(); - let mut unprivileged_content = unprivileged_content_receiver.recv().unwrap(); + let unprivileged_content = unprivileged_content_receiver.recv().unwrap(); opts::set_options(unprivileged_content.opts()); prefs::pref_map() .set_all(unprivileged_content.prefs()) .expect("Failed to set preferences"); - set_logger(unprivileged_content.script_to_constellation_chan().clone()); // Enter the sandbox if necessary. if opts::get().sandbox { create_sandbox(); } - let background_hang_monitor_register = if opts::get().background_hang_monitor { - unprivileged_content.register_with_background_hang_monitor() - } else { - None - }; - - // send the required channels to the service worker manager - let sw_senders = unprivileged_content.swmanager_senders(); let _js_engine_setup = script::init(); - script::init_service_workers(sw_senders); - media_platform::init(); + match unprivileged_content { + UnprivilegedContent::Pipeline(mut content) => { + media_platform::init(); + + set_logger(content.script_to_constellation_chan().clone()); - unprivileged_content.start_all::<script_layout_interface::message::Msg, - layout_thread::LayoutThread, - script::script_thread::ScriptThread>( - true, - background_hang_monitor_register, - None, - ); + let background_hang_monitor_register = if opts::get().background_hang_monitor { + content.register_with_background_hang_monitor() + } else { + None + }; + + content.start_all::<script_layout_interface::message::Msg, + layout_thread::LayoutThread, + script::script_thread::ScriptThread>( + true, + background_hang_monitor_register, + None, + ); + }, + UnprivilegedContent::ServiceWorker(content) => { + content.start::<ServiceWorkerManager>(); + }, + } } #[cfg(all( |