Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ServiceWorker in multiprocess #26087

Merged
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

allow for a service worker network mediator per origin

  • Loading branch information
gterzian committed Apr 5, 2020
commit 1e017a7082e7649a4d2d2f2b8b8d1a1a23c7fb84
@@ -16,13 +16,6 @@ mod constellation;
mod event_loop;
mod network_listener;
mod pipeline;
#[cfg(all(
not(target_os = "windows"),
not(target_os = "ios"),
not(target_os = "android"),
not(target_arch = "arm"),
not(target_arch = "aarch64")
))]
mod sandboxing;
mod serviceworker;
mod session_history;
@@ -32,11 +25,4 @@ pub use crate::constellation::{
Constellation, FromCompositorLogger, FromScriptLogger, InitialConstellationState,
};
pub use crate::pipeline::UnprivilegedPipelineContent;
#[cfg(all(
not(target_os = "windows"),
not(target_os = "ios"),
not(target_os = "android"),
not(target_arch = "arm"),
not(target_arch = "aarch64")
))]
pub use crate::sandboxing::{content_process_sandbox_profile, UnprivilegedContent};
@@ -39,7 +39,7 @@ use profile_traits::mem::{Report, ReportKind, ReportsChan};
use profile_traits::time::ProfilerChan;
use serde::{Deserialize, Serialize};
use servo_arc::Arc as ServoArc;
use servo_url::ServoUrl;
use servo_url::{ImmutableOrigin, ServoUrl};
use std::borrow::{Cow, ToOwned};
use std::collections::HashMap;
use std::fs::{self, File};
@@ -299,8 +299,10 @@ impl ResourceChannelManager {
.send(cookie_jar.cookies_for_url(&url, source))
.unwrap();
},
CoreResourceMsg::NetworkMediator(mediator_chan) => {
self.resource_manager.swmanager_chan = Some(mediator_chan)
CoreResourceMsg::NetworkMediator(mediator_chan, origin) => {
self.resource_manager
.sw_managers
.insert(origin, mediator_chan);
},
CoreResourceMsg::GetCookiesDataForUrl(url, consumer, source) => {
let mut cookie_jar = http_state.cookie_jar.write().unwrap();
@@ -431,7 +433,7 @@ pub struct AuthCache {
pub struct CoreResourceManager {
user_agent: Cow<'static, str>,
devtools_chan: Option<Sender<DevtoolsControlMsg>>,
swmanager_chan: Option<IpcSender<CustomResponseMediator>>,
sw_managers: HashMap<ImmutableOrigin, IpcSender<CustomResponseMediator>>,
filemanager: FileManager,
thread_pool: Arc<CoreResourceThreadPool>,
certificate_path: Option<String>,
@@ -575,7 +577,7 @@ impl CoreResourceManager {
CoreResourceManager {
user_agent: user_agent,
devtools_chan: devtools_channel,
swmanager_chan: None,
sw_managers: Default::default(),
filemanager: FileManager::new(embedder_proxy, Arc::downgrade(&pool_handle)),
thread_pool: pool_handle,
certificate_path,
@@ -30,7 +30,7 @@ use ipc_channel::router::ROUTER;
use ipc_channel::Error as IpcError;
use mime::Mime;
use msg::constellation_msg::HistoryStateId;
use servo_url::ServoUrl;
use servo_url::{ImmutableOrigin, ServoUrl};
use time::precise_time_ns;
use webrender_api::ImageKey;

@@ -423,8 +423,8 @@ pub enum CoreResourceMsg {
RemoveHistoryStates(Vec<HistoryStateId>),
/// Synchronization message solely for knowing the state of the ResourceChannelManager loop
Synchronize(IpcSender<()>),
/// Send the network sender in constellation to CoreResourceThread
NetworkMediator(IpcSender<CustomResponseMediator>),
/// Send the service worker network mediator for an origin to CoreResourceThread
NetworkMediator(IpcSender<CustomResponseMediator>, ImmutableOrigin),
/// Message forwarded to file manager's handler
ToFileManager(FileManagerThreadMsg),
/// Break the load handler loop, send a reply when done cleaning up local resources
@@ -192,7 +192,7 @@ impl ServiceWorkerManager {
}

impl ServiceWorkerManagerFactory for ServiceWorkerManager {
fn create(sw_senders: SWManagerSenders, _origin: ImmutableOrigin) {
fn create(sw_senders: SWManagerSenders, origin: ImmutableOrigin) {
let (resource_chan, resource_port) = ipc::channel().unwrap();

let SWManagerSenders {
@@ -204,7 +204,7 @@ impl ServiceWorkerManagerFactory for ServiceWorkerManager {

let from_constellation = ROUTER.route_ipc_receiver_to_new_crossbeam_receiver(receiver);
let resource_port = ROUTER.route_ipc_receiver_to_new_crossbeam_receiver(resource_port);
let _ = resource_sender.send(CoreResourceMsg::NetworkMediator(resource_chan));
let _ = resource_sender.send(CoreResourceMsg::NetworkMediator(resource_chan, origin));
if thread::Builder::new()
.name("ServiceWorkerManager".to_owned())
.spawn(move || {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.