Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1305)

Unified Diff: content/child/service_worker/service_worker_dispatcher.cc

Issue 182863004: Wire provider_id into scriptable API provider to start listening events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/child/service_worker/service_worker_dispatcher.cc
diff --git a/content/child/service_worker/service_worker_dispatcher.cc b/content/child/service_worker/service_worker_dispatcher.cc
index b9da048c199071bdf1ae92aac9ba74b5bd824860..c888df4740ba35fc274c1fee61f3aaf6676646c3 100644
--- a/content/child/service_worker/service_worker_dispatcher.cc
+++ b/content/child/service_worker/service_worker_dispatcher.cc
@@ -33,7 +33,8 @@ int CurrentWorkerId() {
ServiceWorkerDispatcher::ServiceWorkerDispatcher(
ThreadSafeSender* thread_safe_sender)
- : thread_safe_sender_(thread_safe_sender) {
+ : thread_safe_sender_(thread_safe_sender),
+ client_(NULL) {
michaeln 2014/03/07 02:24:09 ditto stale
kinuko 2014/03/07 02:37:13 Done.
g_dispatcher_tls.Pointer()->Set(this);
}
@@ -77,6 +78,25 @@ void ServiceWorkerDispatcher::UnregisterServiceWorker(
CurrentWorkerId(), request_id, pattern));
}
+void ServiceWorkerDispatcher::AddScriptClient(
+ int provider_id,
+ blink::WebServiceWorkerProviderClient* client) {
+ DCHECK(client);
+ DCHECK(!ContainsKey(script_clients_, provider_id));
+ script_clients_[provider_id] = client;
+ thread_safe_sender_->Send(new ServiceWorkerHostMsg_AddScriptClient(
+ CurrentWorkerId(), provider_id));
+}
+
+void ServiceWorkerDispatcher::RemoveScriptClient(int provider_id) {
+ // This could be possibly called multiple times to ensure termination.
+ if (ContainsKey(script_clients_, provider_id)) {
+ script_clients_.erase(provider_id);
+ thread_safe_sender_->Send(new ServiceWorkerHostMsg_RemoveScriptClient(
+ CurrentWorkerId(), provider_id));
+ }
+}
+
ServiceWorkerDispatcher* ServiceWorkerDispatcher::ThreadSpecificInstance(
ThreadSafeSender* thread_safe_sender) {
if (g_dispatcher_tls.Pointer()->Get() == kHasBeenDeleted) {

Powered by Google App Engine
This is Rietveld 408576698