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

Side by Side 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: nit fix 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/child/service_worker/service_worker_dispatcher.h" 5 #include "content/child/service_worker/service_worker_dispatcher.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/threading/thread_local.h" 8 #include "base/threading/thread_local.h"
9 #include "content/child/service_worker/web_service_worker_impl.h" 9 #include "content/child/service_worker/web_service_worker_impl.h"
10 #include "content/child/thread_safe_sender.h" 10 #include "content/child/thread_safe_sender.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 void ServiceWorkerDispatcher::UnregisterServiceWorker( 71 void ServiceWorkerDispatcher::UnregisterServiceWorker(
72 const GURL& pattern, 72 const GURL& pattern,
73 WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks) { 73 WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks) {
74 DCHECK(callbacks); 74 DCHECK(callbacks);
75 int request_id = pending_callbacks_.Add(callbacks); 75 int request_id = pending_callbacks_.Add(callbacks);
76 thread_safe_sender_->Send(new ServiceWorkerHostMsg_UnregisterServiceWorker( 76 thread_safe_sender_->Send(new ServiceWorkerHostMsg_UnregisterServiceWorker(
77 CurrentWorkerId(), request_id, pattern)); 77 CurrentWorkerId(), request_id, pattern));
78 } 78 }
79 79
80 void ServiceWorkerDispatcher::AddScriptClient(
81 int provider_id,
82 blink::WebServiceWorkerProviderClient* client) {
83 DCHECK(client);
84 DCHECK(!ContainsKey(script_clients_, provider_id));
85 script_clients_[provider_id] = client;
86 thread_safe_sender_->Send(new ServiceWorkerHostMsg_AddScriptClient(
87 CurrentWorkerId(), provider_id));
88 }
89
90 void ServiceWorkerDispatcher::RemoveScriptClient(int provider_id) {
91 // This could be possibly called multiple times to ensure termination.
92 if (ContainsKey(script_clients_, provider_id)) {
93 script_clients_.erase(provider_id);
94 thread_safe_sender_->Send(new ServiceWorkerHostMsg_RemoveScriptClient(
95 CurrentWorkerId(), provider_id));
96 }
97 }
98
80 ServiceWorkerDispatcher* ServiceWorkerDispatcher::ThreadSpecificInstance( 99 ServiceWorkerDispatcher* ServiceWorkerDispatcher::ThreadSpecificInstance(
81 ThreadSafeSender* thread_safe_sender) { 100 ThreadSafeSender* thread_safe_sender) {
82 if (g_dispatcher_tls.Pointer()->Get() == kHasBeenDeleted) { 101 if (g_dispatcher_tls.Pointer()->Get() == kHasBeenDeleted) {
83 NOTREACHED() << "Re-instantiating TLS ServiceWorkerDispatcher."; 102 NOTREACHED() << "Re-instantiating TLS ServiceWorkerDispatcher.";
84 g_dispatcher_tls.Pointer()->Set(NULL); 103 g_dispatcher_tls.Pointer()->Set(NULL);
85 } 104 }
86 if (g_dispatcher_tls.Pointer()->Get()) 105 if (g_dispatcher_tls.Pointer()->Get())
87 return g_dispatcher_tls.Pointer()->Get(); 106 return g_dispatcher_tls.Pointer()->Get();
88 107
89 ServiceWorkerDispatcher* dispatcher = 108 ServiceWorkerDispatcher* dispatcher =
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 159
141 scoped_ptr<WebServiceWorkerError> error( 160 scoped_ptr<WebServiceWorkerError> error(
142 new WebServiceWorkerError(error_type, message)); 161 new WebServiceWorkerError(error_type, message));
143 callbacks->onError(error.release()); 162 callbacks->onError(error.release());
144 pending_callbacks_.Remove(request_id); 163 pending_callbacks_.Remove(request_id);
145 } 164 }
146 165
147 void ServiceWorkerDispatcher::OnWorkerRunLoopStopped() { delete this; } 166 void ServiceWorkerDispatcher::OnWorkerRunLoopStopped() { delete this; }
148 167
149 } // namespace content 168 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698