aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGregory Terzian <gterzian@users.noreply.github.com>2020-04-04 13:19:43 +0800
committerGregory Terzian <gterzian@users.noreply.github.com>2020-04-05 22:43:37 +0800
commit1e017a7082e7649a4d2d2f2b8b8d1a1a23c7fb84 (patch)
tree5a795fc0dd5e94ae089e10188f309198735c5b32
parentdb217d557513030836898f840206d5ac9ed87b79 (diff)
downloadservo-1e017a7082e7649a4d2d2f2b8b8d1a1a23c7fb84.tar.gz
servo-1e017a7082e7649a4d2d2f2b8b8d1a1a23c7fb84.zip
allow for a service worker network mediator per origin
-rw-r--r--components/constellation/lib.rs14
-rw-r--r--components/net/resource_thread.rs12
-rw-r--r--components/net_traits/lib.rs6
-rw-r--r--components/script/serviceworker_manager.rs4
4 files changed, 12 insertions, 24 deletions
diff --git a/components/constellation/lib.rs b/components/constellation/lib.rs
index 0e28b880cce..92495c50cd9 100644
--- a/components/constellation/lib.rs
+++ b/components/constellation/lib.rs
@@ -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};
diff --git a/components/net/resource_thread.rs b/components/net/resource_thread.rs
index 79f84b65971..388cacc77af 100644
--- a/components/net/resource_thread.rs
+++ b/components/net/resource_thread.rs
@@ -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,
diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs
index f7b291e420f..2de544c31fe 100644
--- a/components/net_traits/lib.rs
+++ b/components/net_traits/lib.rs
@@ -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
diff --git a/components/script/serviceworker_manager.rs b/components/script/serviceworker_manager.rs
index 66d4d995d32..83bf1dbf312 100644
--- a/components/script/serviceworker_manager.rs
+++ b/components/script/serviceworker_manager.rs
@@ -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 || {