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

Unified Diff: Source/modules/serviceworkers/ServiceWorkerRegistration.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 | « Source/modules/serviceworkers/ServiceWorkerRegistration.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/serviceworkers/ServiceWorkerRegistration.cpp
diff --git a/Source/modules/serviceworkers/ServiceWorkerRegistration.cpp b/Source/modules/serviceworkers/ServiceWorkerRegistration.cpp
index e3bfd95b556cf00e9e022fe757712fd2a8fea609..eba2e5d61976a7de4eca4dbc6e55d8bfdce3263c 100644
--- a/Source/modules/serviceworkers/ServiceWorkerRegistration.cpp
+++ b/Source/modules/serviceworkers/ServiceWorkerRegistration.cpp
@@ -7,7 +7,6 @@
#include "bindings/core/v8/CallbackPromiseAdapter.h"
#include "bindings/core/v8/ScriptPromise.h"
-#include "bindings/core/v8/ScriptPromiseResolver.h"
#include "bindings/core/v8/ScriptState.h"
#include "core/dom/DOMException.h"
#include "core/dom/ExceptionCode.h"
@@ -63,22 +62,13 @@ void ServiceWorkerRegistration::setActive(WebServiceWorker* serviceWorker)
m_active = ServiceWorker::from(executionContext(), serviceWorker);
}
-ServiceWorkerRegistration* ServiceWorkerRegistration::from(ExecutionContext* executionContext, WebServiceWorkerRegistration* registration)
+ServiceWorkerRegistration* ServiceWorkerRegistration::create(ExecutionContext* executionContext, PassOwnPtr<WebServiceWorkerRegistration> webRegistration)
{
- if (!registration)
- return 0;
- return getOrCreate(executionContext, registration);
-}
-
-ServiceWorkerRegistration* ServiceWorkerRegistration::take(ScriptPromiseResolver* resolver, WebServiceWorkerRegistration* registration)
-{
- return from(resolver->scriptState()->executionContext(), registration);
-}
-
-void ServiceWorkerRegistration::dispose(WebServiceWorkerRegistration* registration)
-{
- if (registration && !registration->proxy())
- delete registration;
+ if (!webRegistration)
+ return nullptr;
+ ServiceWorkerRegistration* registration = new ServiceWorkerRegistration(executionContext, webRegistration);
+ registration->suspendIfNeeded();
+ return registration;
}
String ServiceWorkerRegistration::scope() const
@@ -114,29 +104,14 @@ ScriptPromise ServiceWorkerRegistration::unregister(ScriptState* scriptState)
return promise;
}
-ServiceWorkerRegistration* ServiceWorkerRegistration::getOrCreate(ExecutionContext* executionContext, WebServiceWorkerRegistration* outerRegistration)
-{
- if (!outerRegistration)
- return 0;
-
- ServiceWorkerRegistration* existingRegistration = static_cast<ServiceWorkerRegistration*>(outerRegistration->proxy());
- if (existingRegistration) {
- ASSERT(existingRegistration->executionContext() == executionContext);
- return existingRegistration;
- }
-
- ServiceWorkerRegistration* registration = new ServiceWorkerRegistration(executionContext, adoptPtr(outerRegistration));
- registration->suspendIfNeeded();
- return registration;
-}
-
ServiceWorkerRegistration::ServiceWorkerRegistration(ExecutionContext* executionContext, PassOwnPtr<WebServiceWorkerRegistration> outerRegistration)
: ActiveDOMObject(executionContext)
, m_outerRegistration(outerRegistration)
- , m_provider(0)
+ , m_provider(nullptr)
, m_stopped(false)
{
ASSERT(m_outerRegistration);
+ ASSERT(!m_outerRegistration->proxy());
if (!executionContext)
return;
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerRegistration.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698