Chromium Code Reviews| Index: Source/modules/serviceworkers/ServiceWorkerContainer.cpp |
| diff --git a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp |
| index a34f7748184e6c31e2d037b800df954a000843ca..5a1f485a77a393d97e2131c0247694fcbf6426db 100644 |
| --- a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp |
| +++ b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp |
| @@ -48,12 +48,10 @@ |
| #include "platform/RuntimeEnabledFeatures.h" |
| #include "public/platform/WebServiceWorker.h" |
| #include "public/platform/WebServiceWorkerProvider.h" |
| +#include "public/platform/WebServiceWorkerRegistration.h" |
| #include "public/platform/WebString.h" |
| #include "public/platform/WebURL.h" |
| -using blink::WebServiceWorker; |
| -using blink::WebServiceWorkerProvider; |
| - |
| namespace blink { |
| PassRefPtrWillBeRawPtr<ServiceWorkerContainer> ServiceWorkerContainer::create(ExecutionContext* executionContext) |
| @@ -218,32 +216,48 @@ static void deleteIfNoExistingOwner(WebServiceWorker* serviceWorker) |
| delete serviceWorker; |
| } |
| +static void deleteIfNoExistingOwner(WebServiceWorkerRegistration* registration) |
| +{ |
| + if (registration && !registration->proxy()) |
| + delete registration; |
| +} |
| + |
| +void ServiceWorkerContainer::setReady(WebServiceWorkerRegistration* registration) |
|
michaeln
2014/09/03 22:27:29
should there be an assertion here that registratio
nhiroki
2014/09/04 08:55:58
Done.
|
| +{ |
| + if (!executionContext()) { |
| + deleteIfNoExistingOwner(registration); |
| + return; |
| + } |
| + |
| + RefPtrWillBeRawPtr<ServiceWorkerRegistration> previousReadyRegistration = m_readyRegistration; |
|
michaeln
2014/09/03 22:27:29
is it ever expected that the previous reg is not n
nhiroki
2014/09/04 08:55:58
I think the previous reg could be non-null, for ex
nhiroki
2014/09/04 10:45:10
Ah, you're right! The previous reg should always b
nhiroki
2014/09/04 13:06:57
Done. Removed checkReadyChanged() and added ASSERT
|
| + m_readyRegistration = ServiceWorkerRegistration::from(executionContext(), registration); |
| + checkReadyChanged(previousReadyRegistration.release()); |
| +} |
| + |
| void ServiceWorkerContainer::setActive(WebServiceWorker* serviceWorker) |
| { |
| if (!executionContext()) { |
| deleteIfNoExistingOwner(serviceWorker); |
| return; |
| } |
| - RefPtrWillBeRawPtr<ServiceWorker> previousReadyWorker = m_active; |
| m_active = ServiceWorker::from(executionContext(), serviceWorker); |
| - checkReadyChanged(previousReadyWorker.release()); |
| } |
| -void ServiceWorkerContainer::checkReadyChanged(PassRefPtrWillBeRawPtr<ServiceWorker> previousReadyWorker) |
| +void ServiceWorkerContainer::checkReadyChanged(PassRefPtrWillBeRawPtr<ServiceWorkerRegistration> previousReadyRegistration) |
| { |
| - ServiceWorker* currentReadyWorker = m_active.get(); |
| + ServiceWorkerRegistration* currentReadyRegistration = m_readyRegistration.get(); |
| - if (previousReadyWorker == currentReadyWorker) |
| + if (previousReadyRegistration == currentReadyRegistration) |
| return; |
| if (m_ready->state() != ReadyProperty::Pending) { |
| // Already resolved Promises are now stale because the |
| - // ready worker changed |
| + // ready registration changed |
| m_ready = createReadyProperty(); |
| } |
| - if (currentReadyWorker) |
| - m_ready->resolve(currentReadyWorker); |
| + if (currentReadyRegistration) |
| + m_ready->resolve(currentReadyRegistration); |
| } |
| void ServiceWorkerContainer::setController(WebServiceWorker* serviceWorker) |