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

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

Issue 552693002: ServiceWorker: Make GetOrCreateRegistrationHandle for refactoring (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 3 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 | « content/browser/service_worker/service_worker_dispatcher_host.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 cd2580eb577c833554a87fe9c5d9f35304c325c4..a0bdabf61db8196e2f0104d6e715dfa67d828a11 100644
--- a/content/browser/service_worker/service_worker_dispatcher_host.cc
+++ b/content/browser/service_worker/service_worker_dispatcher_host.cc
@@ -169,6 +169,25 @@ bool ServiceWorkerDispatcherHost::Send(IPC::Message* message) {
return true;
}
+ServiceWorkerRegistrationHandle*
+ServiceWorkerDispatcherHost::GetOrCreateRegistrationHandle(
+ int provider_id,
+ ServiceWorkerRegistration* registration) {
+ ServiceWorkerRegistrationHandle* handle =
+ FindRegistrationHandle(provider_id, registration->id());
+ if (handle) {
+ handle->IncrementRefCount();
+ return handle;
+ }
+
+ scoped_ptr<ServiceWorkerRegistrationHandle> new_handle(
+ new ServiceWorkerRegistrationHandle(
+ GetContext()->AsWeakPtr(), this, provider_id, registration));
+ handle = new_handle.get();
+ RegisterServiceWorkerRegistrationHandle(new_handle.Pass());
+ return handle;
+}
+
void ServiceWorkerDispatcherHost::RegisterServiceWorkerHandle(
scoped_ptr<ServiceWorkerHandle> handle) {
int handle_id = handle->handle_id();
@@ -391,19 +410,7 @@ void ServiceWorkerDispatcherHost::RegistrationComplete(
DCHECK(registration);
ServiceWorkerRegistrationHandle* handle =
- FindRegistrationHandle(provider_id, registration_id);
- ServiceWorkerRegistrationObjectInfo info;
- if (handle) {
- handle->IncrementRefCount();
- info = handle->GetObjectInfo();
- } else {
- scoped_ptr<ServiceWorkerRegistrationHandle> new_handle(
- new ServiceWorkerRegistrationHandle(
- GetContext()->AsWeakPtr(), this, provider_id, registration));
- info = new_handle->GetObjectInfo();
- handle = new_handle.get();
- RegisterServiceWorkerRegistrationHandle(new_handle.Pass());
- }
+ GetOrCreateRegistrationHandle(provider_id, registration);
ServiceWorkerVersionAttributes attrs;
attrs.installing = handle->CreateServiceWorkerHandleAndPass(
@@ -414,7 +421,7 @@ void ServiceWorkerDispatcherHost::RegistrationComplete(
registration->active_version());
Send(new ServiceWorkerMsg_ServiceWorkerRegistered(
- thread_id, request_id, info, attrs));
+ thread_id, request_id, handle->GetObjectInfo(), attrs));
TRACE_EVENT_ASYNC_END2("ServiceWorker",
"ServiceWorkerDispatcherHost::RegisterServiceWorker",
request_id,
« no previous file with comments | « content/browser/service_worker/service_worker_dispatcher_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698