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

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

Issue 224733014: Introduce ServiceWorkerHandle for tracking WebServiceWorkerImpl reference (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 321bdf611fa1ad10bdfaf4751f516c3aab20eacd..45efdfa38634cbefdfd8f935f47b9f3d995918f9 100644
--- a/content/browser/service_worker/service_worker_dispatcher_host.cc
+++ b/content/browser/service_worker/service_worker_dispatcher_host.cc
@@ -10,6 +10,7 @@
#include "content/browser/service_worker/embedded_worker_registry.h"
#include "content/browser/service_worker/service_worker_context_core.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
+#include "content/browser/service_worker/service_worker_handle.h"
#include "content/browser/service_worker/service_worker_registration.h"
#include "content/browser/service_worker/service_worker_utils.h"
#include "content/common/service_worker/embedded_worker_messages.h"
@@ -100,12 +101,19 @@ bool ServiceWorkerDispatcherHost::OnMessageReceived(
OnWorkerStopped)
IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_SendMessageToBrowser,
OnSendMessageToBrowser)
+ IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ServiceWorkerObjectDestroyed,
+ OnServiceWorkerObjectDestroyed)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
+int ServiceWorkerDispatcherHost::RegisterServiceWorkerHandle(
+ scoped_ptr<ServiceWorkerHandle> handle) {
+ return handles_.Add(handle.release());
+}
+
void ServiceWorkerDispatcherHost::OnRegisterServiceWorker(
int thread_id,
int request_id,
@@ -221,7 +229,7 @@ void ServiceWorkerDispatcherHost::OnProviderCreated(int provider_id) {
}
scoped_ptr<ServiceWorkerProviderHost> provider_host(
new ServiceWorkerProviderHost(
- render_process_id_, provider_id, context_));
+ render_process_id_, provider_id, context_, this));
context_->AddProviderHost(provider_host.Pass());
}
@@ -275,13 +283,21 @@ void ServiceWorkerDispatcherHost::RegistrationComplete(
ServiceWorkerStatusCode status,
int64 registration_id,
int64 version_id) {
+ if (!context_)
+ return;
+
if (status != SERVICE_WORKER_OK) {
SendRegistrationError(thread_id, request_id, status);
return;
}
+ ServiceWorkerVersion* version = context_->GetLiveVersion(version_id);
+ DCHECK(version);
+ DCHECK_EQ(registration_id, version->registration_id());
+ int handle_id = RegisterServiceWorkerHandle(
+ ServiceWorkerHandle::Create(context_, this, version));
Send(new ServiceWorkerMsg_ServiceWorkerRegistered(
- thread_id, request_id, registration_id, version_id));
+ thread_id, request_id, handle_id, version_id));
}
void ServiceWorkerDispatcherHost::OnWorkerStarted(
@@ -309,6 +325,11 @@ void ServiceWorkerDispatcherHost::OnSendMessageToBrowser(
embedded_worker_id, request_id, message);
}
+void ServiceWorkerDispatcherHost::OnServiceWorkerObjectDestroyed(
+ int handle_id) {
+ handles_.Remove(handle_id);
+}
+
void ServiceWorkerDispatcherHost::UnregistrationComplete(
int thread_id,
int request_id,

Powered by Google App Engine
This is Rietveld 408576698