mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Introduce service-worker mode
This commit is contained in:
parent
6342a4b455
commit
6adc653083
6 changed files with 85 additions and 71 deletions
|
@ -97,6 +97,14 @@ pub enum CacheMode {
|
|||
OnlyIfCached,
|
||||
}
|
||||
|
||||
/// [Service-workers mode](https://fetch.spec.whatwg.org/#request-service-workers-mode)
|
||||
#[derive(Copy, Clone, PartialEq, Serialize, Deserialize, HeapSizeOf)]
|
||||
pub enum ServiceWorkersMode {
|
||||
All,
|
||||
Foreign,
|
||||
None,
|
||||
}
|
||||
|
||||
/// [Redirect mode](https://fetch.spec.whatwg.org/#concept-request-redirect-mode)
|
||||
#[derive(Copy, Clone, PartialEq, Serialize, Deserialize, HeapSizeOf)]
|
||||
pub enum RedirectMode {
|
||||
|
@ -140,6 +148,7 @@ pub struct RequestInit {
|
|||
pub headers: Headers,
|
||||
pub unsafe_request: bool,
|
||||
pub body: Option<Vec<u8>>,
|
||||
pub service_workers_mode: ServiceWorkersMode,
|
||||
// TODO: client object
|
||||
pub type_: Type,
|
||||
pub destination: Destination,
|
||||
|
@ -170,6 +179,7 @@ impl Default for RequestInit {
|
|||
headers: Headers::new(),
|
||||
unsafe_request: false,
|
||||
body: None,
|
||||
service_workers_mode: ServiceWorkersMode::All,
|
||||
type_: Type::None,
|
||||
destination: Destination::None,
|
||||
synchronous: false,
|
||||
|
@ -208,12 +218,12 @@ pub struct Request {
|
|||
/// https://fetch.spec.whatwg.org/#concept-request-body
|
||||
pub body: Option<Vec<u8>>,
|
||||
// TODO: client object
|
||||
pub is_service_worker_global_scope: bool,
|
||||
pub window: Window,
|
||||
// TODO: target browsing context
|
||||
/// https://fetch.spec.whatwg.org/#request-keepalive-flag
|
||||
pub keep_alive: bool,
|
||||
pub skip_service_worker: bool,
|
||||
// https://fetch.spec.whatwg.org/#request-service-workers-mode
|
||||
pub service_workers_mode: ServiceWorkersMode,
|
||||
/// https://fetch.spec.whatwg.org/#concept-request-initiator
|
||||
pub initiator: Initiator,
|
||||
/// https://fetch.spec.whatwg.org/#concept-request-type
|
||||
|
@ -257,7 +267,6 @@ pub struct Request {
|
|||
impl Request {
|
||||
pub fn new(url: ServoUrl,
|
||||
origin: Option<Origin>,
|
||||
is_service_worker_global_scope: bool,
|
||||
pipeline_id: Option<PipelineId>)
|
||||
-> Request {
|
||||
Request {
|
||||
|
@ -267,10 +276,9 @@ impl Request {
|
|||
headers: Headers::new(),
|
||||
unsafe_request: false,
|
||||
body: None,
|
||||
is_service_worker_global_scope: is_service_worker_global_scope,
|
||||
window: Window::Client,
|
||||
keep_alive: false,
|
||||
skip_service_worker: false,
|
||||
service_workers_mode: ServiceWorkersMode::All,
|
||||
initiator: Initiator::None,
|
||||
type_: Type::None,
|
||||
destination: Destination::None,
|
||||
|
@ -295,12 +303,12 @@ impl Request {
|
|||
pub fn from_init(init: RequestInit) -> Request {
|
||||
let mut req = Request::new(init.url.clone(),
|
||||
Some(Origin::Origin(init.origin.origin())),
|
||||
false,
|
||||
init.pipeline_id);
|
||||
req.method = init.method;
|
||||
req.headers = init.headers;
|
||||
req.unsafe_request = init.unsafe_request;
|
||||
req.body = init.body;
|
||||
req.service_workers_mode = init.service_workers_mode;
|
||||
req.type_ = init.type_;
|
||||
req.destination = init.destination;
|
||||
req.synchronous = init.synchronous;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue