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

Side by Side Diff: Source/modules/serviceworkers/ServiceWorkerContainer.cpp

Issue 669423002: Only dispose proxy-less WebServiceWorkerRegistration objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « no previous file | Source/modules/serviceworkers/ServiceWorkerRegistration.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 // If the WebServiceWorker is up for adoption (does not have a 201 // If the WebServiceWorker is up for adoption (does not have a
202 // WebServiceWorkerProxy owner), rejects the adoption by deleting the 202 // WebServiceWorkerProxy owner), rejects the adoption by deleting the
203 // WebServiceWorker. 203 // WebServiceWorker.
204 static void deleteIfNoExistingOwner(WebServiceWorker* serviceWorker) 204 static void deleteIfNoExistingOwner(WebServiceWorker* serviceWorker)
205 { 205 {
206 if (serviceWorker && !serviceWorker->proxy()) 206 if (serviceWorker && !serviceWorker->proxy())
207 delete serviceWorker; 207 delete serviceWorker;
208 } 208 }
209 209
210 static void deleteIfNoExistingOwner(WebServiceWorkerRegistration* registration)
211 {
212 if (registration && !registration->proxy())
213 delete registration;
214 }
215
216 void ServiceWorkerContainer::setController(WebServiceWorker* serviceWorker) 210 void ServiceWorkerContainer::setController(WebServiceWorker* serviceWorker)
217 { 211 {
218 if (!executionContext()) { 212 if (!executionContext()) {
219 deleteIfNoExistingOwner(serviceWorker); 213 deleteIfNoExistingOwner(serviceWorker);
220 return; 214 return;
221 } 215 }
222 m_controller = ServiceWorker::from(executionContext(), serviceWorker); 216 m_controller = ServiceWorker::from(executionContext(), serviceWorker);
223 } 217 }
224 218
225 void ServiceWorkerContainer::setReadyRegistration(WebServiceWorkerRegistration* registration) 219 void ServiceWorkerContainer::setReadyRegistration(WebServiceWorkerRegistration* registration)
226 { 220 {
227 if (!executionContext()) { 221 if (!executionContext()) {
228 deleteIfNoExistingOwner(registration); 222 ServiceWorkerRegistration::dispose(registration);
229 return; 223 return;
230 } 224 }
231 225
232 ServiceWorkerRegistration* readyRegistration = ServiceWorkerRegistration::fr om(executionContext(), registration); 226 ServiceWorkerRegistration* readyRegistration = ServiceWorkerRegistration::fr om(executionContext(), registration);
233 ASSERT(readyRegistration->active()); 227 ASSERT(readyRegistration->active());
234 228
235 if (m_readyRegistration) { 229 if (m_readyRegistration) {
236 ASSERT(m_readyRegistration == readyRegistration); 230 ASSERT(m_readyRegistration == readyRegistration);
237 ASSERT(m_ready->state() == ReadyProperty::Resolved); 231 ASSERT(m_ready->state() == ReadyProperty::Resolved);
238 return; 232 return;
(...skipping 24 matching lines...) Expand all
263 m_ready = createReadyProperty(); 257 m_ready = createReadyProperty();
264 258
265 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { 259 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) {
266 m_provider = client->provider(); 260 m_provider = client->provider();
267 if (m_provider) 261 if (m_provider)
268 m_provider->setClient(this); 262 m_provider->setClient(this);
269 } 263 }
270 } 264 }
271 265
272 } // namespace blink 266 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/modules/serviceworkers/ServiceWorkerRegistration.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698