summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-13 17:00:42 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-13 17:00:42 +0000
commit9f547bfd7465f0bcb29ab1d0225dddf81e7ebed8 (patch)
treeb9991ef261fb6107a25947da1231c36e70919bd1
parentdc8caba097e35e536697f3bf6605257317640d26 (diff)
downloadchromium_src-9f547bfd7465f0bcb29ab1d0225dddf81e7ebed8.zip
chromium_src-9f547bfd7465f0bcb29ab1d0225dddf81e7ebed8.tar.gz
chromium_src-9f547bfd7465f0bcb29ab1d0225dddf81e7ebed8.tar.bz2
Switch a bunch of remaining filters to derive from BrowserMessageFilters so that ResourceMessageFilter doesn't have to know about them and vice versa. A bunch of small cleanup in the process. I've added new message files for classes that want their messages dispatched on threads other than the IO.
Review URL: http://codereview.chromium.org/5698008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69008 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/device_orientation/message_filter.cc (renamed from chrome/browser/device_orientation/dispatcher_host.cc)50
-rw-r--r--chrome/browser/device_orientation/message_filter.h (renamed from chrome/browser/device_orientation/dispatcher_host.h)26
-rw-r--r--chrome/browser/file_system/file_system_dispatcher_host.cc41
-rw-r--r--chrome/browser/file_system/file_system_dispatcher_host.h30
-rw-r--r--chrome/browser/mime_registry_dispatcher.cc96
-rw-r--r--chrome/browser/mime_registry_dispatcher.h37
-rw-r--r--chrome/browser/mime_registry_message_filter.cc51
-rw-r--r--chrome/browser/mime_registry_message_filter.h31
-rw-r--r--chrome/browser/renderer_host/blob_message_filter.cc (renamed from chrome/browser/renderer_host/blob_dispatcher_host.cc)27
-rw-r--r--chrome/browser/renderer_host/blob_message_filter.h (renamed from chrome/browser/renderer_host/blob_dispatcher_host.h)24
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc16
-rw-r--r--chrome/browser/renderer_host/file_utilities_dispatcher_host.cc199
-rw-r--r--chrome/browser/renderer_host/file_utilities_dispatcher_host.h63
-rw-r--r--chrome/browser/renderer_host/file_utilities_message_filter.cc106
-rw-r--r--chrome/browser/renderer_host/file_utilities_message_filter.h48
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc50
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h37
-rw-r--r--chrome/browser/search_engines/search_provider_install_state_message_filter.cc (renamed from chrome/browser/search_engines/search_provider_install_state_dispatcher_host.cc)38
-rw-r--r--chrome/browser/search_engines/search_provider_install_state_message_filter.h (renamed from chrome/browser/search_engines/search_provider_install_state_dispatcher_host.h)40
-rw-r--r--chrome/browser/speech/speech_input_dispatcher_host.cc50
-rw-r--r--chrome/browser/speech/speech_input_dispatcher_host.h22
-rw-r--r--chrome/browser/worker_host/worker_process_host.cc40
-rw-r--r--chrome/browser/worker_host/worker_process_host.h8
-rw-r--r--chrome/chrome_browser.gypi20
-rw-r--r--chrome/chrome_common.gypi4
-rw-r--r--chrome/common/file_utilities_messages.cc8
-rw-r--r--chrome/common/file_utilities_messages.h35
-rw-r--r--chrome/common/mime_registry_messages.cc8
-rw-r--r--chrome/common/mime_registry_messages.h28
-rw-r--r--chrome/common/render_messages_internal.h28
-rw-r--r--chrome/renderer/renderer_webkitclient_impl.cc19
-rw-r--r--chrome/worker/worker_webkitclient_impl.cc16
-rw-r--r--ipc/ipc_message_macros.h4
-rw-r--r--ipc/ipc_message_utils.h2
34 files changed, 508 insertions, 794 deletions
diff --git a/chrome/browser/device_orientation/dispatcher_host.cc b/chrome/browser/device_orientation/message_filter.cc
index 6bec33f..06f49cb 100644
--- a/chrome/browser/device_orientation/dispatcher_host.cc
+++ b/chrome/browser/device_orientation/message_filter.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/device_orientation/dispatcher_host.h"
+#include "chrome/browser/device_orientation/message_filter.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/browser_thread.h"
@@ -16,24 +16,21 @@
namespace device_orientation {
-DispatcherHost::DispatcherHost(int process_id)
- : process_id_(process_id),
- observers_map_(),
- provider_(NULL) {
+MessageFilter::MessageFilter() : provider_(NULL) {
}
-DispatcherHost::~DispatcherHost() {
+MessageFilter::~MessageFilter() {
}
-class DispatcherHost::ObserverDelegate
+class MessageFilter::ObserverDelegate
: public base::RefCounted<ObserverDelegate>, public Provider::Observer {
public:
// Create ObserverDelegate that observes provider and forwards updates to
// render_view_id in process_id.
// Will stop observing provider when destructed.
ObserverDelegate(Provider* provider,
- int process_id,
- int render_view_id);
+ int render_view_id,
+ IPC::Message::Sender* sender);
// From Provider::Observer.
virtual void OnOrientationUpdate(const Orientation& orientation);
@@ -43,26 +40,26 @@ class DispatcherHost::ObserverDelegate
virtual ~ObserverDelegate();
scoped_refptr<Provider> provider_;
- int process_id_;
int render_view_id_;
+ IPC::Message::Sender* sender_; // Weak pointer.
DISALLOW_COPY_AND_ASSIGN(ObserverDelegate);
};
-DispatcherHost::ObserverDelegate::ObserverDelegate(Provider* provider,
- int process_id,
- int render_view_id)
+MessageFilter::ObserverDelegate::ObserverDelegate(Provider* provider,
+ int render_view_id,
+ IPC::Message::Sender* sender)
: provider_(provider),
- process_id_(process_id),
- render_view_id_(render_view_id) {
+ render_view_id_(render_view_id),
+ sender_(sender) {
provider_->AddObserver(this);
}
-DispatcherHost::ObserverDelegate::~ObserverDelegate() {
+MessageFilter::ObserverDelegate::~ObserverDelegate() {
provider_->RemoveObserver(this);
}
-void DispatcherHost::ObserverDelegate::OnOrientationUpdate(
+void MessageFilter::ObserverDelegate::OnOrientationUpdate(
const Orientation& orientation) {
ViewMsg_DeviceOrientationUpdated_Params params;
params.can_provide_alpha = orientation.can_provide_alpha_;
@@ -72,17 +69,14 @@ void DispatcherHost::ObserverDelegate::OnOrientationUpdate(
params.can_provide_gamma = orientation.can_provide_gamma_;
params.gamma = orientation.gamma_;
- IPC::Message* message = new ViewMsg_DeviceOrientationUpdated(render_view_id_,
- params);
- CallRenderViewHost(process_id_, render_view_id_, &RenderViewHost::Send,
- message);
+ sender_->Send(new ViewMsg_DeviceOrientationUpdated(render_view_id_, params));
}
-bool DispatcherHost::OnMessageReceived(const IPC::Message& msg,
- bool* msg_was_ok) {
+bool MessageFilter::OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
bool handled = true;
- IPC_BEGIN_MESSAGE_MAP_EX(DispatcherHost, msg, *msg_was_ok)
+ IPC_BEGIN_MESSAGE_MAP_EX(MessageFilter, message, *message_was_ok)
IPC_MESSAGE_HANDLER(ViewHostMsg_DeviceOrientation_StartUpdating,
OnStartUpdating)
IPC_MESSAGE_HANDLER(ViewHostMsg_DeviceOrientation_StopUpdating,
@@ -92,18 +86,18 @@ bool DispatcherHost::OnMessageReceived(const IPC::Message& msg,
return handled;
}
-void DispatcherHost::OnStartUpdating(int render_view_id) {
+void MessageFilter::OnStartUpdating(int render_view_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (!provider_)
provider_ = Provider::GetInstance();
observers_map_[render_view_id] = new ObserverDelegate(provider_,
- process_id_,
- render_view_id);
+ render_view_id,
+ this);
}
-void DispatcherHost::OnStopUpdating(int render_view_id) {
+void MessageFilter::OnStopUpdating(int render_view_id) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
observers_map_.erase(render_view_id);
diff --git a/chrome/browser/device_orientation/dispatcher_host.h b/chrome/browser/device_orientation/message_filter.h
index d30e8201..468fe6f 100644
--- a/chrome/browser/device_orientation/dispatcher_host.h
+++ b/chrome/browser/device_orientation/message_filter.h
@@ -2,28 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_DEVICE_ORIENTATION_DISPATCHER_HOST_H_
-#define CHROME_BROWSER_DEVICE_ORIENTATION_DISPATCHER_HOST_H_
+#ifndef CHROME_BROWSER_DEVICE_ORIENTATION_MESSAGE_FILTER_H_
+#define CHROME_BROWSER_DEVICE_ORIENTATION_MESSAGE_FILTER_H_
#include <map>
-#include "base/ref_counted.h"
+#include "chrome/browser/browser_message_filter.h"
#include "chrome/browser/device_orientation/provider.h"
-namespace IPC { class Message; }
-
namespace device_orientation {
class Orientation;
-class DispatcherHost : public base::RefCounted<DispatcherHost> {
+class MessageFilter : public BrowserMessageFilter {
public:
- explicit DispatcherHost(int process_id);
- bool OnMessageReceived(const IPC::Message& msg, bool* msg_was_ok);
+ MessageFilter();
+
+ // BrowserMessageFilter implementation.
+ virtual bool OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok);
private:
- virtual ~DispatcherHost();
- friend class base::RefCounted<DispatcherHost>;
+ virtual ~MessageFilter();
void OnStartUpdating(int render_view_id);
void OnStopUpdating(int render_view_id);
@@ -31,16 +31,14 @@ class DispatcherHost : public base::RefCounted<DispatcherHost> {
// Helper class that observes a Provider and forwards updates to a RenderView.
class ObserverDelegate;
- int process_id_;
-
// map from render_view_id to ObserverDelegate.
std::map<int, scoped_refptr<ObserverDelegate> > observers_map_;
scoped_refptr<Provider> provider_;
- DISALLOW_COPY_AND_ASSIGN(DispatcherHost);
+ DISALLOW_COPY_AND_ASSIGN(MessageFilter);
};
} // namespace device_orientation
-#endif // CHROME_BROWSER_DEVICE_ORIENTATION_DISPATCHER_HOST_H_
+#endif // CHROME_BROWSER_DEVICE_ORIENTATION_MESSAGE_FILTER_H_
diff --git a/chrome/browser/file_system/file_system_dispatcher_host.cc b/chrome/browser/file_system/file_system_dispatcher_host.cc
index 64b4801..fe2504d 100644
--- a/chrome/browser/file_system/file_system_dispatcher_host.cc
+++ b/chrome/browser/file_system/file_system_dispatcher_host.cc
@@ -10,7 +10,6 @@
#include "base/file_path.h"
#include "base/thread.h"
#include "base/time.h"
-#include "chrome/browser/browser_thread.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/file_system/browser_file_system_context.h"
#include "chrome/browser/net/chrome_url_request_context.h"
@@ -82,37 +81,25 @@ class BrowserFileSystemCallbackDispatcher
int request_id_;
};
-FileSystemDispatcherHost::FileSystemDispatcherHost(
- IPC::Message::Sender* sender, Profile* profile)
- : message_sender_(sender),
- process_handle_(0),
- shutdown_(false),
- context_(profile->GetFileSystemContext()),
+FileSystemDispatcherHost::FileSystemDispatcherHost(Profile* profile)
+ : context_(profile->GetFileSystemContext()),
host_content_settings_map_(profile->GetHostContentSettingsMap()),
request_context_getter_(profile->GetRequestContext()) {
- DCHECK(message_sender_);
}
FileSystemDispatcherHost::FileSystemDispatcherHost(
- IPC::Message::Sender* sender, ChromeURLRequestContext* context)
- : message_sender_(sender),
- process_handle_(0),
- shutdown_(false),
- context_(context->browser_file_system_context()),
+ ChromeURLRequestContext* context)
+ : context_(context->browser_file_system_context()),
host_content_settings_map_(context->host_content_settings_map()),
request_context_(context) {
- DCHECK(message_sender_);
}
FileSystemDispatcherHost::~FileSystemDispatcherHost() {
}
-void FileSystemDispatcherHost::Init(base::ProcessHandle process_handle) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- DCHECK(!shutdown_);
- DCHECK(!process_handle_);
- DCHECK(process_handle);
- process_handle_ = process_handle;
+void FileSystemDispatcherHost::OnChannelConnected(int32 peer_pid) {
+ BrowserMessageFilter::OnChannelConnected(peer_pid);
+
if (request_context_getter_.get()) {
DCHECK(!request_context_.get());
request_context_ = request_context_getter_->GetURLRequestContext();
@@ -120,14 +107,8 @@ void FileSystemDispatcherHost::Init(base::ProcessHandle process_handle) {
DCHECK(request_context_.get());
}
-void FileSystemDispatcherHost::Shutdown() {
- message_sender_ = NULL;
- shutdown_ = true;
-}
-
bool FileSystemDispatcherHost::OnMessageReceived(
const IPC::Message& message, bool* message_was_ok) {
- DCHECK(!shutdown_);
*message_was_ok = true;
bool handled = true;
IPC_BEGIN_MESSAGE_MAP_EX(FileSystemDispatcherHost, message, *message_was_ok)
@@ -251,14 +232,6 @@ void FileSystemDispatcherHost::OnCancel(
}
}
-void FileSystemDispatcherHost::Send(IPC::Message* message) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- if (!shutdown_ && message_sender_)
- message_sender_->Send(message);
- else
- delete message;
-}
-
SandboxedFileSystemOperation* FileSystemDispatcherHost::GetNewOperation(
int request_id) {
BrowserFileSystemCallbackDispatcher* dispatcher =
diff --git a/chrome/browser/file_system/file_system_dispatcher_host.h b/chrome/browser/file_system/file_system_dispatcher_host.h
index fdbe8f6..b7f50ed 100644
--- a/chrome/browser/file_system/file_system_dispatcher_host.h
+++ b/chrome/browser/file_system/file_system_dispatcher_host.h
@@ -9,9 +9,7 @@
#include "base/basictypes.h"
#include "base/id_map.h"
-#include "base/process.h"
-#include "base/ref_counted.h"
-#include "ipc/ipc_message.h"
+#include "chrome/browser/browser_message_filter.h"
#include "webkit/fileapi/file_system_types.h"
namespace base {
@@ -33,20 +31,19 @@ namespace fileapi {
class SandboxedFileSystemOperation;
}
-class FileSystemDispatcherHost
- : public base::RefCountedThreadSafe<FileSystemDispatcherHost> {
+class FileSystemDispatcherHost : public BrowserMessageFilter {
public:
// Used by the renderer.
- FileSystemDispatcherHost(IPC::Message::Sender* sender,
- Profile* profile);
+ explicit FileSystemDispatcherHost(Profile* profile);
// Used by the worker, since it has the context handy already.
- FileSystemDispatcherHost(IPC::Message::Sender* sender,
- ChromeURLRequestContext* context);
+ explicit FileSystemDispatcherHost(ChromeURLRequestContext* context);
~FileSystemDispatcherHost();
- void Init(base::ProcessHandle process_handle);
- void Shutdown();
- bool OnMessageReceived(const IPC::Message& message, bool* message_was_ok);
+ // BrowserMessageFilter implementation.
+ virtual void OnChannelConnected(int32 peer_pid);
+ virtual bool OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok);
+
void OnOpenFileSystem(int request_id,
const GURL& origin_url,
@@ -78,21 +75,12 @@ class FileSystemDispatcherHost
const base::Time& last_access_time,
const base::Time& last_modified_time);
void OnCancel(int request_id, int request_to_cancel);
- void Send(IPC::Message* message);
void UnregisterOperation(int request_id);
private:
// Creates a new SandboxedFileSystemOperation.
fileapi::SandboxedFileSystemOperation* GetNewOperation(int request_id);
- // The sender to be used for sending out IPC messages.
- IPC::Message::Sender* message_sender_;
-
- // The handle of this process.
- base::ProcessHandle process_handle_;
-
- bool shutdown_;
-
scoped_refptr<BrowserFileSystemContext> context_;
// Used to look up permissions.
diff --git a/chrome/browser/mime_registry_dispatcher.cc b/chrome/browser/mime_registry_dispatcher.cc
deleted file mode 100644
index bc8653f..0000000
--- a/chrome/browser/mime_registry_dispatcher.cc
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/mime_registry_dispatcher.h"
-
-#include "chrome/browser/browser_thread.h"
-#include "chrome/common/render_messages.h"
-#include "net/base/mime_util.h"
-
-MimeRegistryDispatcher::MimeRegistryDispatcher(IPC::Message::Sender* sender)
- : message_sender_(sender) {
- DCHECK(message_sender_);
-}
-
-MimeRegistryDispatcher::~MimeRegistryDispatcher() {
-}
-
-void MimeRegistryDispatcher::Shutdown() {
- message_sender_ = NULL;
-}
-
-bool MimeRegistryDispatcher::OnMessageReceived(const IPC::Message& message) {
- // On Windows MIME registry requests may access the Windows Registry so
- // they need to run on the FILE thread.
- if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) {
- // Return false if the message is not for us.
- if (message.type() != ViewHostMsg_GetMimeTypeFromExtension::ID &&
- message.type() != ViewHostMsg_GetMimeTypeFromFile::ID &&
- message.type() != ViewHostMsg_GetPreferredExtensionForMimeType::ID)
- return false;
-
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(
- this, &MimeRegistryDispatcher::OnMessageReceived, message));
- return true;
- }
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
-
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(MimeRegistryDispatcher, message)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetMimeTypeFromExtension,
- OnGetMimeTypeFromExtension)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetMimeTypeFromFile,
- OnGetMimeTypeFromFile)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(
- ViewHostMsg_GetPreferredExtensionForMimeType,
- OnGetPreferredExtensionForMimeType)
- IPC_MESSAGE_UNHANDLED((handled = false))
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
-void MimeRegistryDispatcher::OnGetMimeTypeFromExtension(
- const FilePath::StringType& ext, IPC::Message* reply_msg) {
- std::string mime_type;
- net::GetMimeTypeFromExtension(ext, &mime_type);
- ViewHostMsg_GetMimeTypeFromExtension::WriteReplyParams(reply_msg, mime_type);
- Send(reply_msg);
-}
-
-void MimeRegistryDispatcher::OnGetMimeTypeFromFile(
- const FilePath& file_path, IPC::Message* reply_msg) {
- std::string mime_type;
- net::GetMimeTypeFromFile(file_path, &mime_type);
- ViewHostMsg_GetMimeTypeFromFile::WriteReplyParams(reply_msg, mime_type);
- Send(reply_msg);
-}
-
-void MimeRegistryDispatcher::OnGetPreferredExtensionForMimeType(
- const std::string& mime_type, IPC::Message* reply_msg) {
- FilePath::StringType ext;
- net::GetPreferredExtensionForMimeType(mime_type, &ext);
- ViewHostMsg_GetPreferredExtensionForMimeType::WriteReplyParams(
- reply_msg, ext);
- Send(reply_msg);
-}
-
-void MimeRegistryDispatcher::Send(IPC::Message* message) {
- if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
- if (!BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE, NewRunnableMethod(
- this, &MimeRegistryDispatcher::Send, message))) {
- // The IO thread is dead.
- delete message;
- }
- return;
- }
-
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- if (message_sender_)
- message_sender_->Send(message);
- else
- delete message;
-}
diff --git a/chrome/browser/mime_registry_dispatcher.h b/chrome/browser/mime_registry_dispatcher.h
deleted file mode 100644
index 0bd17dd..0000000
--- a/chrome/browser/mime_registry_dispatcher.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_MIME_REGISTRY_DISPATCHER_H_
-#define CHROME_BROWSER_MIME_REGISTRY_DISPATCHER_H_
-
-#include "base/file_path.h"
-#include "base/ref_counted.h"
-#include "ipc/ipc_message.h"
-
-class MimeRegistryDispatcher
- : public base::RefCountedThreadSafe<MimeRegistryDispatcher> {
- public:
- explicit MimeRegistryDispatcher(IPC::Message::Sender* sender);
- void Shutdown();
- bool OnMessageReceived(const IPC::Message& message);
- void Send(IPC::Message* message);
-
- private:
- friend class base::RefCountedThreadSafe<MimeRegistryDispatcher>;
- ~MimeRegistryDispatcher();
-
- void OnGetMimeTypeFromExtension(const FilePath::StringType& ext,
- IPC::Message* reply);
- void OnGetMimeTypeFromFile(const FilePath& file_path,
- IPC::Message* reply);
- void OnGetPreferredExtensionForMimeType(const std::string& mime_type,
- IPC::Message* reply);
-
- // The sender to be used for sending out IPC messages.
- IPC::Message::Sender* message_sender_;
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(MimeRegistryDispatcher);
-};
-
-#endif // CHROME_BROWSER_MIME_REGISTRY_DISPATCHER_H_
diff --git a/chrome/browser/mime_registry_message_filter.cc b/chrome/browser/mime_registry_message_filter.cc
new file mode 100644
index 0000000..c57cad3
--- /dev/null
+++ b/chrome/browser/mime_registry_message_filter.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/mime_registry_message_filter.h"
+
+#include "chrome/common/mime_registry_messages.h"
+#include "net/base/mime_util.h"
+
+MimeRegistryMessageFilter::MimeRegistryMessageFilter() {
+}
+
+MimeRegistryMessageFilter::~MimeRegistryMessageFilter() {
+}
+
+void MimeRegistryMessageFilter::OverrideThreadForMessage(
+ const IPC::Message& message,
+ BrowserThread::ID* thread) {
+ if (IPC_MESSAGE_CLASS(message) == MimeRegistryMsgStart)
+ *thread = BrowserThread::FILE;
+}
+
+bool MimeRegistryMessageFilter::OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP_EX(MimeRegistryMessageFilter, message, *message_was_ok)
+ IPC_MESSAGE_HANDLER(MimeRegistryMsg_GetMimeTypeFromExtension,
+ OnGetMimeTypeFromExtension)
+ IPC_MESSAGE_HANDLER(MimeRegistryMsg_GetMimeTypeFromFile,
+ OnGetMimeTypeFromFile)
+ IPC_MESSAGE_HANDLER(MimeRegistryMsg_GetPreferredExtensionForMimeType,
+ OnGetPreferredExtensionForMimeType)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void MimeRegistryMessageFilter::OnGetMimeTypeFromExtension(
+ const FilePath::StringType& ext, std::string* mime_type) {
+ net::GetMimeTypeFromExtension(ext, mime_type);
+}
+
+void MimeRegistryMessageFilter::OnGetMimeTypeFromFile(
+ const FilePath& file_path, std::string* mime_type) {
+ net::GetMimeTypeFromFile(file_path, mime_type);
+}
+
+void MimeRegistryMessageFilter::OnGetPreferredExtensionForMimeType(
+ const std::string& mime_type, FilePath::StringType* extension) {
+ net::GetPreferredExtensionForMimeType(mime_type, extension);
+}
diff --git a/chrome/browser/mime_registry_message_filter.h b/chrome/browser/mime_registry_message_filter.h
new file mode 100644
index 0000000..71348e5
--- /dev/null
+++ b/chrome/browser/mime_registry_message_filter.h
@@ -0,0 +1,31 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_MIME_REGISTRY_MESSAGE_FILTER_H_
+#define CHROME_BROWSER_MIME_REGISTRY_MESSAGE_FILTER_H_
+
+#include "base/file_path.h"
+#include "chrome/browser/browser_message_filter.h"
+
+class MimeRegistryMessageFilter : public BrowserMessageFilter {
+ public:
+ MimeRegistryMessageFilter();
+
+ virtual void OverrideThreadForMessage(const IPC::Message& message,
+ BrowserThread::ID* thread);
+ virtual bool OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok);
+
+ private:
+ ~MimeRegistryMessageFilter();
+
+ void OnGetMimeTypeFromExtension(const FilePath::StringType& ext,
+ std::string* mime_type);
+ void OnGetMimeTypeFromFile(const FilePath& file_path,
+ std::string* mime_type);
+ void OnGetPreferredExtensionForMimeType(const std::string& mime_type,
+ FilePath::StringType* extension);
+};
+
+#endif // CHROME_BROWSER_MIME_REGISTRY_MESSAGE_FILTER_H_
diff --git a/chrome/browser/renderer_host/blob_dispatcher_host.cc b/chrome/browser/renderer_host/blob_message_filter.cc
index 1946b68..d31d5f7 100644
--- a/chrome/browser/renderer_host/blob_dispatcher_host.cc
+++ b/chrome/browser/renderer_host/blob_message_filter.cc
@@ -2,29 +2,27 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/renderer_host/blob_dispatcher_host.h"
+#include "chrome/browser/renderer_host/blob_message_filter.h"
-#include "chrome/browser/browser_thread.h"
#include "chrome/browser/child_process_security_policy.h"
#include "chrome/browser/chrome_blob_storage_context.h"
#include "chrome/common/render_messages.h"
#include "googleurl/src/gurl.h"
-#include "ipc/ipc_message.h"
#include "webkit/blob/blob_data.h"
#include "webkit/blob/blob_storage_controller.h"
-BlobDispatcherHost::BlobDispatcherHost(
+BlobMessageFilter::BlobMessageFilter(
int process_id,
ChromeBlobStorageContext* blob_storage_context)
: process_id_(process_id),
blob_storage_context_(blob_storage_context) {
}
-BlobDispatcherHost::~BlobDispatcherHost() {
+BlobMessageFilter::~BlobMessageFilter() {
}
-void BlobDispatcherHost::Shutdown() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+void BlobMessageFilter::OnChannelClosing() {
+ BrowserMessageFilter::OnChannelClosing();
// Unregister all the blob URLs that are previously registered in this
// process.
@@ -34,13 +32,12 @@ void BlobDispatcherHost::Shutdown() {
}
}
-bool BlobDispatcherHost::OnMessageReceived(const IPC::Message& message,
- bool* msg_is_ok) {
+bool BlobMessageFilter::OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- *msg_is_ok = true;
bool handled = true;
- IPC_BEGIN_MESSAGE_MAP_EX(BlobDispatcherHost, message, *msg_is_ok)
+ IPC_BEGIN_MESSAGE_MAP_EX(BlobMessageFilter, message, *message_was_ok)
IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterBlobUrl, OnRegisterBlobUrl)
IPC_MESSAGE_HANDLER(ViewHostMsg_RegisterBlobUrlFrom, OnRegisterBlobUrlFrom)
IPC_MESSAGE_HANDLER(ViewHostMsg_UnregisterBlobUrl, OnUnregisterBlobUrl)
@@ -50,7 +47,7 @@ bool BlobDispatcherHost::OnMessageReceived(const IPC::Message& message,
}
// Check if the child process has been granted permission to register the files.
-bool BlobDispatcherHost::CheckPermission(
+bool BlobMessageFilter::CheckPermission(
webkit_blob::BlobData* blob_data) const {
ChildProcessSecurityPolicy* policy =
ChildProcessSecurityPolicy::GetInstance();
@@ -65,7 +62,7 @@ bool BlobDispatcherHost::CheckPermission(
return true;
}
-void BlobDispatcherHost::OnRegisterBlobUrl(
+void BlobMessageFilter::OnRegisterBlobUrl(
const GURL& url, const scoped_refptr<webkit_blob::BlobData>& blob_data) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (!CheckPermission(blob_data.get()))
@@ -74,14 +71,14 @@ void BlobDispatcherHost::OnRegisterBlobUrl(
blob_urls_.insert(url.spec());
}
-void BlobDispatcherHost::OnRegisterBlobUrlFrom(
+void BlobMessageFilter::OnRegisterBlobUrlFrom(
const GURL& url, const GURL& src_url) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
blob_storage_context_->controller()->RegisterBlobUrlFrom(url, src_url);
blob_urls_.insert(url.spec());
}
-void BlobDispatcherHost::OnUnregisterBlobUrl(const GURL& url) {
+void BlobMessageFilter::OnUnregisterBlobUrl(const GURL& url) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
blob_storage_context_->controller()->UnregisterBlobUrl(url);
blob_urls_.erase(url.spec());
diff --git a/chrome/browser/renderer_host/blob_dispatcher_host.h b/chrome/browser/renderer_host/blob_message_filter.h
index 8ba95ff..2809763 100644
--- a/chrome/browser/renderer_host/blob_dispatcher_host.h
+++ b/chrome/browser/renderer_host/blob_message_filter.h
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_RENDERER_HOST_BLOB_DISPATCHER_HOST_H_
-#define CHROME_BROWSER_RENDERER_HOST_BLOB_DISPATCHER_HOST_H_
+#ifndef CHROME_BROWSER_RENDERER_HOST_BLOB_MESSAGE_FILTER_H_
+#define CHROME_BROWSER_RENDERER_HOST_BLOB_MESSAGE_FILTER_H_
#include "base/hash_tables.h"
-#include "base/ref_counted.h"
+#include "chrome/browser/browser_message_filter.h"
class ChromeBlobStorageContext;
class GURL;
@@ -19,14 +19,16 @@ namespace webkit_blob {
class BlobData;
}
-class BlobDispatcherHost {
+class BlobMessageFilter : public BrowserMessageFilter {
public:
- BlobDispatcherHost(int process_id,
- ChromeBlobStorageContext* blob_storage_context);
- ~BlobDispatcherHost();
+ BlobMessageFilter(int process_id,
+ ChromeBlobStorageContext* blob_storage_context);
+ ~BlobMessageFilter();
- void Shutdown();
- bool OnMessageReceived(const IPC::Message& message, bool* msg_is_ok);
+ // BrowserMessageFilter implementation.
+ virtual void OnChannelClosing();
+ virtual bool OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok);
private:
void OnRegisterBlobUrl(const GURL& url,
@@ -43,7 +45,7 @@ class BlobDispatcherHost {
// all of them when the renderer process dies.
base::hash_set<std::string> blob_urls_;
- DISALLOW_IMPLICIT_CONSTRUCTORS(BlobDispatcherHost);
+ DISALLOW_IMPLICIT_CONSTRUCTORS(BlobMessageFilter);
};
-#endif // CHROME_BROWSER_RENDERER_HOST_BLOB_DISPATCHER_HOST_H_
+#endif // CHROME_BROWSER_RENDERER_HOST_BLOB_MESSAGE_FILTER_H_
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index 7e85058..3a46d65 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -30,18 +30,23 @@
#include "chrome/browser/browser_child_process_host.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/child_process_security_policy.h"
+#include "chrome/browser/device_orientation/message_filter.h"
#include "chrome/browser/extensions/extension_event_router.h"
#include "chrome/browser/extensions/extension_function_dispatcher.h"
#include "chrome/browser/extensions/extension_message_service.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/extensions/user_script_master.h"
+#include "chrome/browser/file_system/file_system_dispatcher_host.h"
#include "chrome/browser/gpu_process_host.h"
#include "chrome/browser/history/history.h"
#include "chrome/browser/io_thread.h"
+#include "chrome/browser/mime_registry_message_filter.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/plugin_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_host/audio_renderer_host.h"
+#include "chrome/browser/renderer_host/blob_message_filter.h"
+#include "chrome/browser/renderer_host/file_utilities_message_filter.h"
#include "chrome/browser/renderer_host/pepper_file_message_filter.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_view_host_delegate.h"
@@ -50,6 +55,8 @@
#include "chrome/browser/renderer_host/resource_message_filter.h"
#include "chrome/browser/renderer_host/web_cache_manager.h"
#include "chrome/browser/safe_browsing/client_side_detection_service.h"
+#include "chrome/browser/search_engines/search_provider_install_state_message_filter.h"
+#include "chrome/browser/speech/speech_input_dispatcher_host.h"
#include "chrome/browser/spellcheck_host.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/visitedlink/visitedlink_master.h"
@@ -389,6 +396,15 @@ void BrowserRenderProcessHost::CreateMessageFilters() {
channel_->AddFilter(
new AppCacheDispatcherHost(profile()->GetRequestContext(), id()));
channel_->AddFilter(new PepperFileMessageFilter(id(), profile()));
+ channel_->AddFilter(new speech_input::SpeechInputDispatcherHost(id()));
+ channel_->AddFilter(
+ new SearchProviderInstallStateMessageFilter(id(), profile()));
+ channel_->AddFilter(new FileSystemDispatcherHost(profile()));
+ channel_->AddFilter(new device_orientation::MessageFilter());
+ channel_->AddFilter(
+ new BlobMessageFilter(id(), profile()->GetBlobStorageContext()));
+ channel_->AddFilter(new FileUtilitiesMessageFilter(id()));
+ channel_->AddFilter(new MimeRegistryMessageFilter());
}
int BrowserRenderProcessHost::GetNextRoutingID() {
diff --git a/chrome/browser/renderer_host/file_utilities_dispatcher_host.cc b/chrome/browser/renderer_host/file_utilities_dispatcher_host.cc
deleted file mode 100644
index ad6fe97..0000000
--- a/chrome/browser/renderer_host/file_utilities_dispatcher_host.cc
+++ /dev/null
@@ -1,199 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/renderer_host/file_utilities_dispatcher_host.h"
-
-#include "base/file_util.h"
-#include "base/platform_file.h"
-#include "chrome/browser/child_process_security_policy.h"
-#include "chrome/browser/browser_thread.h"
-#include "chrome/common/render_messages.h"
-#include "chrome/common/render_messages_params.h"
-
-namespace {
-
-void WriteFileSize(IPC::Message* reply_msg,
- const base::PlatformFileInfo& file_info) {
- ViewHostMsg_GetFileSize::WriteReplyParams(reply_msg, file_info.size);
-}
-
-void WriteFileModificationTime(IPC::Message* reply_msg,
- const base::PlatformFileInfo& file_info) {
- ViewHostMsg_GetFileModificationTime::WriteReplyParams(
- reply_msg, file_info.last_modified);
-}
-
-} // namespace
-
-FileUtilitiesDispatcherHost::FileUtilitiesDispatcherHost(
- IPC::Message::Sender* sender, int process_id)
- : message_sender_(sender),
- process_id_(process_id),
- process_handle_(0),
- shutdown_(false) {
- DCHECK(message_sender_);
-}
-
-FileUtilitiesDispatcherHost::~FileUtilitiesDispatcherHost() {
-}
-
-void FileUtilitiesDispatcherHost::Init(base::ProcessHandle process_handle) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- DCHECK(!shutdown_);
- DCHECK(!process_handle_);
- DCHECK(process_handle);
- process_handle_ = process_handle;
-}
-
-void FileUtilitiesDispatcherHost::Shutdown() {
- message_sender_ = NULL;
- shutdown_ = true;
-}
-
-bool FileUtilitiesDispatcherHost::OnMessageReceived(
- const IPC::Message& message) {
- DCHECK(!shutdown_);
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(FileUtilitiesDispatcherHost, message)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetFileSize, OnGetFileSize)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetFileModificationTime,
- OnGetFileModificationTime)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenFile, OnOpenFile)
- IPC_MESSAGE_UNHANDLED((handled = false))
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
-void FileUtilitiesDispatcherHost::OnGetFileSize(
- const FilePath& path, IPC::Message* reply_msg) {
- // Get file size only when the child process has been granted permission to
- // upload the file.
- if (!ChildProcessSecurityPolicy::GetInstance()->CanReadFile(
- process_id_, path)) {
- ViewHostMsg_GetFileSize::WriteReplyParams(
- reply_msg, static_cast<int64>(-1));
- Send(reply_msg);
- return;
- }
-
- // Getting file size could take long time if it lives on a network share,
- // so run it on FILE thread.
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(
- this, &FileUtilitiesDispatcherHost::OnGetFileInfoOnFileThread, path,
- reply_msg, &WriteFileSize));
-}
-
-void FileUtilitiesDispatcherHost::OnGetFileModificationTime(
- const FilePath& path, IPC::Message* reply_msg) {
- // Get file modification time only when the child process has been granted
- // permission to upload the file.
- if (!ChildProcessSecurityPolicy::GetInstance()->CanReadFile(
- process_id_, path)) {
- ViewHostMsg_GetFileModificationTime::WriteReplyParams(reply_msg,
- base::Time());
- Send(reply_msg);
- return;
- }
-
- // Getting file modification time could take a long time if it lives on a
- // network share, so run it on the FILE thread.
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(
- this, &FileUtilitiesDispatcherHost::OnGetFileInfoOnFileThread,
- path, reply_msg, &WriteFileModificationTime));
-}
-
-void FileUtilitiesDispatcherHost::OnGetFileInfoOnFileThread(
- const FilePath& path,
- IPC::Message* reply_msg,
- FileInfoWriteFunc write_func) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
-
- base::PlatformFileInfo file_info;
- file_info.size = 0;
- file_util::GetFileInfo(path, &file_info);
-
- (*write_func)(reply_msg, file_info);
-
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(this, &FileUtilitiesDispatcherHost::Send, reply_msg));
-}
-
-void FileUtilitiesDispatcherHost::OnOpenFile(
- const FilePath& path, int mode, IPC::Message* reply_msg) {
- // Open the file only when the child process has been granted permission to
- // upload the file.
- // TODO(jianli): Do we need separate permission to control opening the file?
- if (!ChildProcessSecurityPolicy::GetInstance()->CanReadFile(
- process_id_, path)) {
- ViewHostMsg_OpenFile::WriteReplyParams(
- reply_msg,
-#if defined(OS_WIN)
- base::kInvalidPlatformFileValue
-#elif defined(OS_POSIX)
- base::FileDescriptor(base::kInvalidPlatformFileValue, true)
-#endif
- );
- Send(reply_msg);
- return;
- }
-
- // Opening the file could take a long time if it lives on a network share,
- // so run it on the FILE thread.
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(
- this, &FileUtilitiesDispatcherHost::OnOpenFileOnFileThread,
- path, mode, reply_msg));
-}
-
-void FileUtilitiesDispatcherHost::OnOpenFileOnFileThread(
- const FilePath& path, int mode, IPC::Message* reply_msg) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
-
- base::PlatformFile file_handle = base::CreatePlatformFile(
- path,
- (mode == 0) ? (base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ)
- : (base::PLATFORM_FILE_CREATE_ALWAYS |
- base::PLATFORM_FILE_WRITE),
- NULL, NULL);
-
- base::PlatformFile target_file_handle;
-#if defined(OS_WIN)
- // Duplicate the file handle so that the renderer process can access the file.
- if (!DuplicateHandle(GetCurrentProcess(), file_handle,
- process_handle_, &target_file_handle, 0, false,
- DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) {
- // file_handle is closed whether or not DuplicateHandle succeeds.
- target_file_handle = INVALID_HANDLE_VALUE;
- }
-#else
- target_file_handle = file_handle;
-#endif
-
- ViewHostMsg_OpenFile::WriteReplyParams(
- reply_msg,
-#if defined(OS_WIN)
- target_file_handle
-#elif defined(OS_POSIX)
- base::FileDescriptor(target_file_handle, true)
-#endif
- );
-
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(this, &FileUtilitiesDispatcherHost::Send, reply_msg));
-}
-
-void FileUtilitiesDispatcherHost::Send(IPC::Message* message) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- if (!shutdown_ && message_sender_)
- message_sender_->Send(message);
- else
- delete message;
-}
diff --git a/chrome/browser/renderer_host/file_utilities_dispatcher_host.h b/chrome/browser/renderer_host/file_utilities_dispatcher_host.h
deleted file mode 100644
index b62aff5..0000000
--- a/chrome/browser/renderer_host/file_utilities_dispatcher_host.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_RENDERER_HOST_FILE_UTILITIES_DISPATCHER_HOST_H_
-#define CHROME_BROWSER_RENDERER_HOST_FILE_UTILITIES_DISPATCHER_HOST_H_
-
-#include "base/basictypes.h"
-#include "base/file_path.h"
-#include "base/process.h"
-#include "base/ref_counted.h"
-#include "ipc/ipc_message.h"
-
-namespace base {
-struct PlatformFileInfo;
-}
-
-namespace IPC {
-class Message;
-}
-
-class FileUtilitiesDispatcherHost
- : public base::RefCountedThreadSafe<FileUtilitiesDispatcherHost> {
- public:
- FileUtilitiesDispatcherHost(IPC::Message::Sender* sender, int process_id);
- void Init(base::ProcessHandle process_handle);
- void Shutdown();
- bool OnMessageReceived(const IPC::Message& message);
-
- void Send(IPC::Message* message);
-
- private:
- friend class base::RefCountedThreadSafe<FileUtilitiesDispatcherHost>;
- ~FileUtilitiesDispatcherHost();
-
- typedef void (*FileInfoWriteFunc)(IPC::Message* reply_msg,
- const base::PlatformFileInfo& file_info);
-
- void OnGetFileSize(const FilePath& path, IPC::Message* reply_msg);
- void OnGetFileModificationTime(const FilePath& path, IPC::Message* reply_msg);
- void OnGetFileInfoOnFileThread(const FilePath& path,
- IPC::Message* reply_msg,
- FileInfoWriteFunc write_func);
- void OnOpenFile(const FilePath& path, int mode,IPC::Message* reply_msg);
- void OnOpenFileOnFileThread(const FilePath& path,
- int mode,
- IPC::Message* reply_msg);
-
- // The sender to be used for sending out IPC messages.
- IPC::Message::Sender* message_sender_;
-
- // The ID of this process.
- int process_id_;
-
- // The handle of this process.
- base::ProcessHandle process_handle_;
-
- bool shutdown_;
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(FileUtilitiesDispatcherHost);
-};
-
-#endif // CHROME_BROWSER_RENDERER_HOST_FILE_UTILITIES_DISPATCHER_HOST_H_
diff --git a/chrome/browser/renderer_host/file_utilities_message_filter.cc b/chrome/browser/renderer_host/file_utilities_message_filter.cc
new file mode 100644
index 0000000..f49c634
--- /dev/null
+++ b/chrome/browser/renderer_host/file_utilities_message_filter.cc
@@ -0,0 +1,106 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/renderer_host/file_utilities_message_filter.h"
+
+#include "base/file_util.h"
+#include "chrome/browser/child_process_security_policy.h"
+#include "chrome/common/file_utilities_messages.h"
+
+
+FileUtilitiesMessageFilter::FileUtilitiesMessageFilter(int process_id)
+ : process_id_(process_id) {
+}
+
+FileUtilitiesMessageFilter::~FileUtilitiesMessageFilter() {
+}
+
+void FileUtilitiesMessageFilter::OverrideThreadForMessage(
+ const IPC::Message& message,
+ BrowserThread::ID* thread) {
+ if (IPC_MESSAGE_CLASS(message) == FileUtilitiesMsgStart)
+ *thread = BrowserThread::FILE;
+}
+
+bool FileUtilitiesMessageFilter::OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP_EX(FileUtilitiesMessageFilter, message, *message_was_ok)
+ IPC_MESSAGE_HANDLER(FileUtilitiesMsg_GetFileSize, OnGetFileSize)
+ IPC_MESSAGE_HANDLER(FileUtilitiesMsg_GetFileModificationTime,
+ OnGetFileModificationTime)
+ IPC_MESSAGE_HANDLER(FileUtilitiesMsg_OpenFile, OnOpenFile)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void FileUtilitiesMessageFilter::OnGetFileSize(const FilePath& path,
+ int64* result) {
+ // Get file size only when the child process has been granted permission to
+ // upload the file.
+ if (!ChildProcessSecurityPolicy::GetInstance()->CanReadFile(
+ process_id_, path)) {
+ *result = -1;
+ return;
+ }
+
+ base::PlatformFileInfo file_info;
+ file_info.size = 0;
+ file_util::GetFileInfo(path, &file_info);
+ *result = file_info.size;
+}
+
+void FileUtilitiesMessageFilter::OnGetFileModificationTime(
+ const FilePath& path, base::Time* result) {
+ // Get file modification time only when the child process has been granted
+ // permission to upload the file.
+ if (!ChildProcessSecurityPolicy::GetInstance()->CanReadFile(
+ process_id_, path)) {
+ *result = base::Time();
+ return;
+ }
+
+ base::PlatformFileInfo file_info;
+ file_info.size = 0;
+ file_util::GetFileInfo(path, &file_info);
+ *result = file_info.last_modified;
+}
+
+void FileUtilitiesMessageFilter::OnOpenFile(
+ const FilePath& path,
+ int mode,
+ IPC::PlatformFileForTransit* result) {
+ // Open the file only when the child process has been granted permission to
+ // upload the file.
+ // TODO(jianli): Do we need separate permission to control opening the file?
+ if (!ChildProcessSecurityPolicy::GetInstance()->CanReadFile(
+ process_id_, path)) {
+#if defined(OS_WIN)
+ *result = base::kInvalidPlatformFileValue;
+#elif defined(OS_POSIX)
+ *result = base::FileDescriptor(base::kInvalidPlatformFileValue, true);
+#endif
+ return;
+ }
+
+ base::PlatformFile file_handle = base::CreatePlatformFile(
+ path,
+ (mode == 0) ? (base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ)
+ : (base::PLATFORM_FILE_CREATE_ALWAYS |
+ base::PLATFORM_FILE_WRITE),
+ NULL, NULL);
+
+#if defined(OS_WIN)
+ // Duplicate the file handle so that the renderer process can access the file.
+ if (!DuplicateHandle(GetCurrentProcess(), file_handle,
+ peer_handle(), result, 0, false,
+ DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) {
+ // file_handle is closed whether or not DuplicateHandle succeeds.
+ *result = INVALID_HANDLE_VALUE;
+ }
+#else
+ *result = base::FileDescriptor(file_handle, true);
+#endif
+}
diff --git a/chrome/browser/renderer_host/file_utilities_message_filter.h b/chrome/browser/renderer_host/file_utilities_message_filter.h
new file mode 100644
index 0000000..9a1c9af
--- /dev/null
+++ b/chrome/browser/renderer_host/file_utilities_message_filter.h
@@ -0,0 +1,48 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_RENDERER_HOST_FILE_UTILITIES_MESSAGE_FILTER_H_
+#define CHROME_BROWSER_RENDERER_HOST_FILE_UTILITIES_MESSAGE_FILTER_H_
+
+#include "base/basictypes.h"
+#include "base/file_path.h"
+#include "chrome/browser/browser_message_filter.h"
+#include "ipc/ipc_platform_file.h"
+
+namespace base {
+struct PlatformFileInfo;
+}
+
+namespace IPC {
+class Message;
+}
+
+class FileUtilitiesMessageFilter : public BrowserMessageFilter {
+ public:
+ explicit FileUtilitiesMessageFilter(int process_id);
+
+ // BrowserMessageFilter implementation.
+ virtual void OverrideThreadForMessage(const IPC::Message& message,
+ BrowserThread::ID* thread);
+ virtual bool OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok);
+ private:
+ ~FileUtilitiesMessageFilter();
+
+ typedef void (*FileInfoWriteFunc)(IPC::Message* reply_msg,
+ const base::PlatformFileInfo& file_info);
+
+ void OnGetFileSize(const FilePath& path, int64* result);
+ void OnGetFileModificationTime(const FilePath& path, base::Time* result);
+ void OnOpenFile(const FilePath& path,
+ int mode,
+ IPC::PlatformFileForTransit* result);
+
+ // The ID of this process.
+ int process_id_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(FileUtilitiesMessageFilter);
+};
+
+#endif // CHROME_BROWSER_RENDERER_HOST_FILE_UTILITIES_MESSAGE_FILTER_H_
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index a745d91f..d762bfb 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -19,10 +19,8 @@
#include "chrome/browser/child_process_security_policy.h"
#include "chrome/browser/chrome_plugin_browsing_context.h"
#include "chrome/browser/clipboard_dispatcher.h"
-#include "chrome/browser/device_orientation/dispatcher_host.h"
#include "chrome/browser/download/download_types.h"
#include "chrome/browser/extensions/extension_message_service.h"
-#include "chrome/browser/file_system/file_system_dispatcher_host.h"
#include "chrome/browser/geolocation/geolocation_dispatcher_host_old.h"
#include "chrome/browser/geolocation/geolocation_permission_context.h"
#include "chrome/browser/gpu_process_host.h"
@@ -30,7 +28,6 @@
#include "chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h"
#include "chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h"
#include "chrome/browser/metrics/histogram_synchronizer.h"
-#include "chrome/browser/mime_registry_dispatcher.h"
#include "chrome/browser/nacl_host/nacl_process_host.h"
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/net/predictor_api.h"
@@ -43,15 +40,11 @@
#include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/printing/printer_query.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/renderer_host/blob_dispatcher_host.h"
#include "chrome/browser/renderer_host/browser_render_process_host.h"
#include "chrome/browser/renderer_host/database_dispatcher_host.h"
-#include "chrome/browser/renderer_host/file_utilities_dispatcher_host.h"
#include "chrome/browser/renderer_host/render_view_host_delegate.h"
#include "chrome/browser/renderer_host/render_view_host_notification_task.h"
#include "chrome/browser/renderer_host/render_widget_helper.h"
-#include "chrome/browser/search_engines/search_provider_install_state_dispatcher_host.h"
-#include "chrome/browser/speech/speech_input_dispatcher_host.h"
#include "chrome/browser/spellchecker_platform_engine.h"
#include "chrome/browser/task_manager/task_manager.h"
#include "chrome/browser/worker_host/message_port_dispatcher.h"
@@ -268,26 +261,9 @@ ResourceMessageFilter::ResourceMessageFilter(
off_the_record_(profile->IsOffTheRecord()),
next_route_id_callback_(NewCallbackWithReturnValue(
render_widget_helper, &RenderWidgetHelper::GetNextRoutingID)),
- ALLOW_THIS_IN_INITIALIZER_LIST(speech_input_dispatcher_host_(
- new speech_input::SpeechInputDispatcherHost(this->id()))),
ALLOW_THIS_IN_INITIALIZER_LIST(geolocation_dispatcher_host_(
GeolocationDispatcherHostOld::New(
- this->id(), profile->GetGeolocationPermissionContext()))),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- search_provider_install_state_dispatcher_host_(
- new SearchProviderInstallStateDispatcherHost(this, profile,
- child_id))),
- ALLOW_THIS_IN_INITIALIZER_LIST(device_orientation_dispatcher_host_(
- new device_orientation::DispatcherHost(this->id()))),
- ALLOW_THIS_IN_INITIALIZER_LIST(file_system_dispatcher_host_(
- new FileSystemDispatcherHost(this, profile))),
- ALLOW_THIS_IN_INITIALIZER_LIST(blob_dispatcher_host_(
- new BlobDispatcherHost(
- this->id(), profile->GetBlobStorageContext()))),
- ALLOW_THIS_IN_INITIALIZER_LIST(file_utilities_dispatcher_host_(
- new FileUtilitiesDispatcherHost(this, this->id()))),
- ALLOW_THIS_IN_INITIALIZER_LIST(mime_registry_dispatcher_(
- new MimeRegistryDispatcher(this))) {
+ this->id(), profile->GetGeolocationPermissionContext()))) {
request_context_ = profile_->GetRequestContext();
DCHECK(request_context_);
DCHECK(media_request_context_);
@@ -315,18 +291,6 @@ ResourceMessageFilter::~ResourceMessageFilter() {
// Shut down the database dispatcher host.
db_dispatcher_host_->Shutdown();
- // Shut down the async file_system dispatcher host.
- file_system_dispatcher_host_->Shutdown();
-
- // Shut down the blob dispatcher host.
- blob_dispatcher_host_->Shutdown();
-
- // Shut down the async file_utilities dispatcher host.
- file_utilities_dispatcher_host_->Shutdown();
-
- // Shut down the mime registry dispatcher host.
- mime_registry_dispatcher_->Shutdown();
-
// Let interested observers know we are being deleted.
NotificationService::current()->Notify(
NotificationType::RESOURCE_MESSAGE_FILTER_SHUTDOWN,
@@ -357,8 +321,6 @@ void ResourceMessageFilter::OnChannelConnected(int32 peer_pid) {
dom_storage_dispatcher_host_->Init(id(), handle());
indexed_db_dispatcher_host_->Init(id(), handle());
db_dispatcher_host_->Init(handle());
- file_system_dispatcher_host_->Init(handle());
- file_utilities_dispatcher_host_->Init(handle());
}
void ResourceMessageFilter::OnChannelError() {
@@ -388,15 +350,7 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) {
db_dispatcher_host_->OnMessageReceived(msg, &msg_is_ok) ||
mp_dispatcher->OnMessageReceived(
msg, this, next_route_id_callback(), &msg_is_ok) ||
- geolocation_dispatcher_host_->OnMessageReceived(msg, &msg_is_ok) ||
- speech_input_dispatcher_host_->OnMessageReceived(msg, &msg_is_ok) ||
- search_provider_install_state_dispatcher_host_->OnMessageReceived(
- msg, &msg_is_ok) ||
- device_orientation_dispatcher_host_->OnMessageReceived(msg, &msg_is_ok) ||
- file_system_dispatcher_host_->OnMessageReceived(msg, &msg_is_ok) ||
- blob_dispatcher_host_->OnMessageReceived(msg, &msg_is_ok) ||
- file_utilities_dispatcher_host_->OnMessageReceived(msg) ||
- mime_registry_dispatcher_->OnMessageReceived(msg);
+ geolocation_dispatcher_host_->OnMessageReceived(msg, &msg_is_ok) ;
if (!handled) {
DCHECK(msg_is_ok); // It should have been marked handled if it wasn't OK.
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index ce23137..9986262 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -31,22 +31,17 @@
#include "third_party/WebKit/WebKit/chromium/public/WebCache.h"
#include "third_party/WebKit/WebKit/chromium/public/WebPopupType.h"
-class BlobDispatcherHost;
class ChromeURLRequestContext;
class DatabaseDispatcherHost;
class DOMStorageDispatcherHost;
-class FileSystemDispatcherHost;
-class FileUtilitiesDispatcherHost;
struct FontDescriptor;
class GeolocationDispatcherHostOld;
class HostZoomMap;
class IndexedDBDispatcherHost;
-class MimeRegistryDispatcher;
class NotificationsPrefsCache;
class PpapiPluginProcessHost;
class Profile;
class RenderWidgetHelper;
-class SearchProviderInstallStateDispatcherHost;
class URLRequestContextGetter;
struct ViewHostMsg_CreateWindow_Params;
struct ViewHostMsg_CreateWorker_Params;
@@ -57,10 +52,6 @@ struct PlatformFileInfo;
class SharedMemory;
}
-namespace device_orientation {
-class DispatcherHost;
-}
-
namespace net {
class CookieStore;
}
@@ -70,10 +61,6 @@ class PrinterQuery;
class PrintJobManager;
}
-namespace speech_input {
-class SpeechInputDispatcherHost;
-}
-
namespace webkit_glue {
struct WebCookie;
}
@@ -473,33 +460,9 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
// A callback to create a routing id for the associated renderer process.
scoped_ptr<CallbackWithReturnValue<int>::Type> next_route_id_callback_;
- // Used to handle speech input related messages.
- scoped_refptr<speech_input::SpeechInputDispatcherHost>
- speech_input_dispatcher_host_;
-
// Used to handle geolocation-related messages.
scoped_refptr<GeolocationDispatcherHostOld> geolocation_dispatcher_host_;
- // Used to handle search provider related messages.
- scoped_ptr<SearchProviderInstallStateDispatcherHost>
- search_provider_install_state_dispatcher_host_;
-
- // Used to handle device orientation related messages.
- scoped_refptr<device_orientation::DispatcherHost>
- device_orientation_dispatcher_host_;
-
- // Handles FileSystem API related messages
- scoped_refptr<FileSystemDispatcherHost> file_system_dispatcher_host_;
-
- // Handles blob related messages.
- scoped_ptr<BlobDispatcherHost> blob_dispatcher_host_;
-
- // Handles file utilities messages.
- scoped_refptr<FileUtilitiesDispatcherHost> file_utilities_dispatcher_host_;
-
- // Handles mime registry requests.
- scoped_refptr<MimeRegistryDispatcher> mime_registry_dispatcher_;
-
DISALLOW_COPY_AND_ASSIGN(ResourceMessageFilter);
};
diff --git a/chrome/browser/search_engines/search_provider_install_state_dispatcher_host.cc b/chrome/browser/search_engines/search_provider_install_state_message_filter.cc
index b7b990e..a24bc1b 100644
--- a/chrome/browser/search_engines/search_provider_install_state_dispatcher_host.cc
+++ b/chrome/browser/search_engines/search_provider_install_state_message_filter.cc
@@ -2,55 +2,45 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/search_engines/search_provider_install_state_dispatcher_host.h"
+#include "chrome/browser/search_engines/search_provider_install_state_message_filter.h"
#include "base/logging.h"
-#include "chrome/browser/browser_thread.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/renderer_host/render_view_host.h"
-#include "chrome/browser/renderer_host/resource_message_filter.h"
#include "chrome/common/notification_source.h"
#include "chrome/common/notification_type.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/render_messages_params.h"
-#include "ipc/ipc_message.h"
#include "googleurl/src/gurl.h"
-SearchProviderInstallStateDispatcherHost::
-SearchProviderInstallStateDispatcherHost(
- ResourceMessageFilter* ipc_sender,
- Profile* profile,
- int render_process_id)
+SearchProviderInstallStateMessageFilter::
+SearchProviderInstallStateMessageFilter(
+ int render_process_id,
+ Profile* profile)
: ALLOW_THIS_IN_INITIALIZER_LIST(
reply_with_provider_install_state_factory_(this)),
provider_data_(profile->GetWebDataService(Profile::EXPLICIT_ACCESS),
NotificationType::RENDERER_PROCESS_TERMINATED,
Source<RenderProcessHost>(
RenderProcessHost::FromID(render_process_id))),
- ipc_sender_(ipc_sender),
is_off_the_record_(profile->IsOffTheRecord()) {
- // This is initialized by ResourceMessageFilter. Do not add any non-trivial
+ // This is initialized by BrowserRenderProcessHost. Do not add any non-trivial
// initialization here. Instead do it lazily when required.
- DCHECK(ipc_sender);
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
-SearchProviderInstallStateDispatcherHost::
-~SearchProviderInstallStateDispatcherHost() {
+SearchProviderInstallStateMessageFilter::
+~SearchProviderInstallStateMessageFilter() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
}
-void SearchProviderInstallStateDispatcherHost::Send(IPC::Message* message) {
- ipc_sender_->Send(message);
-}
-
-bool SearchProviderInstallStateDispatcherHost::OnMessageReceived(
+bool SearchProviderInstallStateMessageFilter::OnMessageReceived(
const IPC::Message& message,
bool* message_was_ok) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
bool handled = true;
- IPC_BEGIN_MESSAGE_MAP_EX(SearchProviderInstallStateDispatcherHost, message,
+ IPC_BEGIN_MESSAGE_MAP_EX(SearchProviderInstallStateMessageFilter, message,
*message_was_ok)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetSearchProviderInstallState,
OnMsgGetSearchProviderInstallState)
@@ -60,7 +50,7 @@ bool SearchProviderInstallStateDispatcherHost::OnMessageReceived(
}
ViewHostMsg_GetSearchProviderInstallState_Params
-SearchProviderInstallStateDispatcherHost::GetSearchProviderInstallState(
+SearchProviderInstallStateMessageFilter::GetSearchProviderInstallState(
const GURL& page_location,
const GURL& requested_host) {
GURL requested_origin = requested_host.GetOrigin();
@@ -95,20 +85,20 @@ SearchProviderInstallStateDispatcherHost::GetSearchProviderInstallState(
}
void
-SearchProviderInstallStateDispatcherHost::OnMsgGetSearchProviderInstallState(
+SearchProviderInstallStateMessageFilter::OnMsgGetSearchProviderInstallState(
const GURL& page_location,
const GURL& requested_host,
IPC::Message* reply_msg) {
provider_data_.CallWhenLoaded(
reply_with_provider_install_state_factory_.NewRunnableMethod(
- &SearchProviderInstallStateDispatcherHost::
+ &SearchProviderInstallStateMessageFilter::
ReplyWithProviderInstallState,
page_location,
requested_host,
reply_msg));
}
-void SearchProviderInstallStateDispatcherHost::ReplyWithProviderInstallState(
+void SearchProviderInstallStateMessageFilter::ReplyWithProviderInstallState(
const GURL& page_location,
const GURL& requested_host,
IPC::Message* reply_msg) {
diff --git a/chrome/browser/search_engines/search_provider_install_state_dispatcher_host.h b/chrome/browser/search_engines/search_provider_install_state_message_filter.h
index d597eb4..63ea44e 100644
--- a/chrome/browser/search_engines/search_provider_install_state_dispatcher_host.h
+++ b/chrome/browser/search_engines/search_provider_install_state_message_filter.h
@@ -2,38 +2,27 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_DISPATCHER_HOST_H_
-#define CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_DISPATCHER_HOST_H_
+#ifndef CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_MESSAGE_FILTER_H_
+#define CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_MESSAGE_FILTER_H_
-#include "base/basictypes.h"
-#include "base/scoped_ptr.h"
-#include "base/task.h"
+#include "chrome/browser/browser_message_filter.h"
#include "chrome/browser/search_engines/search_provider_install_data.h"
-namespace IPC {
-class Message;
-}
-
class GURL;
class Profile;
-class ResourceMessageFilter;
struct ViewHostMsg_GetSearchProviderInstallState_Params;
// Handles messages regarding search provider install state on the I/O thread.
-class SearchProviderInstallStateDispatcherHost {
+class SearchProviderInstallStateMessageFilter : public BrowserMessageFilter {
public:
// Unlike the other methods, the constructor is called on the UI thread.
- SearchProviderInstallStateDispatcherHost(ResourceMessageFilter* ipc_sender,
- Profile* profile,
- int render_process_id);
- ~SearchProviderInstallStateDispatcherHost();
-
- // Send a message to the renderer process.
- void Send(IPC::Message* message);
+ SearchProviderInstallStateMessageFilter(int render_process_id,
+ Profile* profile);
+ ~SearchProviderInstallStateMessageFilter();
- // Called to possibly handle the incoming IPC message. Returns true if
- // handled.
- bool OnMessageReceived(const IPC::Message& message, bool* message_was_ok);
+ // BrowserMessageFilter implementation.
+ virtual bool OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok);
private:
// Figures out the install state for the search provider.
@@ -52,20 +41,17 @@ class SearchProviderInstallStateDispatcherHost {
IPC::Message* reply_msg);
// Used to schedule invocations of ReplyWithProviderInstallState.
- ScopedRunnableMethodFactory<SearchProviderInstallStateDispatcherHost>
+ ScopedRunnableMethodFactory<SearchProviderInstallStateMessageFilter>
reply_with_provider_install_state_factory_;
// Used to do a load and get information about install states.
SearchProviderInstallData provider_data_;
- // Used to reply to messages.
- ResourceMessageFilter* ipc_sender_;
-
// Copied from the profile since the profile can't be accessed on the I/O
// thread.
const bool is_off_the_record_;
- DISALLOW_COPY_AND_ASSIGN(SearchProviderInstallStateDispatcherHost);
+ DISALLOW_COPY_AND_ASSIGN(SearchProviderInstallStateMessageFilter);
};
-#endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_DISPATCHER_HOST_H_
+#endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_MESSAGE_FILTER_H_
diff --git a/chrome/browser/speech/speech_input_dispatcher_host.cc b/chrome/browser/speech/speech_input_dispatcher_host.cc
index add39af..f1abebf 100644
--- a/chrome/browser/speech/speech_input_dispatcher_host.cc
+++ b/chrome/browser/speech/speech_input_dispatcher_host.cc
@@ -5,10 +5,6 @@
#include "chrome/browser/speech/speech_input_dispatcher_host.h"
#include "base/lazy_instance.h"
-#include "chrome/browser/renderer_host/render_process_host.h"
-#include "chrome/browser/renderer_host/render_view_host.h"
-#include "chrome/browser/renderer_host/render_view_host_notification_task.h"
-#include "chrome/browser/renderer_host/resource_message_filter.h"
#include "chrome/common/render_messages.h"
namespace speech_input {
@@ -108,10 +104,9 @@ int SpeechInputDispatcherHost::SpeechInputCallers::request_id(int id) {
SpeechInputManager::AccessorMethod*
SpeechInputDispatcherHost::manager_accessor_ = &SpeechInputManager::Get;
-SpeechInputDispatcherHost::SpeechInputDispatcherHost(
- int resource_message_filter_process_id)
- : resource_message_filter_process_id_(resource_message_filter_process_id) {
- // This is initialized by ResourceMessageFilter. Do not add any non-trivial
+SpeechInputDispatcherHost::SpeechInputDispatcherHost(int render_process_id)
+ : render_process_id_(render_process_id) {
+ // This is initialized by Browser. Do not add any non-trivial
// initialization here, instead do it lazily when required (e.g. see the
// method |manager()|) or add an Init() method.
}
@@ -124,10 +119,10 @@ SpeechInputManager* SpeechInputDispatcherHost::manager() {
}
bool SpeechInputDispatcherHost::OnMessageReceived(
- const IPC::Message& msg, bool* msg_was_ok) {
+ const IPC::Message& message, bool* message_was_ok) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
bool handled = true;
- IPC_BEGIN_MESSAGE_MAP_EX(SpeechInputDispatcherHost, msg, *msg_was_ok)
+ IPC_BEGIN_MESSAGE_MAP_EX(SpeechInputDispatcherHost, message, *message_was_ok)
IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_StartRecognition,
OnStartRecognition)
IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_CancelRecognition,
@@ -146,9 +141,9 @@ void SpeechInputDispatcherHost::OnStartRecognition(
const std::string& language,
const std::string& grammar) {
int caller_id = g_speech_input_callers.Get().CreateId(
- resource_message_filter_process_id_, render_view_id, request_id);
+ render_process_id_, render_view_id, request_id);
manager()->StartRecognition(this, caller_id,
- resource_message_filter_process_id_,
+ render_process_id_,
render_view_id, element_rect,
language, grammar);
}
@@ -156,7 +151,7 @@ void SpeechInputDispatcherHost::OnStartRecognition(
void SpeechInputDispatcherHost::OnCancelRecognition(int render_view_id,
int request_id) {
int caller_id = g_speech_input_callers.Get().GetId(
- resource_message_filter_process_id_, render_view_id, request_id);
+ render_process_id_, render_view_id, request_id);
if (caller_id) {
manager()->CancelRecognition(caller_id);
// Request sequence ended so remove mapping.
@@ -167,18 +162,11 @@ void SpeechInputDispatcherHost::OnCancelRecognition(int render_view_id,
void SpeechInputDispatcherHost::OnStopRecording(int render_view_id,
int request_id) {
int caller_id = g_speech_input_callers.Get().GetId(
- resource_message_filter_process_id_, render_view_id, request_id);
+ render_process_id_, render_view_id, request_id);
if (caller_id)
manager()->StopRecording(caller_id);
}
-void SpeechInputDispatcherHost::SendMessageToRenderView(IPC::Message* message,
- int render_view_id) {
- CallRenderViewHost(
- resource_message_filter_process_id_, render_view_id,
- &RenderViewHost::Send, message);
-}
-
void SpeechInputDispatcherHost::SetRecognitionResult(
int caller_id, const SpeechInputResultArray& result) {
VLOG(1) << "SpeechInputDispatcherHost::SetRecognitionResult enter";
@@ -186,11 +174,9 @@ void SpeechInputDispatcherHost::SetRecognitionResult(
int caller_render_view_id =
g_speech_input_callers.Get().render_view_id(caller_id);
int caller_request_id = g_speech_input_callers.Get().request_id(caller_id);
- SendMessageToRenderView(
- new ViewMsg_SpeechInput_SetRecognitionResult(caller_render_view_id,
- caller_request_id,
- result),
- caller_render_view_id);
+ Send(new ViewMsg_SpeechInput_SetRecognitionResult(caller_render_view_id,
+ caller_request_id,
+ result));
VLOG(1) << "SpeechInputDispatcherHost::SetRecognitionResult exit";
}
@@ -200,10 +186,8 @@ void SpeechInputDispatcherHost::DidCompleteRecording(int caller_id) {
int caller_render_view_id =
g_speech_input_callers.Get().render_view_id(caller_id);
int caller_request_id = g_speech_input_callers.Get().request_id(caller_id);
- SendMessageToRenderView(
- new ViewMsg_SpeechInput_RecordingComplete(caller_render_view_id,
- caller_request_id),
- caller_render_view_id);
+ Send(new ViewMsg_SpeechInput_RecordingComplete(caller_render_view_id,
+ caller_request_id));
VLOG(1) << "SpeechInputDispatcherHost::DidCompleteRecording exit";
}
@@ -213,10 +197,8 @@ void SpeechInputDispatcherHost::DidCompleteRecognition(int caller_id) {
int caller_render_view_id =
g_speech_input_callers.Get().render_view_id(caller_id);
int caller_request_id = g_speech_input_callers.Get().request_id(caller_id);
- SendMessageToRenderView(
- new ViewMsg_SpeechInput_RecognitionComplete(caller_render_view_id,
- caller_request_id),
- caller_render_view_id);
+ Send(new ViewMsg_SpeechInput_RecognitionComplete(caller_render_view_id,
+ caller_request_id));
// Request sequence ended, so remove mapping.
g_speech_input_callers.Get().RemoveId(caller_id);
VLOG(1) << "SpeechInputDispatcherHost::DidCompleteRecognition exit";
diff --git a/chrome/browser/speech/speech_input_dispatcher_host.h b/chrome/browser/speech/speech_input_dispatcher_host.h
index 38de835..82a12940 100644
--- a/chrome/browser/speech/speech_input_dispatcher_host.h
+++ b/chrome/browser/speech/speech_input_dispatcher_host.h
@@ -5,24 +5,21 @@
#ifndef CHROME_BROWSER_SPEECH_SPEECH_INPUT_DISPATCHER_HOST_H_
#define CHROME_BROWSER_SPEECH_SPEECH_INPUT_DISPATCHER_HOST_H_
-#include "base/basictypes.h"
-#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
+#include "chrome/browser/browser_message_filter.h"
#include "chrome/browser/speech/speech_input_manager.h"
-#include "ipc/ipc_message.h"
namespace speech_input {
// SpeechInputDispatcherHost is a delegate for Speech API messages used by
// ResourceMessageFilter.
// It's the complement of SpeechInputDispatcher (owned by RenderView).
-class SpeechInputDispatcherHost
- : public base::RefCountedThreadSafe<SpeechInputDispatcherHost>,
- public SpeechInputManager::Delegate {
+class SpeechInputDispatcherHost : public BrowserMessageFilter,
+ public SpeechInputManager::Delegate {
public:
class SpeechInputCallers;
- explicit SpeechInputDispatcherHost(int resource_message_filter_process_id);
+ explicit SpeechInputDispatcherHost(int render_process_id);
// SpeechInputManager::Delegate methods.
virtual void SetRecognitionResult(int caller_id,
@@ -30,9 +27,9 @@ class SpeechInputDispatcherHost
virtual void DidCompleteRecording(int caller_id);
virtual void DidCompleteRecognition(int caller_id);
- // Called to possibly handle the incoming IPC message. Returns true if
- // handled.
- bool OnMessageReceived(const IPC::Message& msg, bool* msg_was_ok);
+ // BrowserMessageFilter implementation.
+ virtual bool OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok);
// Singleton accessor setter useful for tests.
static void set_manager_accessor(SpeechInputManager::AccessorMethod* method) {
@@ -40,10 +37,7 @@ class SpeechInputDispatcherHost
}
private:
- friend class base::RefCountedThreadSafe<SpeechInputDispatcherHost>;
-
virtual ~SpeechInputDispatcherHost();
- void SendMessageToRenderView(IPC::Message* message, int render_view_id);
void OnStartRecognition(int render_view_id, int request_id,
const gfx::Rect& element_rect,
@@ -56,7 +50,7 @@ class SpeechInputDispatcherHost
// needed.
SpeechInputManager* manager();
- int resource_message_filter_process_id_;
+ int render_process_id_;
static SpeechInputManager::AccessorMethod* manager_accessor_;
diff --git a/chrome/browser/worker_host/worker_process_host.cc b/chrome/browser/worker_host/worker_process_host.cc
index 03ce293..2ea0564 100644
--- a/chrome/browser/worker_host/worker_process_host.cc
+++ b/chrome/browser/worker_host/worker_process_host.cc
@@ -17,12 +17,12 @@
#include "chrome/browser/child_process_security_policy.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/file_system/file_system_dispatcher_host.h"
-#include "chrome/browser/mime_registry_dispatcher.h"
+#include "chrome/browser/mime_registry_message_filter.h"
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/renderer_host/blob_dispatcher_host.h"
+#include "chrome/browser/renderer_host/blob_message_filter.h"
#include "chrome/browser/renderer_host/database_dispatcher_host.h"
-#include "chrome/browser/renderer_host/file_utilities_dispatcher_host.h"
+#include "chrome/browser/renderer_host/file_utilities_message_filter.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_view_host_delegate.h"
#include "chrome/browser/renderer_host/render_view_host_notification_task.h"
@@ -68,16 +68,7 @@ WorkerProcessHost::WorkerProcessHost(
ResourceDispatcherHost* resource_dispatcher_host,
ChromeURLRequestContext *request_context)
: BrowserChildProcessHost(WORKER_PROCESS, resource_dispatcher_host),
- request_context_(request_context),
- ALLOW_THIS_IN_INITIALIZER_LIST(blob_dispatcher_host_(
- new BlobDispatcherHost(
- this->id(), request_context->blob_storage_context()))),
- ALLOW_THIS_IN_INITIALIZER_LIST(file_system_dispatcher_host_(
- new FileSystemDispatcherHost(this, request_context))),
- ALLOW_THIS_IN_INITIALIZER_LIST(file_utilities_dispatcher_host_(
- new FileUtilitiesDispatcherHost(this, this->id()))),
- ALLOW_THIS_IN_INITIALIZER_LIST(mime_registry_dispatcher_(
- new MimeRegistryDispatcher(this))) {
+ request_context_(request_context) {
next_route_id_callback_.reset(NewCallbackWithReturnValue(
WorkerService::GetInstance(), &WorkerService::next_worker_route_id));
db_dispatcher_host_ = new DatabaseDispatcherHost(
@@ -94,18 +85,6 @@ WorkerProcessHost::~WorkerProcessHost() {
// Shut down the database dispatcher host.
db_dispatcher_host_->Shutdown();
- // Shut down the blob dispatcher host.
- blob_dispatcher_host_->Shutdown();
-
- // Shut down the file system dispatcher host.
- file_system_dispatcher_host_->Shutdown();
-
- // Shut down the file utilities dispatcher host.
- file_utilities_dispatcher_host_->Shutdown();
-
- // Shut down the mime registry dispatcher host.
- mime_registry_dispatcher_->Shutdown();
-
// Let interested observers know we are being deleted.
NotificationService::current()->Notify(
NotificationType::WORKER_PROCESS_HOST_SHUTDOWN,
@@ -224,6 +203,11 @@ 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(
+ new BlobMessageFilter(id(), request_context_->blob_storage_context()));
+ filters_.push_back(new MimeRegistryMessageFilter());
for (size_t i = 0; i < filters_.size(); ++i)
filters_[i]->OnFilterAdded(channel());
@@ -299,10 +283,6 @@ void WorkerProcessHost::OnMessageReceived(const IPC::Message& message) {
bool msg_is_ok = true;
bool handled =
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) ||
- file_utilities_dispatcher_host_->OnMessageReceived(message) ||
- mime_registry_dispatcher_->OnMessageReceived(message) ||
MessagePortDispatcher::GetInstance()->OnMessageReceived(
message, this, next_route_id_callback_.get(), &msg_is_ok);
@@ -363,8 +343,6 @@ void WorkerProcessHost::OnChannelError() {
void WorkerProcessHost::OnProcessLaunched() {
db_dispatcher_host_->Init(handle());
- file_system_dispatcher_host_->Init(handle());
- file_utilities_dispatcher_host_->Init(handle());
}
CallbackWithReturnValue<int>::Type* WorkerProcessHost::GetNextRouteIdCallback(
diff --git a/chrome/browser/worker_host/worker_process_host.h b/chrome/browser/worker_host/worker_process_host.h
index 4c983e0..b9307ec 100644
--- a/chrome/browser/worker_host/worker_process_host.h
+++ b/chrome/browser/worker_host/worker_process_host.h
@@ -20,13 +20,9 @@
#include "googleurl/src/gurl.h"
#include "ipc/ipc_channel.h"
-class BlobDispatcherHost;
class ChromeURLRequestContext;
class ChromeURLRequestContextGetter;
class DatabaseDispatcherHost;
-class FileSystemDispatcherHost;
-class FileUtilitiesDispatcherHost;
-class MimeRegistryDispatcher;
namespace webkit_database {
class DatabaseTracker;
} // namespace webkit_database
@@ -215,10 +211,6 @@ class WorkerProcessHost : public BrowserChildProcessHost {
scoped_refptr<ChromeURLRequestContext> request_context_;
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
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index ad667e8..a443f3a 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -823,8 +823,8 @@
'browser/device_orientation/accelerometer_mac.cc',
'browser/device_orientation/accelerometer_mac.h',
'browser/device_orientation/data_fetcher.h',
- 'browser/device_orientation/dispatcher_host.cc',
- 'browser/device_orientation/dispatcher_host.h',
+ 'browser/device_orientation/message_filter.cc',
+ 'browser/device_orientation/message_filter.h',
'browser/device_orientation/orientation.h',
'browser/device_orientation/provider.cc',
'browser/device_orientation/provider.h',
@@ -1763,8 +1763,8 @@
'browser/metrics/metrics_service.h',
'browser/metrics/user_metrics.cc',
'browser/metrics/user_metrics.h',
- 'browser/mime_registry_dispatcher.cc',
- 'browser/mime_registry_dispatcher.h',
+ 'browser/mime_registry_message_filter.cc',
+ 'browser/mime_registry_message_filter.h',
'browser/modal_html_dialog_delegate.cc',
'browser/modal_html_dialog_delegate.h',
'browser/nacl_host/nacl_broker_host_win.cc',
@@ -2107,8 +2107,8 @@
'browser/renderer_host/backing_store_win.h',
'browser/renderer_host/backing_store_x.cc',
'browser/renderer_host/backing_store_x.h',
- 'browser/renderer_host/blob_dispatcher_host.cc',
- 'browser/renderer_host/blob_dispatcher_host.h',
+ 'browser/renderer_host/blob_message_filter.cc',
+ 'browser/renderer_host/blob_message_filter.h',
'browser/renderer_host/browser_render_process_host.cc',
'browser/renderer_host/browser_render_process_host.h',
'browser/renderer_host/buffered_resource_handler.cc',
@@ -2121,8 +2121,8 @@
'browser/renderer_host/download_resource_handler.h',
'browser/renderer_host/download_throttling_resource_handler.cc',
'browser/renderer_host/download_throttling_resource_handler.h',
- 'browser/renderer_host/file_utilities_dispatcher_host.cc',
- 'browser/renderer_host/file_utilities_dispatcher_host.h',
+ 'browser/renderer_host/file_utilities_message_filter.cc',
+ 'browser/renderer_host/file_utilities_message_filter.h',
'browser/renderer_host/global_request_id.h',
'browser/renderer_host/accelerated_surface_container_mac.cc',
'browser/renderer_host/accelerated_surface_container_mac.h',
@@ -2242,8 +2242,8 @@
'browser/search_engines/search_host_to_urls_map.cc',
'browser/search_engines/search_provider_install_data.h',
'browser/search_engines/search_provider_install_data.cc',
- 'browser/search_engines/search_provider_install_state_dispatcher_host.cc',
- 'browser/search_engines/search_provider_install_state_dispatcher_host.h',
+ 'browser/search_engines/search_provider_install_state_message_filter.cc',
+ 'browser/search_engines/search_provider_install_state_message_filter.h',
'browser/search_engines/search_terms_data.cc',
'browser/search_engines/search_terms_data.h',
'browser/search_engines/template_url.cc',
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 9a59de9..75ca7d3 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -61,6 +61,8 @@
'common/file_system/webfilesystem_impl.h',
'common/file_system/webfilewriter_impl.cc',
'common/file_system/webfilewriter_impl.h',
+ 'common/file_utilities_messages.cc',
+ 'common/file_utilities_messages.h',
'common/font_descriptor_mac.h',
'common/font_descriptor_mac.mm',
'common/geoposition.cc',
@@ -88,6 +90,8 @@
'common/message_router.h',
'common/metrics_helpers.cc',
'common/metrics_helpers.h',
+ 'common/mime_registry_messages.cc',
+ 'common/mime_registry_messages.h',
'common/multi_process_lock.h',
'common/multi_process_lock_linux.cc',
'common/multi_process_lock_mac.cc',
diff --git a/chrome/common/file_utilities_messages.cc b/chrome/common/file_utilities_messages.cc
new file mode 100644
index 0000000..b1236ae
--- /dev/null
+++ b/chrome/common/file_utilities_messages.cc
@@ -0,0 +1,8 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/common_param_traits.h"
+
+#define IPC_MESSAGE_IMPL
+#include "chrome/common/file_utilities_messages.h"
diff --git a/chrome/common/file_utilities_messages.h b/chrome/common/file_utilities_messages.h
new file mode 100644
index 0000000..6b8157d
--- /dev/null
+++ b/chrome/common/file_utilities_messages.h
@@ -0,0 +1,35 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_COMMON_FILE_UTILITIES_MESSAGES_H_
+#define CHROME_COMMON_FILE_UTILITIES_MESSAGES_H_
+#pragma once
+
+#include "base/time.h"
+#include "ipc/ipc_message_macros.h"
+#include "ipc/ipc_param_traits.h"
+#include "ipc/ipc_platform_file.h"
+
+#define IPC_MESSAGE_START FileUtilitiesMsgStart
+
+// File utilities messages sent from the renderer to the browser.
+
+// Get file size in bytes. Set result to -1 if failed to get the file size.
+IPC_SYNC_MESSAGE_CONTROL1_1(FileUtilitiesMsg_GetFileSize,
+ FilePath /* path */,
+ int64 /* result */)
+
+// Get file modification time in seconds. Set result to 0 if failed to get the
+// file modification time.
+IPC_SYNC_MESSAGE_CONTROL1_1(FileUtilitiesMsg_GetFileModificationTime,
+ FilePath /* path */,
+ base::Time /* result */)
+
+// Open the file.
+IPC_SYNC_MESSAGE_CONTROL2_1(FileUtilitiesMsg_OpenFile,
+ FilePath /* path */,
+ int /* mode */,
+ IPC::PlatformFileForTransit /* result */)
+
+#endif // CHROME_COMMON_FILE_UTILITIES_MESSAGES_H_
diff --git a/chrome/common/mime_registry_messages.cc b/chrome/common/mime_registry_messages.cc
new file mode 100644
index 0000000..e8c2b9b
--- /dev/null
+++ b/chrome/common/mime_registry_messages.cc
@@ -0,0 +1,8 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/common_param_traits.h"
+
+#define IPC_MESSAGE_IMPL
+#include "chrome/common/mime_registry_messages.h"
diff --git a/chrome/common/mime_registry_messages.h b/chrome/common/mime_registry_messages.h
new file mode 100644
index 0000000..636009f
--- /dev/null
+++ b/chrome/common/mime_registry_messages.h
@@ -0,0 +1,28 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_COMMON_MIME_REGISTRY_MESSAGES_H_
+#define CHROME_COMMON_MIME_REGISTRY_MESSAGES_H_
+#pragma once
+
+#include "base/file_path.h"
+#include "ipc/ipc_message_macros.h"
+#include "ipc/ipc_param_traits.h"
+
+#define IPC_MESSAGE_START MimeRegistryMsgStart
+
+// Mime registry messages sent from the renderer to the browser.
+
+// Sent to query MIME information.
+IPC_SYNC_MESSAGE_CONTROL1_1(MimeRegistryMsg_GetMimeTypeFromExtension,
+ FilePath::StringType /* extension */,
+ std::string /* mime_type */)
+IPC_SYNC_MESSAGE_CONTROL1_1(MimeRegistryMsg_GetMimeTypeFromFile,
+ FilePath /* file_path */,
+ std::string /* mime_type */)
+IPC_SYNC_MESSAGE_CONTROL1_1(MimeRegistryMsg_GetPreferredExtensionForMimeType,
+ std::string /* mime_type */,
+ FilePath::StringType /* extension */)
+
+#endif // CHROME_COMMON_MIME_REGISTRY_MESSAGES_H_
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 29c4a7f..fa1ce45 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1931,17 +1931,6 @@ IPC_MESSAGE_ROUTED4(ViewHostMsg_DidDownloadFavIcon,
bool /* true if there was a network error */,
SkBitmap /* image_data */)
-// Sent to query MIME information.
-IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_GetMimeTypeFromExtension,
- FilePath::StringType /* extension */,
- std::string /* mime_type */)
-IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_GetMimeTypeFromFile,
- FilePath /* file_path */,
- std::string /* mime_type */)
-IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_GetPreferredExtensionForMimeType,
- std::string /* mime_type */,
- FilePath::StringType /* extension */)
-
// Get the CPBrowsingContext associated with the renderer sending this
// message.
IPC_SYNC_MESSAGE_CONTROL0_1(ViewHostMsg_GetCPBrowsingContext,
@@ -2660,23 +2649,6 @@ IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBTransactionDidCompleteTaskEvents,
IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBTransactionDestroyed,
int32 /* idb_transaction_id */)
-// Get file size in bytes. Set result to -1 if failed to get the file size.
-IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_GetFileSize,
- FilePath /* path */,
- int64 /* result */)
-
-// Get file modification time in seconds. Set result to 0 if failed to get the
-// file modification time.
-IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_GetFileModificationTime,
- FilePath /* path */,
- base::Time /* result */)
-
-// Open the file.
-IPC_SYNC_MESSAGE_CONTROL2_1(ViewHostMsg_OpenFile,
- FilePath /* path */,
- int /* mode */,
- IPC::PlatformFileForTransit /* result */)
-
// Opens a file asynchronously. The response returns a file descriptor
// and an error code from base/platform_file.h.
IPC_MESSAGE_ROUTED3(ViewHostMsg_AsyncOpenFile,
diff --git a/chrome/renderer/renderer_webkitclient_impl.cc b/chrome/renderer/renderer_webkitclient_impl.cc
index 90a2ee5..1025e69 100644
--- a/chrome/renderer/renderer_webkitclient_impl.cc
+++ b/chrome/renderer/renderer_webkitclient_impl.cc
@@ -12,6 +12,8 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/database_util.h"
#include "chrome/common/file_system/webfilesystem_impl.h"
+#include "chrome/common/file_utilities_messages.h"
+#include "chrome/common/mime_registry_messages.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/webblobregistry_impl.h"
#include "chrome/common/webmessageportchannel_impl.h"
@@ -324,8 +326,9 @@ WebString RendererWebKitClientImpl::MimeRegistry::mimeTypeForExtension(
// The sandbox restricts our access to the registry, so we need to proxy
// these calls over to the browser process.
std::string mime_type;
- RenderThread::current()->Send(new ViewHostMsg_GetMimeTypeFromExtension(
- webkit_glue::WebStringToFilePathString(file_extension), &mime_type));
+ RenderThread::current()->Send(
+ new MimeRegistryMsg_GetMimeTypeFromExtension(
+ webkit_glue::WebStringToFilePathString(file_extension), &mime_type));
return ASCIIToUTF16(mime_type);
}
@@ -338,7 +341,7 @@ WebString RendererWebKitClientImpl::MimeRegistry::mimeTypeFromFile(
// The sandbox restricts our access to the registry, so we need to proxy
// these calls over to the browser process.
std::string mime_type;
- RenderThread::current()->Send(new ViewHostMsg_GetMimeTypeFromFile(
+ RenderThread::current()->Send(new MimeRegistryMsg_GetMimeTypeFromFile(
FilePath(webkit_glue::WebStringToFilePathString(file_path)),
&mime_type));
return ASCIIToUTF16(mime_type);
@@ -354,8 +357,8 @@ WebString RendererWebKitClientImpl::MimeRegistry::preferredExtensionForMIMEType(
// these calls over to the browser process.
FilePath::StringType file_extension;
RenderThread::current()->Send(
- new ViewHostMsg_GetPreferredExtensionForMimeType(UTF16ToASCII(mime_type),
- &file_extension));
+ new MimeRegistryMsg_GetPreferredExtensionForMimeType(
+ UTF16ToASCII(mime_type), &file_extension));
return webkit_glue::FilePathStringToWebString(file_extension);
}
@@ -363,7 +366,7 @@ WebString RendererWebKitClientImpl::MimeRegistry::preferredExtensionForMIMEType(
bool RendererWebKitClientImpl::FileUtilities::getFileSize(const WebString& path,
long long& result) {
- if (SendSyncMessageFromAnyThread(new ViewHostMsg_GetFileSize(
+ if (SendSyncMessageFromAnyThread(new FileUtilitiesMsg_GetFileSize(
webkit_glue::WebStringToFilePath(path),
reinterpret_cast<int64*>(&result)))) {
return result >= 0;
@@ -384,7 +387,7 @@ bool RendererWebKitClientImpl::FileUtilities::getFileModificationTime(
const WebString& path,
double& result) {
base::Time time;
- if (SendSyncMessageFromAnyThread(new ViewHostMsg_GetFileModificationTime(
+ if (SendSyncMessageFromAnyThread(new FileUtilitiesMsg_GetFileModificationTime(
webkit_glue::WebStringToFilePath(path), &time))) {
result = time.ToDoubleT();
return !time.is_null();
@@ -398,7 +401,7 @@ base::PlatformFile RendererWebKitClientImpl::FileUtilities::openFile(
const WebString& path,
int mode) {
IPC::PlatformFileForTransit handle = IPC::InvalidPlatformFileForTransit();
- SendSyncMessageFromAnyThread(new ViewHostMsg_OpenFile(
+ SendSyncMessageFromAnyThread(new FileUtilitiesMsg_OpenFile(
webkit_glue::WebStringToFilePath(path), mode, &handle));
return IPC::PlatformFileForTransitToPlatformFile(handle);
}
diff --git a/chrome/worker/worker_webkitclient_impl.cc b/chrome/worker/worker_webkitclient_impl.cc
index cd188cd..3dc9cc2 100644
--- a/chrome/worker/worker_webkitclient_impl.cc
+++ b/chrome/worker/worker_webkitclient_impl.cc
@@ -8,8 +8,10 @@
#include "base/utf_string_conversions.h"
#include "chrome/common/database_util.h"
#include "chrome/common/file_system/webfilesystem_impl.h"
+#include "chrome/common/file_utilities_messages.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/render_messages_params.h"
+#include "chrome/common/mime_registry_messages.h"
#include "chrome/common/webblobregistry_impl.h"
#include "chrome/common/webmessageportchannel_impl.h"
#include "chrome/worker/worker_thread.h"
@@ -55,7 +57,7 @@ static bool SendSyncMessageFromAnyThread(IPC::SyncMessage* msg) {
bool WorkerWebKitClientImpl::FileUtilities::getFileSize(const WebString& path,
long long& result) {
- if (SendSyncMessageFromAnyThread(new ViewHostMsg_GetFileSize(
+ if (SendSyncMessageFromAnyThread(new FileUtilitiesMsg_GetFileSize(
webkit_glue::WebStringToFilePath(path),
reinterpret_cast<int64*>(&result)))) {
return result >= 0;
@@ -69,8 +71,8 @@ bool WorkerWebKitClientImpl::FileUtilities::getFileModificationTime(
const WebString& path,
double& result) {
base::Time time;
- if (SendSyncMessageFromAnyThread(new ViewHostMsg_GetFileModificationTime(
- webkit_glue::WebStringToFilePath(path), &time))) {
+ if (SendSyncMessageFromAnyThread(new FileUtilitiesMsg_GetFileModificationTime(
+ webkit_glue::WebStringToFilePath(path), &time))) {
result = time.ToDoubleT();
return !time.is_null();
}
@@ -228,7 +230,7 @@ WebMimeRegistry::SupportsType WorkerWebKitClientImpl::supportsNonImageMIMEType(
WebString WorkerWebKitClientImpl::mimeTypeForExtension(
const WebString& file_extension) {
std::string mime_type;
- SendSyncMessageFromAnyThread(new ViewHostMsg_GetMimeTypeFromExtension(
+ SendSyncMessageFromAnyThread(new MimeRegistryMsg_GetMimeTypeFromExtension(
webkit_glue::WebStringToFilePathString(file_extension), &mime_type));
return ASCIIToUTF16(mime_type);
}
@@ -236,7 +238,7 @@ WebString WorkerWebKitClientImpl::mimeTypeForExtension(
WebString WorkerWebKitClientImpl::mimeTypeFromFile(
const WebString& file_path) {
std::string mime_type;
- SendSyncMessageFromAnyThread(new ViewHostMsg_GetMimeTypeFromFile(
+ SendSyncMessageFromAnyThread(new MimeRegistryMsg_GetMimeTypeFromFile(
FilePath(webkit_glue::WebStringToFilePathString(file_path)),
&mime_type));
return ASCIIToUTF16(mime_type);
@@ -246,8 +248,8 @@ WebString WorkerWebKitClientImpl::preferredExtensionForMIMEType(
const WebString& mime_type) {
FilePath::StringType file_extension;
SendSyncMessageFromAnyThread(
- new ViewHostMsg_GetPreferredExtensionForMimeType(UTF16ToASCII(mime_type),
- &file_extension));
+ new MimeRegistryMsg_GetPreferredExtensionForMimeType(
+ UTF16ToASCII(mime_type), &file_extension));
return webkit_glue::FilePathStringToWebString(file_extension);
}
diff --git a/ipc/ipc_message_macros.h b/ipc/ipc_message_macros.h
index f84df9d..d955135 100644
--- a/ipc/ipc_message_macros.h
+++ b/ipc/ipc_message_macros.h
@@ -1031,3 +1031,7 @@ void class_name::OnMessageReceived(const IPC::Message& msg) \
#define IPC_END_MESSAGE_MAP_EX() \
} \
}
+
+// This corresponds to an enum value from IPCMessageStart.
+#define IPC_MESSAGE_CLASS(message) \
+ message.type() >> 16
diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h
index 8e0f670..858ad1a 100644
--- a/ipc/ipc_message_utils.h
+++ b/ipc/ipc_message_utils.h
@@ -59,6 +59,8 @@ enum IPCMessageStart {
ServiceMsgStart,
PpapiMsgStart,
FirefoxImporterUnittestMsgStart,
+ FileUtilitiesMsgStart,
+ MimeRegistryMsgStart,
};
class DictionaryValue;