allow for a service worker manager per origin

This commit is contained in:
Gregory Terzian 2020-04-01 23:33:27 +08:00
parent 9972aee81f
commit db217d5575
11 changed files with 405 additions and 245 deletions

View file

@ -706,6 +706,13 @@ pub trait ScriptThreadFactory {
) -> (Sender<Self::Message>, Receiver<Self::Message>);
}
/// This trait allows creating a `ServiceWorkerManager` without depending on the `script`
/// crate.
pub trait ServiceWorkerManagerFactory {
/// Create a `ServiceWorkerManager`.
fn create(sw_senders: SWManagerSenders, origin: ImmutableOrigin);
}
/// Whether the sandbox attribute is present for an iframe element
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub enum IFrameSandboxState {

View file

@ -370,11 +370,16 @@ pub struct DOMMessage {
}
/// Channels to allow service worker manager to communicate with constellation and resource thread
#[derive(Deserialize, Serialize)]
pub struct SWManagerSenders {
/// sender for communicating with constellation
/// Sender of messages to the constellation.
pub swmanager_sender: IpcSender<SWManagerMsg>,
/// sender for communicating with resource thread
/// Sender for communicating with resource thread.
pub resource_sender: IpcSender<CoreResourceMsg>,
/// Sender of messages to the manager.
pub own_sender: IpcSender<ServiceWorkerMsg>,
/// Receiver of messages from the constellation.
pub receiver: IpcReceiver<ServiceWorkerMsg>,
}
/// Messages sent to Service Worker Manager thread
@ -393,6 +398,8 @@ pub enum ServiceWorkerMsg {
/// Messages outgoing from the Service Worker Manager thread to constellation
#[derive(Debug, Deserialize, Serialize)]
pub enum SWManagerMsg {
/// Provide the constellation with a means of communicating with the Service Worker Manager
OwnSender(IpcSender<ServiceWorkerMsg>),
/// Placeholder to keep the enum,
/// as it will be needed when implementing
/// https://github.com/servo/servo/issues/24660
PostMessageToClient,
}