| Index: Source/modules/serviceworkers/ServiceWorkerContainer.cpp
|
| diff --git a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
|
| index d2ce8c6af97146b56ccf7319dfd1094ee47faa68..5b0ea1f76dd6029415d1e769aac45e14efd06b50 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)
|
| @@ -195,32 +193,39 @@ static void deleteIfNoExistingOwner(WebServiceWorker* serviceWorker)
|
| delete serviceWorker;
|
| }
|
|
|
| -void ServiceWorkerContainer::setActive(WebServiceWorker* serviceWorker)
|
| +static void deleteIfNoExistingOwner(WebServiceWorkerRegistration* registration)
|
| +{
|
| + if (registration && !registration->proxy())
|
| + delete registration;
|
| +}
|
| +
|
| +void ServiceWorkerContainer::setReadyRegistration(WebServiceWorkerRegistration* registration)
|
| {
|
| if (!executionContext()) {
|
| - deleteIfNoExistingOwner(serviceWorker);
|
| + deleteIfNoExistingOwner(registration);
|
| return;
|
| }
|
| - RefPtrWillBeRawPtr<ServiceWorker> previousReadyWorker = m_active;
|
| - m_active = ServiceWorker::from(executionContext(), serviceWorker);
|
| - checkReadyChanged(previousReadyWorker.release());
|
| -}
|
|
|
| -void ServiceWorkerContainer::checkReadyChanged(PassRefPtrWillBeRawPtr<ServiceWorker> previousReadyWorker)
|
| -{
|
| - ServiceWorker* currentReadyWorker = m_active.get();
|
| + RefPtrWillBeRawPtr<ServiceWorkerRegistration> readyRegistration = ServiceWorkerRegistration::from(executionContext(), registration);
|
| + ASSERT(readyRegistration->active());
|
|
|
| - if (previousReadyWorker == currentReadyWorker)
|
| + if (m_readyRegistration) {
|
| + ASSERT(m_readyRegistration == readyRegistration);
|
| + ASSERT(m_ready->state() == ReadyProperty::Resolved);
|
| return;
|
| -
|
| - if (m_ready->state() != ReadyProperty::Pending) {
|
| - // Already resolved Promises are now stale because the
|
| - // ready worker changed
|
| - m_ready = createReadyProperty();
|
| }
|
|
|
| - if (currentReadyWorker)
|
| - m_ready->resolve(currentReadyWorker);
|
| + m_readyRegistration = readyRegistration;
|
| + m_ready->resolve(readyRegistration);
|
| +}
|
| +
|
| +void ServiceWorkerContainer::setActive(WebServiceWorker* serviceWorker)
|
| +{
|
| + if (!executionContext()) {
|
| + deleteIfNoExistingOwner(serviceWorker);
|
| + return;
|
| + }
|
| + m_active = ServiceWorker::from(executionContext(), serviceWorker);
|
| }
|
|
|
| void ServiceWorkerContainer::setController(WebServiceWorker* serviceWorker)
|
|
|