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

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

Issue 486083002: ServiceWorker: Introduce ServiceWorkerRegistrationObjectInfo for cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 47885d1db6ce9625994225d9102cdf3098cebe12..e7f0a9551e7dee10a4581496ab7263de27ad97bc 100644
--- a/content/browser/service_worker/service_worker_dispatcher_host.cc
+++ b/content/browser/service_worker/service_worker_dispatcher_host.cc
@@ -327,21 +327,6 @@ void ServiceWorkerDispatcherHost::OnSetHostedVersionId(
BadMessageReceived();
}
-ServiceWorkerHandle* ServiceWorkerDispatcherHost::FindHandle(int provider_id,
- int64 version_id) {
- for (IDMap<ServiceWorkerHandle, IDMapOwnPointer>::iterator iter(&handles_);
- !iter.IsAtEnd();
- iter.Advance()) {
- ServiceWorkerHandle* handle = iter.GetCurrentValue();
- DCHECK(handle);
- if (handle->provider_id() == provider_id && handle->version() &&
- handle->version()->version_id() == version_id) {
- return handle;
- }
- }
- return NULL;
-}
-
ServiceWorkerRegistrationHandle*
ServiceWorkerDispatcherHost::FindRegistrationHandle(int provider_id,
int64 registration_id) {
@@ -374,43 +359,26 @@ void ServiceWorkerDispatcherHost::RegistrationComplete(
return;
}
- ServiceWorkerVersion* version = GetContext()->GetLiveVersion(version_id);
- DCHECK(version);
- DCHECK_EQ(registration_id, version->registration_id());
- ServiceWorkerObjectInfo info;
-
- ServiceWorkerHandle* handle = FindHandle(provider_id, version_id);
- if (handle) {
- DCHECK_EQ(thread_id, handle->thread_id());
- info = handle->GetObjectInfo();
- handle->IncrementRefCount();
- } else {
- scoped_ptr<ServiceWorkerHandle> new_handle = ServiceWorkerHandle::Create(
- GetContext()->AsWeakPtr(), this, thread_id, provider_id, version);
- info = new_handle->GetObjectInfo();
- RegisterServiceWorkerHandle(new_handle.Pass());
- }
-
ServiceWorkerRegistration* registration =
GetContext()->GetLiveRegistration(registration_id);
DCHECK(registration);
- ServiceWorkerRegistrationHandle* registration_handle =
+ ServiceWorkerRegistrationHandle* handle =
FindRegistrationHandle(provider_id, registration_id);
- int registration_handle_id = kInvalidServiceWorkerRegistrationHandleId;
- if (registration_handle) {
- registration_handle->IncrementRefCount();
- registration_handle_id = registration_handle->handle_id();
+ ServiceWorkerRegistrationObjectInfo info;
+ if (handle) {
+ handle->IncrementRefCount();
+ info = handle->GetObjectInfo();
} else {
scoped_ptr<ServiceWorkerRegistrationHandle> new_handle(
new ServiceWorkerRegistrationHandle(
GetContext()->AsWeakPtr(), this, provider_id, registration));
- registration_handle_id = new_handle->handle_id();
+ info = new_handle->GetObjectInfo();
RegisterServiceWorkerRegistrationHandle(new_handle.Pass());
}
Send(new ServiceWorkerMsg_ServiceWorkerRegistered(
- thread_id, request_id, registration_handle_id, info));
+ thread_id, request_id, info));
}
void ServiceWorkerDispatcherHost::OnWorkerScriptLoaded(int embedded_worker_id) {

Powered by Google App Engine
This is Rietveld 408576698