aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_thread.rs
diff options
context:
space:
mode:
authorRahul Sharma <rsconceptx@gmail.com>2016-07-28 23:34:44 +0530
committerRahul Sharma <rsconceptx@gmail.com>2016-09-07 12:07:36 +0530
commit0996b38ade7e2fe368ad7bd21ba8cf9a48d8f866 (patch)
tree8ac690564d216b672e1da26404e8c6d5585dcbc3 /components/script/script_thread.rs
parent72279cc7eb044a760ce461d76da2ff62adc511dc (diff)
downloadservo-0996b38ade7e2fe368ad7bd21ba8cf9a48d8f866.tar.gz
servo-0996b38ade7e2fe368ad7bd21ba8cf9a48d8f866.zip
Make service workers talk to their serviceworkerglobalscopes
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r--components/script/script_thread.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index ac6165d5c4f..fb5abc005d8 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -42,7 +42,7 @@ use dom::element::Element;
use dom::event::{Event, EventBubbles, EventCancelable};
use dom::htmlanchorelement::HTMLAnchorElement;
use dom::node::{Node, NodeDamage, window_from_node};
-use dom::serviceworker::TrustedServiceWorkerAddress;
+use dom::serviceworker::{TrustedServiceWorkerAddress, ServiceWorker};
use dom::serviceworkerregistration::ServiceWorkerRegistration;
use dom::servohtmlparser::ParserContext;
use dom::uievent::UIEvent;
@@ -84,7 +84,7 @@ use script_traits::CompositorEvent::{TouchEvent, TouchpadPressureEvent};
use script_traits::webdriver_msg::WebDriverScriptCommand;
use script_traits::{CompositorEvent, ConstellationControlMsg, EventResult};
use script_traits::{InitialScriptState, MouseButton, MouseEventType, MozBrowserEvent};
-use script_traits::{NewLayoutInfo, ScriptMsg as ConstellationMsg};
+use script_traits::{NewLayoutInfo, ScriptMsg as ConstellationMsg, DOMMessage};
use script_traits::{ScriptThreadFactory, TimerEvent, TimerEventRequest, TimerSource};
use script_traits::{TouchEventType, TouchId, UntrustedNodeAddress, WindowSizeData};
use std::borrow::ToOwned;
@@ -924,6 +924,8 @@ impl ScriptThread {
self.handle_css_error_reporting(pipeline_id, filename, line, column, msg),
ConstellationControlMsg::Reload(pipeline_id) =>
self.handle_reload(pipeline_id),
+ ConstellationControlMsg::ConnectServiceWorker(scope_url, chan) =>
+ self.connect_serviceworker_to_scope(scope_url, chan),
msg @ ConstellationControlMsg::AttachLayout(..) |
msg @ ConstellationControlMsg::Viewport(..) |
msg @ ConstellationControlMsg::SetScrollState(..) |
@@ -1456,7 +1458,16 @@ impl ScriptThread {
let scope_things = ServiceWorkerRegistration::create_scope_things(global_ref, script_url);
let _ = self.constellation_chan.send(ConstellationMsg::RegisterServiceWorker(scope_things, scope));
} else {
- warn!("Registration failed for {}", pipeline_id);
+ warn!("Registration failed for {}", scope);
+ }
+ }
+
+ // Set the sender to the corresponding scope of the service worker object.
+ fn connect_serviceworker_to_scope(&self, scope_url: Url, chan: IpcSender<DOMMessage>) {
+ let ref maybe_registration_ref = *self.registration_map.borrow();
+ if let Some(ref registration) = maybe_registration_ref.get(&scope_url) {
+ let trusted_worker = registration.get_trusted_worker();
+ ServiceWorker::store_sender(trusted_worker, chan);
}
}