mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Integrate service worker manager thread
This commit is contained in:
parent
e8fa02a07f
commit
1e6293ea1d
39 changed files with 764 additions and 582 deletions
|
@ -36,7 +36,7 @@ mod script_msg;
|
|||
pub mod webdriver_msg;
|
||||
|
||||
use app_units::Au;
|
||||
use devtools_traits::ScriptToDevtoolsControlMsg;
|
||||
use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, WorkerId};
|
||||
use euclid::Size2D;
|
||||
use euclid::length::Length;
|
||||
use euclid::point::Point2D;
|
||||
|
@ -51,13 +51,14 @@ use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
|||
use layers::geometry::DevicePixel;
|
||||
use libc::c_void;
|
||||
use msg::constellation_msg::{FrameId, FrameType, Image, Key, KeyModifiers, KeyState, LoadData};
|
||||
use msg::constellation_msg::{NavigationDirection, PanicMsg, PipelineId};
|
||||
use msg::constellation_msg::{NavigationDirection, PanicMsg, PipelineId, ReferrerPolicy};
|
||||
use msg::constellation_msg::{PipelineNamespaceId, SubpageId, WindowSizeType};
|
||||
use net_traits::ResourceThreads;
|
||||
use net_traits::bluetooth_thread::BluetoothMethodMsg;
|
||||
use net_traits::image_cache_thread::ImageCacheThread;
|
||||
use net_traits::response::HttpsState;
|
||||
use net_traits::{LoadOrigin, ResourceThreads};
|
||||
use profile_traits::mem;
|
||||
use profile_traits::time as profile_time;
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::mpsc::{Sender, Receiver};
|
||||
|
@ -67,6 +68,7 @@ use util::ipc::OptionalOpaqueIpcSender;
|
|||
use webdriver_msg::{LoadStatus, WebDriverScriptCommand};
|
||||
|
||||
pub use script_msg::{LayoutMsg, ScriptMsg, EventResult, LogEntry};
|
||||
pub use script_msg::{ServiceWorkerMsg, ScopeThings, SWManagerMsg};
|
||||
|
||||
/// The address of a node. Layout sends these back. They must be validated via
|
||||
/// `from_untrusted_node_address` before they can be used, because we do not trust layout.
|
||||
|
@ -603,3 +605,49 @@ pub enum ConstellationMsg {
|
|||
/// A log entry, with the pipeline id and thread name
|
||||
LogEntry(Option<PipelineId>, Option<String>, LogEntry),
|
||||
}
|
||||
|
||||
/// Resources required by workerglobalscopes
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct WorkerGlobalScopeInit {
|
||||
/// Chan to a resource thread
|
||||
pub resource_threads: ResourceThreads,
|
||||
/// Chan to the memory profiler
|
||||
pub mem_profiler_chan: mem::ProfilerChan,
|
||||
/// Chan to the time profiler
|
||||
pub time_profiler_chan: profile_time::ProfilerChan,
|
||||
/// To devtools sender
|
||||
pub to_devtools_sender: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
||||
/// From devtools sender
|
||||
pub from_devtools_sender: Option<IpcSender<DevtoolScriptControlMsg>>,
|
||||
/// Messages to send to constellation
|
||||
pub constellation_chan: IpcSender<ScriptMsg>,
|
||||
/// Message to send to the scheduler
|
||||
pub scheduler_chan: IpcSender<TimerEventRequest>,
|
||||
/// Sender which sends panic messages
|
||||
pub panic_chan: IpcSender<PanicMsg>,
|
||||
/// The worker id
|
||||
pub worker_id: WorkerId,
|
||||
}
|
||||
|
||||
/// Common entities representing a network load origin
|
||||
#[derive(Deserialize, Serialize, Clone)]
|
||||
pub struct WorkerScriptLoadOrigin {
|
||||
/// referrer url
|
||||
pub referrer_url: Option<Url>,
|
||||
/// the referrer policy which is used
|
||||
pub referrer_policy: Option<ReferrerPolicy>,
|
||||
/// the pipeline id of the entity requesting the load
|
||||
pub pipeline_id: Option<PipelineId>
|
||||
}
|
||||
|
||||
impl LoadOrigin for WorkerScriptLoadOrigin {
|
||||
fn referrer_url(&self) -> Option<Url> {
|
||||
self.referrer_url.clone()
|
||||
}
|
||||
fn referrer_policy(&self) -> Option<ReferrerPolicy> {
|
||||
self.referrer_policy.clone()
|
||||
}
|
||||
fn pipeline_id(&self) -> Option<PipelineId> {
|
||||
self.pipeline_id.clone()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,13 +8,17 @@ use IFrameLoadInfo;
|
|||
use MouseButton;
|
||||
use MouseEventType;
|
||||
use MozBrowserEvent;
|
||||
use WorkerGlobalScopeInit;
|
||||
use WorkerScriptLoadOrigin;
|
||||
use canvas_traits::CanvasMsg;
|
||||
use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId};
|
||||
use euclid::point::Point2D;
|
||||
use euclid::size::Size2D;
|
||||
use gfx_traits::LayerId;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData};
|
||||
use msg::constellation_msg::{NavigationDirection, PipelineId, SubpageId};
|
||||
use net_traits::CustomResponseMediator;
|
||||
use offscreen_gl_context::{GLContextAttributes, GLLimits};
|
||||
use style_traits::cursor::Cursor;
|
||||
use style_traits::viewport::ViewportConstraints;
|
||||
|
@ -106,6 +110,8 @@ pub enum ScriptMsg {
|
|||
ActivateDocument(PipelineId),
|
||||
/// Set the document state for a pipeline (used by screenshot / reftests)
|
||||
SetDocumentState(PipelineId, DocumentState),
|
||||
/// Message from network to constellation
|
||||
NetworkRequest(CustomResponseMediator),
|
||||
/// Update the pipeline Url, which can change after redirections.
|
||||
SetFinalUrl(PipelineId, Url),
|
||||
/// Check if an alert dialog box should be presented
|
||||
|
@ -131,6 +137,45 @@ pub enum ScriptMsg {
|
|||
LogEntry(Option<PipelineId>, Option<String>, LogEntry),
|
||||
/// Notifies the constellation that this pipeline has exited.
|
||||
PipelineExited(PipelineId),
|
||||
/// Store the data required to activate a service worker for the given scope
|
||||
RegisterServiceWorker(ScopeThings, Url),
|
||||
/// Requests that the compositor shut down.
|
||||
Exit
|
||||
}
|
||||
|
||||
/// Entities required to spawn service workers
|
||||
#[derive(Deserialize, Serialize, Clone)]
|
||||
pub struct ScopeThings {
|
||||
/// script resource url
|
||||
pub script_url: Url,
|
||||
/// pipeline which requested the activation
|
||||
pub pipeline_id: PipelineId,
|
||||
/// network load origin of the resource
|
||||
pub worker_load_origin: WorkerScriptLoadOrigin,
|
||||
/// base resources required to create worker global scopes
|
||||
pub init: WorkerGlobalScopeInit,
|
||||
/// the port to receive devtools message from
|
||||
pub devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
||||
/// service worker id
|
||||
pub worker_id: WorkerId,
|
||||
}
|
||||
|
||||
/// Messages sent to Service Worker Manager thread
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum ServiceWorkerMsg {
|
||||
/// Message to register the service worker
|
||||
RegisterServiceWorker(ScopeThings, Url),
|
||||
/// Message to activate the worker
|
||||
ActivateWorker(CustomResponseMediator),
|
||||
/// Timeout message sent by active service workers
|
||||
Timeout(Url),
|
||||
/// Exit the service worker manager
|
||||
Exit,
|
||||
}
|
||||
|
||||
/// Messages outgoing from the Service Worker Manager thread
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum SWManagerMsg {
|
||||
/// Provide the constellation with a means of communicating with the Service Worker Manager
|
||||
OwnSender(IpcSender<ServiceWorkerMsg>),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue