mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
allow for a service worker network mediator per origin
This commit is contained in:
parent
db217d5575
commit
1e017a7082
4 changed files with 12 additions and 24 deletions
|
@ -16,13 +16,6 @@ mod constellation;
|
||||||
mod event_loop;
|
mod event_loop;
|
||||||
mod network_listener;
|
mod network_listener;
|
||||||
mod pipeline;
|
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 sandboxing;
|
||||||
mod serviceworker;
|
mod serviceworker;
|
||||||
mod session_history;
|
mod session_history;
|
||||||
|
@ -32,11 +25,4 @@ pub use crate::constellation::{
|
||||||
Constellation, FromCompositorLogger, FromScriptLogger, InitialConstellationState,
|
Constellation, FromCompositorLogger, FromScriptLogger, InitialConstellationState,
|
||||||
};
|
};
|
||||||
pub use crate::pipeline::UnprivilegedPipelineContent;
|
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};
|
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 profile_traits::time::ProfilerChan;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use servo_arc::Arc as ServoArc;
|
use servo_arc::Arc as ServoArc;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::{ImmutableOrigin, ServoUrl};
|
||||||
use std::borrow::{Cow, ToOwned};
|
use std::borrow::{Cow, ToOwned};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
|
@ -299,8 +299,10 @@ impl ResourceChannelManager {
|
||||||
.send(cookie_jar.cookies_for_url(&url, source))
|
.send(cookie_jar.cookies_for_url(&url, source))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
},
|
},
|
||||||
CoreResourceMsg::NetworkMediator(mediator_chan) => {
|
CoreResourceMsg::NetworkMediator(mediator_chan, origin) => {
|
||||||
self.resource_manager.swmanager_chan = Some(mediator_chan)
|
self.resource_manager
|
||||||
|
.sw_managers
|
||||||
|
.insert(origin, mediator_chan);
|
||||||
},
|
},
|
||||||
CoreResourceMsg::GetCookiesDataForUrl(url, consumer, source) => {
|
CoreResourceMsg::GetCookiesDataForUrl(url, consumer, source) => {
|
||||||
let mut cookie_jar = http_state.cookie_jar.write().unwrap();
|
let mut cookie_jar = http_state.cookie_jar.write().unwrap();
|
||||||
|
@ -431,7 +433,7 @@ pub struct AuthCache {
|
||||||
pub struct CoreResourceManager {
|
pub struct CoreResourceManager {
|
||||||
user_agent: Cow<'static, str>,
|
user_agent: Cow<'static, str>,
|
||||||
devtools_chan: Option<Sender<DevtoolsControlMsg>>,
|
devtools_chan: Option<Sender<DevtoolsControlMsg>>,
|
||||||
swmanager_chan: Option<IpcSender<CustomResponseMediator>>,
|
sw_managers: HashMap<ImmutableOrigin, IpcSender<CustomResponseMediator>>,
|
||||||
filemanager: FileManager,
|
filemanager: FileManager,
|
||||||
thread_pool: Arc<CoreResourceThreadPool>,
|
thread_pool: Arc<CoreResourceThreadPool>,
|
||||||
certificate_path: Option<String>,
|
certificate_path: Option<String>,
|
||||||
|
@ -575,7 +577,7 @@ impl CoreResourceManager {
|
||||||
CoreResourceManager {
|
CoreResourceManager {
|
||||||
user_agent: user_agent,
|
user_agent: user_agent,
|
||||||
devtools_chan: devtools_channel,
|
devtools_chan: devtools_channel,
|
||||||
swmanager_chan: None,
|
sw_managers: Default::default(),
|
||||||
filemanager: FileManager::new(embedder_proxy, Arc::downgrade(&pool_handle)),
|
filemanager: FileManager::new(embedder_proxy, Arc::downgrade(&pool_handle)),
|
||||||
thread_pool: pool_handle,
|
thread_pool: pool_handle,
|
||||||
certificate_path,
|
certificate_path,
|
||||||
|
|
|
@ -30,7 +30,7 @@ use ipc_channel::router::ROUTER;
|
||||||
use ipc_channel::Error as IpcError;
|
use ipc_channel::Error as IpcError;
|
||||||
use mime::Mime;
|
use mime::Mime;
|
||||||
use msg::constellation_msg::HistoryStateId;
|
use msg::constellation_msg::HistoryStateId;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::{ImmutableOrigin, ServoUrl};
|
||||||
use time::precise_time_ns;
|
use time::precise_time_ns;
|
||||||
use webrender_api::ImageKey;
|
use webrender_api::ImageKey;
|
||||||
|
|
||||||
|
@ -423,8 +423,8 @@ pub enum CoreResourceMsg {
|
||||||
RemoveHistoryStates(Vec<HistoryStateId>),
|
RemoveHistoryStates(Vec<HistoryStateId>),
|
||||||
/// Synchronization message solely for knowing the state of the ResourceChannelManager loop
|
/// Synchronization message solely for knowing the state of the ResourceChannelManager loop
|
||||||
Synchronize(IpcSender<()>),
|
Synchronize(IpcSender<()>),
|
||||||
/// Send the network sender in constellation to CoreResourceThread
|
/// Send the service worker network mediator for an origin to CoreResourceThread
|
||||||
NetworkMediator(IpcSender<CustomResponseMediator>),
|
NetworkMediator(IpcSender<CustomResponseMediator>, ImmutableOrigin),
|
||||||
/// Message forwarded to file manager's handler
|
/// Message forwarded to file manager's handler
|
||||||
ToFileManager(FileManagerThreadMsg),
|
ToFileManager(FileManagerThreadMsg),
|
||||||
/// Break the load handler loop, send a reply when done cleaning up local resources
|
/// Break the load handler loop, send a reply when done cleaning up local resources
|
||||||
|
|
|
@ -192,7 +192,7 @@ impl ServiceWorkerManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ServiceWorkerManagerFactory for 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 (resource_chan, resource_port) = ipc::channel().unwrap();
|
||||||
|
|
||||||
let SWManagerSenders {
|
let SWManagerSenders {
|
||||||
|
@ -204,7 +204,7 @@ impl ServiceWorkerManagerFactory for ServiceWorkerManager {
|
||||||
|
|
||||||
let from_constellation = ROUTER.route_ipc_receiver_to_new_crossbeam_receiver(receiver);
|
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_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()
|
if thread::Builder::new()
|
||||||
.name("ServiceWorkerManager".to_owned())
|
.name("ServiceWorkerManager".to_owned())
|
||||||
.spawn(move || {
|
.spawn(move || {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue