OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |