diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-15 22:19:48 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-15 22:19:48 +0000 |
commit | 8e2b6472071f38c065a3d00adb136ef259ef68a1 (patch) | |
tree | 8a05864f6463e4948c6468139998a59eb6b54899 /chrome/browser/worker_host | |
parent | 10a4a0aa5e9a1754752454ee2d4d8aff872a61a3 (diff) | |
download | chromium_src-8e2b6472071f38c065a3d00adb136ef259ef68a1.zip chromium_src-8e2b6472071f38c065a3d00adb136ef259ef68a1.tar.gz chromium_src-8e2b6472071f38c065a3d00adb136ef259ef68a1.tar.bz2 |
Create a ResourceMessageFilter to filter resource related IPCs. This gets rid of the awkward ResourceDispatcherHost::Receiver interface and allows a bunch of cleanup. I've also generalized the filtering done in WorkerProcessHost and moved it to ChildProcessHost (since it's now used to add the ResourceMessageFilter).
Review URL: http://codereview.chromium.org/5874002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69335 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/worker_host')
-rw-r--r-- | chrome/browser/worker_host/worker_process_host.cc | 43 | ||||
-rw-r--r-- | chrome/browser/worker_host/worker_process_host.h | 14 |
2 files changed, 7 insertions, 50 deletions
diff --git a/chrome/browser/worker_host/worker_process_host.cc b/chrome/browser/worker_host/worker_process_host.cc index f240fcc..df61eab 100644 --- a/chrome/browser/worker_host/worker_process_host.cc +++ b/chrome/browser/worker_host/worker_process_host.cc @@ -75,11 +75,6 @@ WorkerProcessHost::WorkerProcessHost( } WorkerProcessHost::~WorkerProcessHost() { - for (size_t i = 0; i < filters_.size(); ++i) { - filters_[i]->OnChannelClosing(); - filters_[i]->OnFilterRemoved(); - } - // Let interested observers know we are being deleted. NotificationService::current()->Notify( NotificationType::WORKER_PROCESS_HOST_SHUTDOWN, @@ -197,19 +192,16 @@ bool WorkerProcessHost::Init() { } void WorkerProcessHost::CreateMessageFilters() { - filters_.push_back(new AppCacheDispatcherHost(request_context_, id())); - filters_.push_back(new FileSystemDispatcherHost(request_context_)); - filters_.push_back(new FileUtilitiesMessageFilter(id())); - filters_.push_back( + AddFilter(new AppCacheDispatcherHost(request_context_, id())); + AddFilter(new FileSystemDispatcherHost(request_context_)); + AddFilter(new FileUtilitiesMessageFilter(id())); + AddFilter( new BlobMessageFilter(id(), request_context_->blob_storage_context())); - filters_.push_back(new MimeRegistryMessageFilter()); - filters_.push_back(new DatabaseMessageFilter( + AddFilter(new MimeRegistryMessageFilter()); + AddFilter(new DatabaseMessageFilter( request_context_->database_tracker(), request_context_->host_content_settings_map())); - filters_.push_back(new SocketStreamDispatcherHost()); - - for (size_t i = 0; i < filters_.size(); ++i) - filters_[i]->OnFilterAdded(channel()); + AddFilter(new SocketStreamDispatcherHost()); } void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) { @@ -253,12 +245,6 @@ bool WorkerProcessHost::FilterMessage(const IPC::Message& message, return false; } -URLRequestContext* WorkerProcessHost::GetRequestContext( - uint32 request_id, - const ViewHostMsg_Resource_Request& request_data) { - return request_context_; -} - // Sent to notify the browser process when a worker context invokes close(), so // no new connections are sent to shared workers. void WorkerProcessHost::OnWorkerContextClosed(int worker_route_id) { @@ -274,11 +260,6 @@ 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 = MessagePortDispatcher::GetInstance()->OnMessageReceived( @@ -329,16 +310,6 @@ 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() { } diff --git a/chrome/browser/worker_host/worker_process_host.h b/chrome/browser/worker_host/worker_process_host.h index f8adca0d..39aad8e 100644 --- a/chrome/browser/worker_host/worker_process_host.h +++ b/chrome/browser/worker_host/worker_process_host.h @@ -7,13 +7,11 @@ #pragma once #include <list> -#include <vector> #include "base/basictypes.h" #include "base/callback.h" #include "base/file_path.h" #include "chrome/browser/browser_child_process_host.h" -#include "chrome/browser/browser_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" @@ -148,16 +146,9 @@ class WorkerProcessHost : public BrowserChildProcessHost { Instances& mutable_instances() { return instances_; } private: - // ResourceDispatcherHost::Receiver implementation: - virtual URLRequestContext* GetRequestContext( - 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(); @@ -208,11 +199,6 @@ class WorkerProcessHost : public BrowserChildProcessHost { scoped_refptr<ChromeURLRequestContext> request_context_; - // 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<BrowserMessageFilter> > filters_; - // A callback to create a routing id for the associated worker process. scoped_ptr<CallbackWithReturnValue<int>::Type> next_route_id_callback_; |