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

Unified Diff: chrome/browser/worker_host/worker_service.cc

Issue 63036: Fix a crash where the ResourceMessageFilter is deleted (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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: chrome/browser/worker_host/worker_service.cc
===================================================================
--- chrome/browser/worker_host/worker_service.cc (revision 13541)
+++ chrome/browser/worker_host/worker_service.cc (working copy)
@@ -14,6 +14,7 @@
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/renderer_host/resource_message_filter.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/notification_service.h"
#include "net/base/registry_controlled_domain.h"
namespace {
@@ -57,6 +58,13 @@
// it to.
worker->CreateWorker(url, render_view_route_id, ++next_worker_route_id_,
renderer_route_id, filter);
+
+ // Receive a notification if the message filter is deleted.
+ NotificationService::current()->AddObserver(
+ this,
+ NotificationType::RESOURCE_MESSAGE_FILTER_SHUTDOWN,
+ Source<ResourceMessageFilter>(filter));
+
return true;
}
@@ -71,14 +79,6 @@
// TODO(jabdelmalek): tell sender that callee is gone
}
-void WorkerService::RendererShutdown(ResourceMessageFilter* filter) {
- for (ChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
- !iter.Done(); ++iter) {
- WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter);
- worker->RendererShutdown(filter);
- }
-}
-
WorkerProcessHost* WorkerService::GetProcessForDomain(const GURL& url) {
int num_processes = 0;
std::string domain =
@@ -126,3 +126,21 @@
return smallest;
}
+
+void WorkerService::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ DCHECK(type.value == NotificationType::RESOURCE_MESSAGE_FILTER_SHUTDOWN);
+ ResourceMessageFilter* filter = Source<ResourceMessageFilter>(source).ptr();
+
+ for (ChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
+ !iter.Done(); ++iter) {
+ WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter);
+ worker->RendererShutdown(filter);
+ }
+
+ NotificationService::current()->RemoveObserver(
+ this,
+ NotificationType::RESOURCE_MESSAGE_FILTER_SHUTDOWN,
+ Source<ResourceMessageFilter>(filter));
+}

Powered by Google App Engine
This is Rietveld 408576698