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

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

Issue 1454963003: ServiceWorker: Ensure that ServiceWorkerDispatcher always adopts passed handle references (1) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_provider_context.h" 5 #include "content/child/service_worker/service_worker_provider_context.h"
6 6
7 #include "base/thread_task_runner_handle.h" 7 #include "base/thread_task_runner_handle.h"
8 #include "content/child/child_thread_impl.h" 8 #include "content/child/child_thread_impl.h"
9 #include "content/child/service_worker/service_worker_dispatcher.h" 9 #include "content/child/service_worker/service_worker_dispatcher.h"
10 #include "content/child/service_worker/service_worker_handle_reference.h" 10 #include "content/child/service_worker/service_worker_handle_reference.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 ControllerDelegate() {} 85 ControllerDelegate() {}
86 ~ControllerDelegate() override {} 86 ~ControllerDelegate() override {}
87 87
88 void AssociateRegistration( 88 void AssociateRegistration(
89 scoped_ptr<ServiceWorkerRegistrationHandleReference> registration, 89 scoped_ptr<ServiceWorkerRegistrationHandleReference> registration,
90 scoped_ptr<ServiceWorkerHandleReference> installing, 90 scoped_ptr<ServiceWorkerHandleReference> installing,
91 scoped_ptr<ServiceWorkerHandleReference> waiting, 91 scoped_ptr<ServiceWorkerHandleReference> waiting,
92 scoped_ptr<ServiceWorkerHandleReference> active) override { 92 scoped_ptr<ServiceWorkerHandleReference> active) override {
93 DCHECK(!registration_); 93 DCHECK(!registration_);
94 registration_ = registration.Pass(); 94 registration_ = registration.Pass();
95 installing_ = active.Pass(); 95 installing_ = installing.Pass();
falken 2015/11/20 03:35:54 I thought this was in another patch.
nhiroki 2015/11/20 05:14:59 Right. I rebased this patch on that patch. (This p
96 waiting_ = waiting.Pass(); 96 waiting_ = waiting.Pass();
97 active_ = active.Pass(); 97 active_ = active.Pass();
98 } 98 }
99 99
100 void DisassociateRegistration() override { 100 void DisassociateRegistration() override {
101 // ServiceWorkerGlobalScope is never disassociated. 101 // ServiceWorkerGlobalScope is never disassociated.
102 NOTREACHED(); 102 NOTREACHED();
103 } 103 }
104 104
105 void SetController( 105 void SetController(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 ServiceWorkerProviderContext::~ServiceWorkerProviderContext() { 157 ServiceWorkerProviderContext::~ServiceWorkerProviderContext() {
158 if (ServiceWorkerDispatcher* dispatcher = 158 if (ServiceWorkerDispatcher* dispatcher =
159 ServiceWorkerDispatcher::GetThreadSpecificInstance()) { 159 ServiceWorkerDispatcher::GetThreadSpecificInstance()) {
160 // Remove this context from the dispatcher living on the main thread. 160 // Remove this context from the dispatcher living on the main thread.
161 dispatcher->RemoveProviderContext(this); 161 dispatcher->RemoveProviderContext(this);
162 } 162 }
163 } 163 }
164 164
165 void ServiceWorkerProviderContext::OnAssociateRegistration( 165 void ServiceWorkerProviderContext::OnAssociateRegistration(
166 const ServiceWorkerRegistrationObjectInfo& info, 166 scoped_ptr<ServiceWorkerRegistrationHandleReference> registration,
167 const ServiceWorkerVersionAttributes& attrs) { 167 scoped_ptr<ServiceWorkerHandleReference> installing,
168 scoped_ptr<ServiceWorkerHandleReference> waiting,
169 scoped_ptr<ServiceWorkerHandleReference> active) {
168 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); 170 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread());
169 delegate_->AssociateRegistration( 171 delegate_->AssociateRegistration(registration.Pass(), installing.Pass(),
170 ServiceWorkerRegistrationHandleReference::Adopt( 172 waiting.Pass(), active.Pass());
171 info, thread_safe_sender_.get()),
172 ServiceWorkerHandleReference::Adopt(attrs.installing,
173 thread_safe_sender_.get()),
174 ServiceWorkerHandleReference::Adopt(attrs.waiting,
175 thread_safe_sender_.get()),
176 ServiceWorkerHandleReference::Adopt(attrs.active,
177 thread_safe_sender_.get()));
178 } 173 }
179 174
180 void ServiceWorkerProviderContext::OnDisassociateRegistration() { 175 void ServiceWorkerProviderContext::OnDisassociateRegistration() {
181 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); 176 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread());
182 delegate_->DisassociateRegistration(); 177 delegate_->DisassociateRegistration();
183 } 178 }
184 179
185 void ServiceWorkerProviderContext::OnSetControllerServiceWorker( 180 void ServiceWorkerProviderContext::OnSetControllerServiceWorker(
186 scoped_ptr<ServiceWorkerHandleReference> controller) { 181 scoped_ptr<ServiceWorkerHandleReference> controller) {
187 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); 182 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread());
(...skipping 14 matching lines...) Expand all
202 197
203 void ServiceWorkerProviderContext::DestructOnMainThread() const { 198 void ServiceWorkerProviderContext::DestructOnMainThread() const {
204 if (!main_thread_task_runner_->RunsTasksOnCurrentThread() && 199 if (!main_thread_task_runner_->RunsTasksOnCurrentThread() &&
205 main_thread_task_runner_->DeleteSoon(FROM_HERE, this)) { 200 main_thread_task_runner_->DeleteSoon(FROM_HERE, this)) {
206 return; 201 return;
207 } 202 }
208 delete this; 203 delete this;
209 } 204 }
210 205
211 } // namespace content 206 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698