Commit 74a30aa3 authored by nhiroki@chromium.org's avatar nhiroki@chromium.org

ServiceWorker: Fix ServiceWorkerRegistration object handling

When there is an existing ServiceWorkerRegistration, getOrCreate() shouldn't
release the given WebServiceWorkerRegistration object because it has already
been taken by the existing registration.


BUG=396400
TEST=https://codereview.chromium.org/466723002/

Review URL: https://codereview.chromium.org/469273002

git-svn-id: svn://svn.chromium.org/blink/trunk@180262 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 6a7046b3
......@@ -88,7 +88,7 @@ PassRefPtrWillBeRawPtr<ServiceWorkerRegistration> ServiceWorkerRegistration::tak
{
if (!registration)
return nullptr;
return getOrCreate(resolver->scriptState()->executionContext(), adoptPtr(registration));
return getOrCreate(resolver->scriptState()->executionContext(), registration);
}
void ServiceWorkerRegistration::dispose(WebType* registration)
......@@ -123,7 +123,7 @@ ScriptPromise ServiceWorkerRegistration::unregister(ScriptState* scriptState)
return promise;
}
PassRefPtrWillBeRawPtr<ServiceWorkerRegistration> ServiceWorkerRegistration::getOrCreate(ExecutionContext* executionContext, PassOwnPtr<WebServiceWorkerRegistration> outerRegistration)
PassRefPtrWillBeRawPtr<ServiceWorkerRegistration> ServiceWorkerRegistration::getOrCreate(ExecutionContext* executionContext, WebServiceWorkerRegistration* outerRegistration)
{
if (!outerRegistration)
return nullptr;
......@@ -137,7 +137,7 @@ PassRefPtrWillBeRawPtr<ServiceWorkerRegistration> ServiceWorkerRegistration::get
}
}
RefPtrWillBeRawPtr<ServiceWorkerRegistration> registration = adoptRefWillBeRefCountedGarbageCollected(new ServiceWorkerRegistration(executionContext, outerRegistration));
RefPtrWillBeRawPtr<ServiceWorkerRegistration> registration = adoptRefWillBeRefCountedGarbageCollected(new ServiceWorkerRegistration(executionContext, adoptPtr(outerRegistration)));
registration->suspendIfNeeded();
return registration.release();
}
......
......@@ -60,7 +60,7 @@ public:
virtual void trace(Visitor*) OVERRIDE;
private:
static PassRefPtrWillBeRawPtr<ServiceWorkerRegistration> getOrCreate(ExecutionContext*, PassOwnPtr<WebServiceWorkerRegistration>);
static PassRefPtrWillBeRawPtr<ServiceWorkerRegistration> getOrCreate(ExecutionContext*, WebServiceWorkerRegistration*);
ServiceWorkerRegistration(ExecutionContext*, PassOwnPtr<WebServiceWorkerRegistration>);
OwnPtr<WebServiceWorkerRegistration> m_outerRegistration;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment