diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-04 00:49:09 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-04 00:49:09 +0000 |
commit | 714a498fed93071523c0c9f389083ed865f14255 (patch) | |
tree | 12d8f9fe9f545e5c04ed1f73e57959267b53cb83 /chrome/browser/worker_host | |
parent | 5f7393b7427f126745f1e65e85ab68bfc4e6161f (diff) | |
download | chromium_src-714a498fed93071523c0c9f389083ed865f14255.zip chromium_src-714a498fed93071523c0c9f389083ed865f14255.tar.gz chromium_src-714a498fed93071523c0c9f389083ed865f14255.tar.bz2 |
Make the AppCacheDispatcherHost be a MessageFilter so that ResourceMessageFilter doesn't have to know about it and vice versa.
Review URL: http://codereview.chromium.org/5625003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68254 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/worker_host')
-rw-r--r-- | chrome/browser/worker_host/worker_process_host.cc | 33 | ||||
-rw-r--r-- | chrome/browser/worker_host/worker_process_host.h | 15 |
2 files changed, 42 insertions, 6 deletions
diff --git a/chrome/browser/worker_host/worker_process_host.cc b/chrome/browser/worker_host/worker_process_host.cc index 1ec2458..03ce293 100644 --- a/chrome/browser/worker_host/worker_process_host.cc +++ b/chrome/browser/worker_host/worker_process_host.cc @@ -69,8 +69,6 @@ WorkerProcessHost::WorkerProcessHost( ChromeURLRequestContext *request_context) : BrowserChildProcessHost(WORKER_PROCESS, resource_dispatcher_host), request_context_(request_context), - appcache_dispatcher_host_( - new AppCacheDispatcherHost(request_context)), ALLOW_THIS_IN_INITIALIZER_LIST(blob_dispatcher_host_( new BlobDispatcherHost( this->id(), request_context->blob_storage_context()))), @@ -85,10 +83,14 @@ WorkerProcessHost::WorkerProcessHost( db_dispatcher_host_ = new DatabaseDispatcherHost( request_context->database_tracker(), this, request_context_->host_content_settings_map()); - appcache_dispatcher_host_->Initialize(this); } WorkerProcessHost::~WorkerProcessHost() { + for (size_t i = 0; i < filters_.size(); ++i) { + filters_[i]->OnChannelClosing(); + filters_[i]->OnFilterRemoved(); + } + // Shut down the database dispatcher host. db_dispatcher_host_->Shutdown(); @@ -215,9 +217,18 @@ bool WorkerProcessHost::Init() { base::PLATFORM_FILE_WRITE_ATTRIBUTES); } + CreateMessageFilters(); + return true; } +void WorkerProcessHost::CreateMessageFilters() { + filters_.push_back(new AppCacheDispatcherHost(request_context_, id())); + + for (size_t i = 0; i < filters_.size(); ++i) + filters_[i]->OnFilterAdded(channel()); +} + void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) { ChildProcessSecurityPolicy::GetInstance()->GrantRequestURL( id(), instance.url()); @@ -280,9 +291,13 @@ void WorkerProcessHost::OnWorkerContextClosed(int worker_route_id) { } void WorkerProcessHost::OnMessageReceived(const IPC::Message& message) { + for (size_t i = 0; i < filters_.size(); ++i) { + if (filters_[i]->OnMessageReceived(message)) + return; + } + bool msg_is_ok = true; bool handled = - appcache_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || db_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || blob_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || file_system_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || @@ -336,6 +351,16 @@ void WorkerProcessHost::OnMessageReceived(const IPC::Message& message) { } } +void WorkerProcessHost::OnChannelConnected(int32 peer_pid) { + for (size_t i = 0; i < filters_.size(); ++i) + filters_[i]->OnChannelConnected(peer_pid); +} + +void WorkerProcessHost::OnChannelError() { + for (size_t i = 0; i < filters_.size(); ++i) + filters_[i]->OnChannelError(); +} + void WorkerProcessHost::OnProcessLaunched() { db_dispatcher_host_->Init(handle()); file_system_dispatcher_host_->Init(handle()); diff --git a/chrome/browser/worker_host/worker_process_host.h b/chrome/browser/worker_host/worker_process_host.h index 2ddcdff..df83a97 100644 --- a/chrome/browser/worker_host/worker_process_host.h +++ b/chrome/browser/worker_host/worker_process_host.h @@ -7,18 +7,19 @@ #pragma once #include <list> +#include <vector> #include "base/basictypes.h" #include "base/callback.h" #include "base/file_path.h" #include "base/ref_counted.h" #include "chrome/browser/browser_child_process_host.h" +#include "chrome/browser/browser_io_message_filter.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/worker_host/worker_document_set.h" #include "googleurl/src/gurl.h" #include "ipc/ipc_channel.h" -class AppCacheDispatcherHost; class BlobDispatcherHost; class ChromeURLRequestContext; class ChromeURLRequestContextGetter; @@ -159,8 +160,14 @@ class WorkerProcessHost : public BrowserChildProcessHost { uint32 request_id, const ViewHostMsg_Resource_Request& request_data); + // IPC::Channel::Listener implementation: // Called when a message arrives from the worker process. virtual void OnMessageReceived(const IPC::Message& message); + virtual void OnChannelConnected(int32 peer_pid); + virtual void OnChannelError(); + + // Creates and adds the message filters. + void CreateMessageFilters(); // Called when the process has been launched successfully. virtual void OnProcessLaunched(); @@ -207,13 +214,17 @@ class WorkerProcessHost : public BrowserChildProcessHost { Instances instances_; scoped_refptr<ChromeURLRequestContext> request_context_; - scoped_ptr<AppCacheDispatcherHost> appcache_dispatcher_host_; scoped_refptr<DatabaseDispatcherHost> db_dispatcher_host_; scoped_ptr<BlobDispatcherHost> blob_dispatcher_host_; scoped_refptr<FileSystemDispatcherHost> file_system_dispatcher_host_; scoped_refptr<FileUtilitiesDispatcherHost> file_utilities_dispatcher_host_; scoped_refptr<MimeRegistryDispatcher> mime_registry_dispatcher_; + // Holds all the IPC message filters. Since the worker process host is on the + // IO thread, we don't have a IPC::ChannelProxy and so we manage filters + // manually. + std::vector<scoped_refptr<BrowserIOMessageFilter> > filters_; + // A callback to create a routing id for the associated worker process. scoped_ptr<CallbackWithReturnValue<int>::Type> next_route_id_callback_; |