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

Side by Side Diff: content/child/service_worker/service_worker_dispatcher.cc

Issue 224733014: Introduce ServiceWorkerHandle for tracking WebServiceWorkerImpl reference (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 109
110 ServiceWorkerDispatcher* dispatcher = 110 ServiceWorkerDispatcher* dispatcher =
111 new ServiceWorkerDispatcher(thread_safe_sender); 111 new ServiceWorkerDispatcher(thread_safe_sender);
112 if (WorkerTaskRunner::Instance()->CurrentWorkerId()) 112 if (WorkerTaskRunner::Instance()->CurrentWorkerId())
113 WorkerTaskRunner::Instance()->AddStopObserver(dispatcher); 113 WorkerTaskRunner::Instance()->AddStopObserver(dispatcher);
114 return dispatcher; 114 return dispatcher;
115 } 115 }
116 116
117 void ServiceWorkerDispatcher::OnRegistered(int thread_id, 117 void ServiceWorkerDispatcher::OnRegistered(int thread_id,
118 int request_id, 118 int request_id,
119 int64 registration_id, 119 int handle_id,
120 int64 version_id) { 120 int64 version_id) {
121 WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks = 121 WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks =
122 pending_callbacks_.Lookup(request_id); 122 pending_callbacks_.Lookup(request_id);
123 DCHECK(callbacks); 123 DCHECK(callbacks);
124 if (!callbacks) 124 if (!callbacks)
125 return; 125 return;
126 126
127 // the browser has to generate the registration_id so the same 127 // the browser has to generate the registration_id so the same
128 // worker can be called from different renderer contexts. However, 128 // worker can be called from different renderer contexts. However,
129 // the impl object doesn't have to be the same instance across calls 129 // the impl object doesn't have to be the same instance across calls
130 // unless we require the DOM objects to be identical when there's a 130 // unless we require the DOM objects to be identical when there's a
131 // duplicate registration. So for now we mint a new object each 131 // duplicate registration. So for now we mint a new object each
132 // time. 132 // time.
133 scoped_ptr<WebServiceWorkerImpl> worker( 133 scoped_ptr<WebServiceWorkerImpl> worker(
134 new WebServiceWorkerImpl(registration_id, version_id, 134 new WebServiceWorkerImpl(handle_id, version_id,
michaeln 2014/04/08 01:21:41 in cases were the message doesn't get far and no W
kinuko 2014/04/08 08:43:31 Done.
135 thread_safe_sender_)); 135 thread_safe_sender_));
136 callbacks->onSuccess(worker.release()); 136 callbacks->onSuccess(worker.release());
137 pending_callbacks_.Remove(request_id); 137 pending_callbacks_.Remove(request_id);
138 } 138 }
139 139
140 void ServiceWorkerDispatcher::OnUnregistered( 140 void ServiceWorkerDispatcher::OnUnregistered(
141 int thread_id, 141 int thread_id,
142 int request_id) { 142 int request_id) {
143 WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks = 143 WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks =
144 pending_callbacks_.Lookup(request_id); 144 pending_callbacks_.Lookup(request_id);
(...skipping 18 matching lines...) Expand all
163 163
164 scoped_ptr<WebServiceWorkerError> error( 164 scoped_ptr<WebServiceWorkerError> error(
165 new WebServiceWorkerError(error_type, message)); 165 new WebServiceWorkerError(error_type, message));
166 callbacks->onError(error.release()); 166 callbacks->onError(error.release());
167 pending_callbacks_.Remove(request_id); 167 pending_callbacks_.Remove(request_id);
168 } 168 }
169 169
170 void ServiceWorkerDispatcher::OnWorkerRunLoopStopped() { delete this; } 170 void ServiceWorkerDispatcher::OnWorkerRunLoopStopped() { delete this; }
171 171
172 } // namespace content 172 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698