| 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));
|
| +}
|
|
|