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

Unified Diff: Source/modules/serviceworkers/ServiceWorkerContainer.cpp

Issue 1317473002: ServiceWorker: Clean up ownership management of WebServiceWorkerRegistration (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: incorporate review comment Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/serviceworkers/ServiceWorkerContainer.cpp
diff --git a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
index 532feb2300418e63abe5c433324addc489d65058..fd56d84d22a656f9136c466411d523bb8e6d2e3d 100644
--- a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
+++ b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
@@ -64,11 +64,13 @@ public:
: m_resolver(resolver) { }
~RegistrationCallback() override { }
- void onSuccess(WebServiceWorkerRegistration* registration) override
+ // Takes ownership of |registrationRaw|.
+ void onSuccess(WebServiceWorkerRegistration* registrationRaw) override
{
+ OwnPtr<WebServiceWorkerRegistration> registration = adoptPtr(registrationRaw);
if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped())
return;
- m_resolver->resolve(ServiceWorkerRegistration::take(m_resolver.get(), registration));
+ m_resolver->resolve(ServiceWorkerRegistration::create(m_resolver->executionContext(), registration.release()));
}
// Takes ownership of |errorRaw|.
@@ -91,8 +93,10 @@ public:
: m_resolver(resolver) { }
~GetRegistrationCallback() override { }
- void onSuccess(WebServiceWorkerRegistration* registration) override
+ // Takes ownership of |registrationRaw|.
+ void onSuccess(WebServiceWorkerRegistration* registrationRaw) override
{
+ OwnPtr<WebServiceWorkerRegistration> registration = adoptPtr(registrationRaw);
if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped())
return;
if (!registration) {
@@ -100,7 +104,7 @@ public:
m_resolver->resolve();
return;
}
- m_resolver->resolve(ServiceWorkerRegistration::take(m_resolver.get(), registration));
+ m_resolver->resolve(ServiceWorkerRegistration::create(m_resolver->executionContext(), registration.release()));
}
// Takes ownership of |errorRaw|.
@@ -151,13 +155,18 @@ public:
explicit GetRegistrationForReadyCallback(ReadyProperty* ready)
: m_ready(ready) { }
~GetRegistrationForReadyCallback() { }
- void onSuccess(WebServiceWorkerRegistration* registration) override
+
+ // Takes ownership of |registrationRaw|.
+ void onSuccess(WebServiceWorkerRegistration* registrationRaw) override
{
- ASSERT(registration);
+ ASSERT(registrationRaw);
ASSERT(m_ready->state() == ReadyProperty::Pending);
+
+ OwnPtr<WebServiceWorkerRegistration> registration = adoptPtr(registrationRaw);
if (m_ready->executionContext() && !m_ready->executionContext()->activeDOMObjectsAreStopped())
- m_ready->resolve(ServiceWorkerRegistration::from(m_ready->executionContext(), registration));
+ m_ready->resolve(ServiceWorkerRegistration::create(m_ready->executionContext(), registration.release()));
}
+
private:
Persistent<ReadyProperty> m_ready;
WTF_MAKE_NONCOPYABLE(GetRegistrationForReadyCallback);
« no previous file with comments | « no previous file | Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698