mirror of
https://github.com/servo/servo.git
synced 2025-07-23 23:33:43 +01:00
Initial work on job queues for service workers
This commit is contained in:
parent
6cc1976cca
commit
114c491111
11 changed files with 462 additions and 68 deletions
|
@ -4,20 +4,20 @@
|
|||
|
||||
use dom::bindings::codegen::Bindings::ClientBinding::{ClientMethods, Wrap};
|
||||
use dom::bindings::codegen::Bindings::ClientBinding::FrameType;
|
||||
use dom::bindings::js::JS;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::js::{JS, Root, MutNullableHeap};
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use dom::bindings::str::{DOMString, USVString};
|
||||
use dom::serviceworker::ServiceWorker;
|
||||
use dom::window::Window;
|
||||
use servo_url::ServoUrl;
|
||||
use std::default::Default;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct Client {
|
||||
reflector_: Reflector,
|
||||
active_worker: Option<JS<ServiceWorker>>,
|
||||
url: USVString,
|
||||
active_worker: MutNullableHeap<JS<ServiceWorker>>,
|
||||
url: ServoUrl,
|
||||
frame_type: FrameType,
|
||||
#[ignore_heap_size_of = "Defined in uuid"]
|
||||
id: Uuid
|
||||
|
@ -27,8 +27,8 @@ impl Client {
|
|||
fn new_inherited(url: ServoUrl) -> Client {
|
||||
Client {
|
||||
reflector_: Reflector::new(),
|
||||
active_worker: None,
|
||||
url: USVString(url.as_str().to_owned()),
|
||||
active_worker: Default::default(),
|
||||
url: url,
|
||||
frame_type: FrameType::None,
|
||||
id: Uuid::new_v4()
|
||||
}
|
||||
|
@ -39,12 +39,24 @@ impl Client {
|
|||
window,
|
||||
Wrap)
|
||||
}
|
||||
|
||||
pub fn creation_url(&self) -> ServoUrl {
|
||||
self.url.clone()
|
||||
}
|
||||
|
||||
pub fn get_controller(&self) -> Option<Root<ServiceWorker>> {
|
||||
self.active_worker.get()
|
||||
}
|
||||
|
||||
pub fn set_controller(&self, worker: &ServiceWorker) {
|
||||
self.active_worker.set(Some(worker));
|
||||
}
|
||||
}
|
||||
|
||||
impl ClientMethods for Client {
|
||||
// https://w3c.github.io/ServiceWorker/#client-url-attribute
|
||||
fn Url(&self) -> USVString {
|
||||
self.url.clone()
|
||||
USVString(self.url.as_str().to_owned())
|
||||
}
|
||||
|
||||
// https://w3c.github.io/ServiceWorker/#client-frametype
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue