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 | |
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
9 files changed, 104 insertions, 80 deletions
diff --git a/chrome/browser/appcache/appcache_dispatcher_host.cc b/chrome/browser/appcache/appcache_dispatcher_host.cc index e7525e2..720b71b 100644 --- a/chrome/browser/appcache/appcache_dispatcher_host.cc +++ b/chrome/browser/appcache/appcache_dispatcher_host.cc @@ -11,27 +11,29 @@ #include "chrome/common/render_messages.h" AppCacheDispatcherHost::AppCacheDispatcherHost( - URLRequestContext* request_context) - : request_context_(request_context), - receiver_(NULL) { + URLRequestContext* request_context, + int process_id) + : ALLOW_THIS_IN_INITIALIZER_LIST(frontend_proxy_(this)), + request_context_(request_context), + process_id_(process_id) { DCHECK(request_context_.get()); } AppCacheDispatcherHost::AppCacheDispatcherHost( - URLRequestContextGetter* request_context_getter) - : request_context_getter_(request_context_getter), - receiver_(NULL) { + URLRequestContextGetter* request_context_getter, + int process_id) + : ALLOW_THIS_IN_INITIALIZER_LIST(frontend_proxy_(this)), + request_context_getter_(request_context_getter), + process_id_(process_id) { DCHECK(request_context_getter_.get()); } AppCacheDispatcherHost::~AppCacheDispatcherHost() {} -void AppCacheDispatcherHost::Initialize( - ResourceDispatcherHost::Receiver* receiver) { - DCHECK(receiver && !receiver_); - DCHECK(request_context_.get() || request_context_getter_.get()); +void AppCacheDispatcherHost::OnChannelConnected(int32 peer_pid) { + BrowserIOMessageFilter::OnChannelConnected(peer_pid); - receiver_ = receiver; + DCHECK(request_context_.get() || request_context_getter_.get()); // Get the AppCacheService (it can only be accessed from IO thread). URLRequestContext* context = request_context_.get(); @@ -42,10 +44,9 @@ void AppCacheDispatcherHost::Initialize( request_context_ = NULL; request_context_getter_ = NULL; - frontend_proxy_.set_sender(receiver); if (appcache_service_.get()) { backend_impl_.Initialize( - appcache_service_.get(), &frontend_proxy_, receiver->id()); + appcache_service_.get(), &frontend_proxy_, process_id_); get_status_callback_.reset( NewCallback(this, &AppCacheDispatcherHost::GetStatusCallback)); start_update_callback_.reset( @@ -55,12 +56,11 @@ void AppCacheDispatcherHost::Initialize( } } -bool AppCacheDispatcherHost::OnMessageReceived(const IPC::Message& msg, - bool *msg_ok) { - DCHECK(receiver_); - *msg_ok = true; +bool AppCacheDispatcherHost::OnMessageReceived(const IPC::Message& message) { bool handled = true; - IPC_BEGIN_MESSAGE_MAP_EX(AppCacheDispatcherHost, msg, *msg_ok) + bool message_was_ok = true; + + IPC_BEGIN_MESSAGE_MAP_EX(AppCacheDispatcherHost, message, message_was_ok) IPC_MESSAGE_HANDLER(AppCacheMsg_RegisterHost, OnRegisterHost); IPC_MESSAGE_HANDLER(AppCacheMsg_UnregisterHost, OnUnregisterHost); IPC_MESSAGE_HANDLER(AppCacheMsg_GetResourceList, OnGetResourceList); @@ -75,13 +75,17 @@ bool AppCacheDispatcherHost::OnMessageReceived(const IPC::Message& msg, IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_SwapCache, OnSwapCache); IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP_EX() + + if (!message_was_ok) + BadMessageReceived(message.type()); + return handled; } void AppCacheDispatcherHost::OnRegisterHost(int host_id) { if (appcache_service_.get()) { if (!backend_impl_.RegisterHost(host_id)) { - ReceivedBadMessage(AppCacheMsg_RegisterHost::ID); + BadMessageReceived(AppCacheMsg_RegisterHost::ID); } } } @@ -89,7 +93,7 @@ void AppCacheDispatcherHost::OnRegisterHost(int host_id) { void AppCacheDispatcherHost::OnUnregisterHost(int host_id) { if (appcache_service_.get()) { if (!backend_impl_.UnregisterHost(host_id)) { - ReceivedBadMessage(AppCacheMsg_UnregisterHost::ID); + BadMessageReceived(AppCacheMsg_UnregisterHost::ID); } } } @@ -102,7 +106,7 @@ void AppCacheDispatcherHost::OnSelectCache( if (!backend_impl_.SelectCache(host_id, document_url, cache_document_was_loaded_from, opt_manifest_url)) { - ReceivedBadMessage(AppCacheMsg_SelectCache::ID); + BadMessageReceived(AppCacheMsg_SelectCache::ID); } } else { frontend_proxy_.OnCacheSelected(host_id, appcache::AppCacheInfo()); @@ -114,7 +118,7 @@ void AppCacheDispatcherHost::OnSelectCacheForWorker( if (appcache_service_.get()) { if (!backend_impl_.SelectCacheForWorker( host_id, parent_process_id, parent_host_id)) { - ReceivedBadMessage(AppCacheMsg_SelectCacheForWorker::ID); + BadMessageReceived(AppCacheMsg_SelectCacheForWorker::ID); } } else { frontend_proxy_.OnCacheSelected(host_id, appcache::AppCacheInfo()); @@ -125,7 +129,7 @@ void AppCacheDispatcherHost::OnSelectCacheForSharedWorker( int host_id, int64 appcache_id) { if (appcache_service_.get()) { if (!backend_impl_.SelectCacheForSharedWorker(host_id, appcache_id)) - ReceivedBadMessage(AppCacheMsg_SelectCacheForSharedWorker::ID); + BadMessageReceived(AppCacheMsg_SelectCacheForSharedWorker::ID); } else { frontend_proxy_.OnCacheSelected(host_id, appcache::AppCacheInfo()); } @@ -137,7 +141,7 @@ void AppCacheDispatcherHost::OnMarkAsForeignEntry( if (appcache_service_.get()) { if (!backend_impl_.MarkAsForeignEntry(host_id, document_url, cache_document_was_loaded_from)) { - ReceivedBadMessage(AppCacheMsg_MarkAsForeignEntry::ID); + BadMessageReceived(AppCacheMsg_MarkAsForeignEntry::ID); } } } @@ -151,7 +155,7 @@ void AppCacheDispatcherHost::OnGetResourceList( void AppCacheDispatcherHost::OnGetStatus(int host_id, IPC::Message* reply_msg) { if (pending_reply_msg_.get()) { - ReceivedBadMessage(AppCacheMsg_GetStatus::ID); + BadMessageReceived(AppCacheMsg_GetStatus::ID); delete reply_msg; return; } @@ -160,7 +164,7 @@ void AppCacheDispatcherHost::OnGetStatus(int host_id, if (appcache_service_.get()) { if (!backend_impl_.GetStatusWithCallback( host_id, get_status_callback_.get(), reply_msg)) { - ReceivedBadMessage(AppCacheMsg_GetStatus::ID); + BadMessageReceived(AppCacheMsg_GetStatus::ID); } return; } @@ -171,7 +175,7 @@ void AppCacheDispatcherHost::OnGetStatus(int host_id, void AppCacheDispatcherHost::OnStartUpdate(int host_id, IPC::Message* reply_msg) { if (pending_reply_msg_.get()) { - ReceivedBadMessage(AppCacheMsg_StartUpdate::ID); + BadMessageReceived(AppCacheMsg_StartUpdate::ID); delete reply_msg; return; } @@ -180,7 +184,7 @@ void AppCacheDispatcherHost::OnStartUpdate(int host_id, if (appcache_service_.get()) { if (!backend_impl_.StartUpdateWithCallback( host_id, start_update_callback_.get(), reply_msg)) { - ReceivedBadMessage(AppCacheMsg_StartUpdate::ID); + BadMessageReceived(AppCacheMsg_StartUpdate::ID); } return; } @@ -191,7 +195,7 @@ void AppCacheDispatcherHost::OnStartUpdate(int host_id, void AppCacheDispatcherHost::OnSwapCache(int host_id, IPC::Message* reply_msg) { if (pending_reply_msg_.get()) { - ReceivedBadMessage(AppCacheMsg_SwapCache::ID); + BadMessageReceived(AppCacheMsg_SwapCache::ID); delete reply_msg; return; } @@ -200,7 +204,7 @@ void AppCacheDispatcherHost::OnSwapCache(int host_id, if (appcache_service_.get()) { if (!backend_impl_.SwapCacheWithCallback( host_id, swap_cache_callback_.get(), reply_msg)) { - ReceivedBadMessage(AppCacheMsg_SwapCache::ID); + BadMessageReceived(AppCacheMsg_SwapCache::ID); } return; } @@ -213,26 +217,19 @@ void AppCacheDispatcherHost::GetStatusCallback( IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param); DCHECK(reply_msg == pending_reply_msg_.get()); AppCacheMsg_GetStatus::WriteReplyParams(reply_msg, status); - frontend_proxy_.sender()->Send(pending_reply_msg_.release()); + Send(pending_reply_msg_.release()); } void AppCacheDispatcherHost::StartUpdateCallback(bool result, void* param) { IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param); DCHECK(reply_msg == pending_reply_msg_.get()); AppCacheMsg_StartUpdate::WriteReplyParams(reply_msg, result); - frontend_proxy_.sender()->Send(pending_reply_msg_.release()); + Send(pending_reply_msg_.release()); } void AppCacheDispatcherHost::SwapCacheCallback(bool result, void* param) { IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param); DCHECK(reply_msg == pending_reply_msg_.get()); AppCacheMsg_SwapCache::WriteReplyParams(reply_msg, result); - frontend_proxy_.sender()->Send(pending_reply_msg_.release()); -} - -void AppCacheDispatcherHost::ReceivedBadMessage(uint32 msg_type) { - // TODO(michaeln): Consider gathering UMA stats - // http://code.google.com/p/chromium/issues/detail?id=24634 - BrowserRenderProcessHost::BadMessageTerminateProcess( - msg_type, receiver_->handle()); + Send(pending_reply_msg_.release()); } diff --git a/chrome/browser/appcache/appcache_dispatcher_host.h b/chrome/browser/appcache/appcache_dispatcher_host.h index 23c7c77..a9e6d20 100644 --- a/chrome/browser/appcache/appcache_dispatcher_host.h +++ b/chrome/browser/appcache/appcache_dispatcher_host.h @@ -12,6 +12,7 @@ #include "base/ref_counted.h" #include "base/scoped_ptr.h" #include "chrome/browser/appcache/appcache_frontend_proxy.h" +#include "chrome/browser/browser_io_message_filter.h" #include "chrome/browser/renderer_host/resource_dispatcher_host.h" #include "ipc/ipc_message.h" #include "webkit/appcache/appcache_backend_impl.h" @@ -24,30 +25,24 @@ class URLRequestContextGetter; // its child processes. There is a distinct host for each child process. // Messages are handled on the IO thread. The ResourceMessageFilter and // WorkerProcessHost create an instance and delegates calls to it. -class AppCacheDispatcherHost { +class AppCacheDispatcherHost : public BrowserIOMessageFilter { public: // Constructor for use on the IO thread. - explicit AppCacheDispatcherHost( - URLRequestContext* request_context); + AppCacheDispatcherHost(URLRequestContext* request_context, + int process_id); // Constructor for use on the UI thread. - explicit AppCacheDispatcherHost( - URLRequestContextGetter* request_context_getter); + AppCacheDispatcherHost(URLRequestContextGetter* request_context_getter, + int process_id); ~AppCacheDispatcherHost(); - void Initialize(ResourceDispatcherHost::Receiver* receiver); - bool OnMessageReceived(const IPC::Message& msg, bool* msg_is_ok); - - int process_id() const { return backend_impl_.process_id(); } - - // Note: needed to satisfy ipc message dispatching macros. - bool Send(IPC::Message* msg) { - return frontend_proxy_.sender()->Send(msg); - } + // BrowserIOMessageFilter implementation + virtual bool OnMessageReceived(const IPC::Message& message); + virtual void OnChannelConnected(int32 peer_pid); private: - // Ipc message handlers + // IPC message handlers void OnRegisterHost(int host_id); void OnUnregisterHost(int host_id); void OnSelectCache(int host_id, const GURL& document_url, @@ -68,25 +63,26 @@ class AppCacheDispatcherHost { void StartUpdateCallback(bool result, void* param); void SwapCacheCallback(bool result, void* param); - void ReceivedBadMessage(uint32 msg_type); + // This is only valid once Initialize() has been called. This MUST be defined + // before backend_impl_ since the latter maintains a (non-refcounted) pointer + // to it. + scoped_refptr<ChromeAppCacheService> appcache_service_; AppCacheFrontendProxy frontend_proxy_; appcache::AppCacheBackendImpl backend_impl_; - // Temporary until Initialize() can be called from the IO thread, + // Temporary until OnChannelConnected() can be called from the IO thread, // which will extract the AppCacheService from the URLRequestContext. scoped_refptr<URLRequestContext> request_context_; scoped_refptr<URLRequestContextGetter> request_context_getter_; - // This is only valid once Initialize() has been called. - scoped_refptr<ChromeAppCacheService> appcache_service_; - scoped_ptr<appcache::GetStatusCallback> get_status_callback_; scoped_ptr<appcache::StartUpdateCallback> start_update_callback_; scoped_ptr<appcache::SwapCacheCallback> swap_cache_callback_; scoped_ptr<IPC::Message> pending_reply_msg_; - ResourceDispatcherHost::Receiver* receiver_; + // The corresponding ChildProcessHost object's id(). + int process_id_; DISALLOW_COPY_AND_ASSIGN(AppCacheDispatcherHost); }; diff --git a/chrome/browser/appcache/appcache_frontend_proxy.cc b/chrome/browser/appcache/appcache_frontend_proxy.cc index 0a80424..c82cb57 100644 --- a/chrome/browser/appcache/appcache_frontend_proxy.cc +++ b/chrome/browser/appcache/appcache_frontend_proxy.cc @@ -6,6 +6,10 @@ #include "chrome/common/render_messages.h" +AppCacheFrontendProxy::AppCacheFrontendProxy(IPC::Message::Sender* sender) + : sender_(sender) { +} + void AppCacheFrontendProxy::OnCacheSelected( int host_id, const appcache::AppCacheInfo& info) { sender_->Send(new AppCacheMsg_CacheSelected(host_id, info)); diff --git a/chrome/browser/appcache/appcache_frontend_proxy.h b/chrome/browser/appcache/appcache_frontend_proxy.h index 2d3775c..51e1f95 100644 --- a/chrome/browser/appcache/appcache_frontend_proxy.h +++ b/chrome/browser/appcache/appcache_frontend_proxy.h @@ -15,9 +15,7 @@ // Sends appcache related messages to a child process. class AppCacheFrontendProxy : public appcache::AppCacheFrontend { public: - AppCacheFrontendProxy() : sender_(NULL) {} - void set_sender(IPC::Message::Sender* sender) { sender_ = sender; } - IPC::Message::Sender* sender() const { return sender_; } + explicit AppCacheFrontendProxy(IPC::Message::Sender* sender); // AppCacheFrontend methods virtual void OnCacheSelected(int host_id, const appcache::AppCacheInfo& info); diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index 9c8846c..16dbede 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -26,6 +26,7 @@ #include "base/string_util.h" #include "base/thread.h" #include "base/thread_restrictions.h" +#include "chrome/browser/appcache/appcache_dispatcher_host.h" #include "chrome/browser/browser_child_process_host.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/child_process_security_policy.h" @@ -383,6 +384,8 @@ void BrowserRenderProcessHost::CreateMessageFilters() { channel_->AddFilter(resource_message_filter); channel_->AddFilter(new AudioRendererHost()); + channel_->AddFilter( + new AppCacheDispatcherHost(profile()->GetRequestContext(), id())); channel_->AddFilter(new PepperFileMessageFilter(id(), profile())); } diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index 37a44d5..f82e398 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -13,7 +13,6 @@ #include "base/thread.h" #include "base/utf_string_conversions.h" #include "base/worker_pool.h" -#include "chrome/browser/appcache/appcache_dispatcher_host.h" #include "chrome/browser/automation/automation_resource_message_filter.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_thread.h" @@ -256,8 +255,6 @@ ResourceMessageFilter::ResourceMessageFilter( media_request_context_(profile->GetRequestContextForMedia()), extensions_request_context_(profile->GetRequestContextForExtensions()), render_widget_helper_(render_widget_helper), - appcache_dispatcher_host_( - new AppCacheDispatcherHost(profile->GetRequestContext())), ALLOW_THIS_IN_INITIALIZER_LIST(dom_storage_dispatcher_host_( new DOMStorageDispatcherHost(this, profile->GetWebKitContext()))), ALLOW_THIS_IN_INITIALIZER_LIST(indexed_db_dispatcher_host_( @@ -294,7 +291,6 @@ ResourceMessageFilter::ResourceMessageFilter( request_context_ = profile_->GetRequestContext(); DCHECK(request_context_); DCHECK(media_request_context_); - DCHECK(appcache_dispatcher_host_.get()); DCHECK(dom_storage_dispatcher_host_.get()); render_widget_helper_->Init(id(), resource_dispatcher_host_); @@ -358,7 +354,6 @@ void ResourceMessageFilter::OnChannelConnected(int32 peer_pid) { set_handle(peer_handle); WorkerService::GetInstance()->Initialize(resource_dispatcher_host_); - appcache_dispatcher_host_->Initialize(this); dom_storage_dispatcher_host_->Init(id(), handle()); indexed_db_dispatcher_host_->Init(id(), handle()); db_dispatcher_host_->Init(handle()); @@ -388,7 +383,6 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) { bool msg_is_ok = true; bool handled = resource_dispatcher_host_->OnMessageReceived(msg, this, &msg_is_ok) || - appcache_dispatcher_host_->OnMessageReceived(msg, &msg_is_ok) || dom_storage_dispatcher_host_->OnMessageReceived(msg, &msg_is_ok) || indexed_db_dispatcher_host_->OnMessageReceived(msg) || db_dispatcher_host_->OnMessageReceived(msg, &msg_is_ok) || diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h index 051f95d6..5aeaa7d 100644 --- a/chrome/browser/renderer_host/resource_message_filter.h +++ b/chrome/browser/renderer_host/resource_message_filter.h @@ -31,7 +31,6 @@ #include "third_party/WebKit/WebKit/chromium/public/WebCache.h" #include "third_party/WebKit/WebKit/chromium/public/WebPopupType.h" -class AppCacheDispatcherHost; class BlobDispatcherHost; class ChromeURLRequestContext; class DatabaseDispatcherHost; @@ -445,9 +444,6 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, scoped_refptr<RenderWidgetHelper> render_widget_helper_; - // Handles AppCache related messages. - scoped_ptr<AppCacheDispatcherHost> appcache_dispatcher_host_; - // Handles DOM Storage related messages. scoped_refptr<DOMStorageDispatcherHost> dom_storage_dispatcher_host_; 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_; |