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

Unified Diff: content/browser/service_worker/service_worker_dispatcher_host.cc

Issue 1307133003: ServiceWorker: Make APIs that return ServiceWorkerRegistration coin a new JS object (2/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: split CreateRegistration() 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
Index: content/browser/service_worker/service_worker_dispatcher_host.cc
diff --git a/content/browser/service_worker/service_worker_dispatcher_host.cc b/content/browser/service_worker/service_worker_dispatcher_host.cc
index 0e9f3c97f2bd3bd9ac021b6cb958b4903137f19e..2de8b88307279714cb2493a75286313f6df5f8d4 100644
--- a/content/browser/service_worker/service_worker_dispatcher_host.cc
+++ b/content/browser/service_worker/service_worker_dispatcher_host.cc
@@ -259,23 +259,16 @@ ServiceWorkerHandle* ServiceWorkerDispatcherHost::FindServiceWorkerHandle(
}
ServiceWorkerRegistrationHandle*
-ServiceWorkerDispatcherHost::GetOrCreateRegistrationHandle(
+ServiceWorkerDispatcherHost::CreateRegistrationHandle(
base::WeakPtr<ServiceWorkerProviderHost> provider_host,
ServiceWorkerRegistration* registration) {
DCHECK(provider_host);
- ServiceWorkerRegistrationHandle* handle =
- FindRegistrationHandle(provider_host->provider_id(), registration->id());
- if (handle) {
- handle->IncrementRefCount();
- return handle;
- }
-
- scoped_ptr<ServiceWorkerRegistrationHandle> new_handle(
- new ServiceWorkerRegistrationHandle(
- GetContext()->AsWeakPtr(), provider_host, registration));
- handle = new_handle.get();
- RegisterServiceWorkerRegistrationHandle(new_handle.Pass());
- return handle;
+ scoped_ptr<ServiceWorkerRegistrationHandle> handle(
+ new ServiceWorkerRegistrationHandle(GetContext()->AsWeakPtr(),
+ provider_host, registration));
+ ServiceWorkerRegistrationHandle* handle_ptr = handle.get();
+ RegisterServiceWorkerRegistrationHandle(handle.Pass());
+ return handle_ptr;
}
void ServiceWorkerDispatcherHost::OnRegisterServiceWorker(
@@ -796,31 +789,13 @@ void ServiceWorkerDispatcherHost::OnSetHostedVersionId(
kDocumentMainThreadId, provider_id, info, attrs));
}
-ServiceWorkerRegistrationHandle*
-ServiceWorkerDispatcherHost::FindRegistrationHandle(int provider_id,
- int64 registration_id) {
- for (IDMap<ServiceWorkerRegistrationHandle, IDMapOwnPointer>::iterator
- iter(&registration_handles_);
- !iter.IsAtEnd();
- iter.Advance()) {
- ServiceWorkerRegistrationHandle* handle = iter.GetCurrentValue();
- DCHECK(handle);
- DCHECK(handle->registration());
- if (handle->provider_id() == provider_id &&
- handle->registration()->id() == registration_id) {
- return handle;
- }
- }
- return NULL;
-}
-
void ServiceWorkerDispatcherHost::GetRegistrationObjectInfoAndVersionAttributes(
base::WeakPtr<ServiceWorkerProviderHost> provider_host,
ServiceWorkerRegistration* registration,
ServiceWorkerRegistrationObjectInfo* info,
ServiceWorkerVersionAttributes* attrs) {
ServiceWorkerRegistrationHandle* handle =
- GetOrCreateRegistrationHandle(provider_host, registration);
+ CreateRegistrationHandle(provider_host, registration);
*info = handle->GetObjectInfo();
attrs->installing = provider_host->GetOrCreateServiceWorkerHandle(

Powered by Google App Engine
This is Rietveld 408576698