summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
authorraymes@google.com <raymes@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-21 02:47:42 +0000
committerraymes@google.com <raymes@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-21 02:47:42 +0000
commit49511a7d75a9952eb4a982716089b56c782f3cec (patch)
treefa240d393e59ccb26b4b95b16570f4c568cb3cc0 /content/browser
parentc68e3e5a9ee8ff4bcd702c4c10a4eac0369a2431 (diff)
downloadchromium_src-49511a7d75a9952eb4a982716089b56c782f3cec.zip
chromium_src-49511a7d75a9952eb4a982716089b56c782f3cec.tar.gz
chromium_src-49511a7d75a9952eb4a982716089b56c782f3cec.tar.bz2
Refactor PepperFlashFileHost and PepperBrokerHost to use MessageFilterHost.
This refactors PepperFlashFileHost and PepperBrokerHost to use MessageFilterHost. This removes the empty Host classes and moves the interface definition of the MessageFilter classes into the header files. This hopefully makes the code a lot cleaner/clearer. TBR=brettw@chromium.org for gypi changes and trivial plugin_data_remover_impl changes. Review URL: https://codereview.chromium.org/11617005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174323 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/plugin_data_remover_impl.cc4
-rw-r--r--content/browser/renderer_host/pepper/content_browser_pepper_host_factory.cc16
-rw-r--r--content/browser/renderer_host/pepper/pepper_flash_file_host.h44
-rw-r--r--content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc (renamed from content/browser/renderer_host/pepper/pepper_flash_file_host.cc)121
-rw-r--r--content/browser/renderer_host/pepper/pepper_flash_file_message_filter.h82
5 files changed, 127 insertions, 140 deletions
diff --git a/content/browser/plugin_data_remover_impl.cc b/content/browser/plugin_data_remover_impl.cc
index 731f1e6..983f84f 100644
--- a/content/browser/plugin_data_remover_impl.cc
+++ b/content/browser/plugin_data_remover_impl.cc
@@ -14,7 +14,7 @@
#include "base/version.h"
#include "content/browser/plugin_process_host.h"
#include "content/browser/plugin_service_impl.h"
-#include "content/browser/renderer_host/pepper/pepper_flash_file_host.h"
+#include "content/browser/renderer_host/pepper/pepper_flash_file_message_filter.h"
#include "content/common/child_process_host_impl.h"
#include "content/common/plugin_messages.h"
#include "content/public/browser/browser_context.h"
@@ -202,7 +202,7 @@ class PluginDataRemoverImpl::Context
IPC::Message* CreatePpapiClearSiteDataMsg(uint64 max_age) {
FilePath profile_path =
- PepperFlashFileHost::GetDataDirName(browser_context_path_);
+ PepperFlashFileMessageFilter::GetDataDirName(browser_context_path_);
// TODO(vtl): This "duplicates" logic in webkit/plugins/ppapi/file_path.cc
// (which prepends the plugin name to the relative part of the path
// instead, with the absolute, profile-dependent part being enforced by
diff --git a/content/browser/renderer_host/pepper/content_browser_pepper_host_factory.cc b/content/browser/renderer_host/pepper/content_browser_pepper_host_factory.cc
index f43d852..75e3ac4 100644
--- a/content/browser/renderer_host/pepper/content_browser_pepper_host_factory.cc
+++ b/content/browser/renderer_host/pepper/content_browser_pepper_host_factory.cc
@@ -6,15 +6,19 @@
#include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h"
#include "content/browser/renderer_host/pepper/pepper_browser_font_singleton_host.h"
-#include "content/browser/renderer_host/pepper/pepper_flash_file_host.h"
+#include "content/browser/renderer_host/pepper/pepper_flash_file_message_filter.h"
#include "content/browser/renderer_host/pepper/pepper_gamepad_host.h"
#include "content/browser/renderer_host/pepper/pepper_print_settings_manager.h"
#include "content/browser/renderer_host/pepper/pepper_printing_host.h"
+#include "ppapi/host/message_filter_host.h"
+#include "ppapi/host/ppapi_host.h"
#include "ppapi/host/resource_host.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
+using ppapi::host::MessageFilterHost;
using ppapi::host::ResourceHost;
+using ppapi::host::ResourceMessageFilter;
namespace content {
@@ -69,9 +73,13 @@ scoped_ptr<ResourceHost> ContentBrowserPepperHostFactory::CreateResourceHost(
// Flash interfaces.
if (GetPermissions().HasPermission(ppapi::PERMISSION_FLASH)) {
switch (message.type()) {
- case PpapiHostMsg_FlashFile_Create::ID:
- return scoped_ptr<ResourceHost>(new PepperFlashFileHost(
- host_, instance, params.pp_resource()));
+ case PpapiHostMsg_FlashFile_Create::ID: {
+ scoped_refptr<ResourceMessageFilter> file_filter(
+ new PepperFlashFileMessageFilter(instance, host_));
+ return scoped_ptr<ResourceHost>(new MessageFilterHost(
+ host_->GetPpapiHost(), instance, params.pp_resource(),
+ file_filter));
+ }
}
}
diff --git a/content/browser/renderer_host/pepper/pepper_flash_file_host.h b/content/browser/renderer_host/pepper/pepper_flash_file_host.h
deleted file mode 100644
index 6b45d98..0000000
--- a/content/browser/renderer_host/pepper/pepper_flash_file_host.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) 2012 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 CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_FILE_HOST_H_
-#define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_FILE_HOST_H_
-
-#include "base/compiler_specific.h"
-#include "base/file_path.h"
-#include "base/memory/ref_counted.h"
-#include "base/process.h"
-#include "ppapi/host/resource_host.h"
-#include "ppapi/host/resource_message_filter.h"
-
-namespace ppapi {
-class PepperFilePath;
-}
-
-namespace ppapi {
-namespace host {
-struct ReplyMessageContext;
-}
-}
-
-namespace content {
-
-class BrowserPpapiHost;
-
-class PepperFlashFileHost : public ppapi::host::ResourceHost {
- public:
- PepperFlashFileHost(BrowserPpapiHost* host,
- PP_Instance instance,
- PP_Resource resource);
- virtual ~PepperFlashFileHost();
-
- static FilePath GetDataDirName(const FilePath& profile_path);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(PepperFlashFileHost);
-};
-
-} // namespace content
-
-#endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_FILE_HOST_H_
diff --git a/content/browser/renderer_host/pepper/pepper_flash_file_host.cc b/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc
index f4dc898..30c07d94 100644
--- a/content/browser/renderer_host/pepper/pepper_flash_file_host.cc
+++ b/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc
@@ -2,11 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/browser/renderer_host/pepper/pepper_flash_file_host.h"
+#include "content/browser/renderer_host/pepper/pepper_flash_file_message_filter.h"
#include "base/bind.h"
#include "base/file_util.h"
-#include "base/task_runner.h"
#include "base/threading/sequenced_worker_pool.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/public/browser/browser_ppapi_host.h"
@@ -37,58 +36,17 @@ const int kWritePermissions = base::PLATFORM_FILE_OPEN |
base::PLATFORM_FILE_WRITE |
base::PLATFORM_FILE_EXCLUSIVE_WRITE |
base::PLATFORM_FILE_WRITE_ATTRIBUTES;
+} // namespace
+
+PepperFlashFileMessageFilter::PepperFlashFileMessageFilter(
+ PP_Instance instance,
+ BrowserPpapiHost* host)
+ : plugin_process_handle_(host->GetPluginProcessHandle()) {
+ int unused;
+ host->GetRenderViewIDsForInstance(instance, &render_process_id_, &unused);
+ FilePath profile_data_directory = host->GetProfileDataDirectory();
+ std::string plugin_name = host->GetPluginName();
-// All file messages are handled by BrowserThread's blocking pool.
-class FileMessageFilter : public ppapi::host::ResourceMessageFilter {
- public:
- FileMessageFilter(const std::string& plugin_name,
- const FilePath& profile_data_directory,
- int render_process_id,
- base::ProcessHandle plugin_process_handle);
- protected:
- // ppapi::host::ResourceMessageFilter implementation.
- virtual scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage(
- const IPC::Message& msg) OVERRIDE;
- virtual int32_t OnResourceMessageReceived(
- const IPC::Message& msg,
- ppapi::host::HostMessageContext* context) OVERRIDE;
-
- private:
- virtual ~FileMessageFilter();
-
- int32_t OnOpenFile(ppapi::host::HostMessageContext* context,
- const ppapi::PepperFilePath& path,
- int flags);
- int32_t OnRenameFile(ppapi::host::HostMessageContext* context,
- const ppapi::PepperFilePath& from_path,
- const ppapi::PepperFilePath& to_path);
- int32_t OnDeleteFileOrDir(ppapi::host::HostMessageContext* context,
- const ppapi::PepperFilePath& path,
- bool recursive);
- int32_t OnCreateDir(ppapi::host::HostMessageContext* context,
- const ppapi::PepperFilePath& path);
- int32_t OnQueryFile(ppapi::host::HostMessageContext* context,
- const ppapi::PepperFilePath& path);
- int32_t OnGetDirContents(ppapi::host::HostMessageContext* context,
- const ppapi::PepperFilePath& path);
- int32_t OnCreateTemporaryFile(ppapi::host::HostMessageContext* context);
-
- FilePath ValidateAndConvertPepperFilePath(
- const ppapi::PepperFilePath& pepper_path,
- int flags);
-
- FilePath plugin_data_directory_;
- int render_process_id_;
- base::ProcessHandle plugin_process_handle_;
-};
-
-FileMessageFilter::FileMessageFilter(
- const std::string& plugin_name,
- const FilePath& profile_data_directory,
- int render_process_id,
- base::ProcessHandle plugin_process_handle)
- : render_process_id_(render_process_id),
- plugin_process_handle_(plugin_process_handle) {
if (profile_data_directory.empty() || plugin_name.empty()) {
// These are used to construct the path. If they are not set it means we
// will construct a bad path and could provide access to the wrong files.
@@ -96,16 +54,23 @@ FileMessageFilter::FileMessageFilter(
// |ValidateAndConvertPepperFilePath| will fail.
NOTREACHED();
} else {
- plugin_data_directory_ = PepperFlashFileHost::GetDataDirName(
+ plugin_data_directory_ = GetDataDirName(
profile_data_directory).Append(FilePath::FromUTF8Unsafe(plugin_name));
}
}
-FileMessageFilter::~FileMessageFilter() {
+PepperFlashFileMessageFilter::~PepperFlashFileMessageFilter() {
+}
+
+// static
+FilePath PepperFlashFileMessageFilter::GetDataDirName(
+ const FilePath& profile_path) {
+ return profile_path.Append(kPepperDataDirname);
}
scoped_refptr<base::TaskRunner>
-FileMessageFilter::OverrideTaskRunnerForMessage(const IPC::Message& msg) {
+PepperFlashFileMessageFilter::OverrideTaskRunnerForMessage(
+ const IPC::Message& msg) {
// The blocking pool provides a pool of threads to run file
// operations, instead of a single thread which might require
// queuing time. Since these messages are synchronous as sent from
@@ -117,10 +82,10 @@ FileMessageFilter::OverrideTaskRunnerForMessage(const IPC::Message& msg) {
return scoped_refptr<base::TaskRunner>(BrowserThread::GetBlockingPool());
}
-int32_t FileMessageFilter::OnResourceMessageReceived(
+int32_t PepperFlashFileMessageFilter::OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) {
- IPC_BEGIN_MESSAGE_MAP(FileMessageFilter, msg)
+ IPC_BEGIN_MESSAGE_MAP(PepperFlashFileMessageFilter, msg)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashFile_OpenFile,
OnOpenFile)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashFile_RenameFile,
@@ -140,7 +105,7 @@ int32_t FileMessageFilter::OnResourceMessageReceived(
return PP_ERROR_FAILED;
}
-int32_t FileMessageFilter::OnOpenFile(
+int32_t PepperFlashFileMessageFilter::OnOpenFile(
ppapi::host::HostMessageContext* context,
const ppapi::PepperFilePath& path,
int flags) {
@@ -178,7 +143,7 @@ int32_t FileMessageFilter::OnOpenFile(
return PP_OK_COMPLETIONPENDING;
}
-int32_t FileMessageFilter::OnRenameFile(
+int32_t PepperFlashFileMessageFilter::OnRenameFile(
ppapi::host::HostMessageContext* context,
const ppapi::PepperFilePath& from_path,
const ppapi::PepperFilePath& to_path) {
@@ -196,7 +161,7 @@ int32_t FileMessageFilter::OnRenameFile(
base::PLATFORM_FILE_OK : base::PLATFORM_FILE_ERROR_ACCESS_DENIED);
}
-int32_t FileMessageFilter::OnDeleteFileOrDir(
+int32_t PepperFlashFileMessageFilter::OnDeleteFileOrDir(
ppapi::host::HostMessageContext* context,
const ppapi::PepperFilePath& path,
bool recursive) {
@@ -211,7 +176,7 @@ int32_t FileMessageFilter::OnDeleteFileOrDir(
return ppapi::PlatformFileErrorToPepperError(result ?
base::PLATFORM_FILE_OK : base::PLATFORM_FILE_ERROR_ACCESS_DENIED);
}
-int32_t FileMessageFilter::OnCreateDir(
+int32_t PepperFlashFileMessageFilter::OnCreateDir(
ppapi::host::HostMessageContext* context,
const ppapi::PepperFilePath& path) {
FilePath full_path = ValidateAndConvertPepperFilePath(path,
@@ -226,7 +191,7 @@ int32_t FileMessageFilter::OnCreateDir(
base::PLATFORM_FILE_OK : base::PLATFORM_FILE_ERROR_ACCESS_DENIED);
}
-int32_t FileMessageFilter::OnQueryFile(
+int32_t PepperFlashFileMessageFilter::OnQueryFile(
ppapi::host::HostMessageContext* context,
const ppapi::PepperFilePath& path) {
FilePath full_path = ValidateAndConvertPepperFilePath(path,
@@ -243,7 +208,7 @@ int32_t FileMessageFilter::OnQueryFile(
base::PLATFORM_FILE_OK : base::PLATFORM_FILE_ERROR_ACCESS_DENIED);
}
-int32_t FileMessageFilter::OnGetDirContents(
+int32_t PepperFlashFileMessageFilter::OnGetDirContents(
ppapi::host::HostMessageContext* context,
const ppapi::PepperFilePath& path) {
FilePath full_path = ValidateAndConvertPepperFilePath(path, kReadPermissions);
@@ -272,7 +237,7 @@ int32_t FileMessageFilter::OnGetDirContents(
return PP_OK;
}
-int32_t FileMessageFilter::OnCreateTemporaryFile(
+int32_t PepperFlashFileMessageFilter::OnCreateTemporaryFile(
ppapi::host::HostMessageContext* context) {
ppapi::PepperFilePath dir_path(
ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL, FilePath());
@@ -314,7 +279,7 @@ int32_t FileMessageFilter::OnCreateTemporaryFile(
return PP_OK_COMPLETIONPENDING;
}
-FilePath FileMessageFilter::ValidateAndConvertPepperFilePath(
+FilePath PepperFlashFileMessageFilter::ValidateAndConvertPepperFilePath(
const ppapi::PepperFilePath& pepper_path,
int flags) {
FilePath file_path; // Empty path returned on error.
@@ -340,28 +305,4 @@ FilePath FileMessageFilter::ValidateAndConvertPepperFilePath(
return file_path;
}
-} // namespace
-
-PepperFlashFileHost::PepperFlashFileHost(
- BrowserPpapiHost* host,
- PP_Instance instance,
- PP_Resource resource)
- : ResourceHost(host->GetPpapiHost(), instance, resource) {
- int render_process_id, unused;
- host->GetRenderViewIDsForInstance(instance, &render_process_id, &unused);
- AddFilter(scoped_refptr<ppapi::host::ResourceMessageFilter>(
- new FileMessageFilter(host->GetPluginName(),
- host->GetProfileDataDirectory(),
- render_process_id,
- host->GetPluginProcessHandle())));
-}
-
-PepperFlashFileHost::~PepperFlashFileHost() {
-}
-
-// static
-FilePath PepperFlashFileHost::GetDataDirName(const FilePath& profile_path) {
- return profile_path.Append(kPepperDataDirname);
-}
-
} // namespace content
diff --git a/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.h b/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.h
new file mode 100644
index 0000000..216a6fb
--- /dev/null
+++ b/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.h
@@ -0,0 +1,82 @@
+// Copyright (c) 2012 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 CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_FILE_MESSAGE_FILTER_H_
+#define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_FILE_MESSAGE_FILTER_H_
+
+#include "base/compiler_specific.h"
+#include "base/file_path.h"
+#include "base/memory/ref_counted.h"
+#include "base/process.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/host/resource_host.h"
+#include "ppapi/host/resource_message_filter.h"
+
+namespace content {
+class BrowserPpapiHost;
+}
+
+namespace ppapi {
+class PepperFilePath;
+}
+
+namespace ppapi {
+namespace host {
+struct HostMessageContext;
+}
+}
+
+namespace content {
+
+class BrowserPpapiHost;
+
+// All file messages are handled by BrowserThread's blocking pool.
+class PepperFlashFileMessageFilter : public ppapi::host::ResourceMessageFilter {
+ public:
+ PepperFlashFileMessageFilter(PP_Instance instance,
+ BrowserPpapiHost* host);
+
+ static FilePath GetDataDirName(const FilePath& profile_path);
+
+ private:
+ virtual ~PepperFlashFileMessageFilter();
+
+ // ppapi::host::ResourceMessageFilter overrides.
+ virtual scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage(
+ const IPC::Message& msg) OVERRIDE;
+ virtual int32_t OnResourceMessageReceived(
+ const IPC::Message& msg,
+ ppapi::host::HostMessageContext* context) OVERRIDE;
+
+ int32_t OnOpenFile(ppapi::host::HostMessageContext* context,
+ const ppapi::PepperFilePath& path,
+ int flags);
+ int32_t OnRenameFile(ppapi::host::HostMessageContext* context,
+ const ppapi::PepperFilePath& from_path,
+ const ppapi::PepperFilePath& to_path);
+ int32_t OnDeleteFileOrDir(ppapi::host::HostMessageContext* context,
+ const ppapi::PepperFilePath& path,
+ bool recursive);
+ int32_t OnCreateDir(ppapi::host::HostMessageContext* context,
+ const ppapi::PepperFilePath& path);
+ int32_t OnQueryFile(ppapi::host::HostMessageContext* context,
+ const ppapi::PepperFilePath& path);
+ int32_t OnGetDirContents(ppapi::host::HostMessageContext* context,
+ const ppapi::PepperFilePath& path);
+ int32_t OnCreateTemporaryFile(ppapi::host::HostMessageContext* context);
+
+ FilePath ValidateAndConvertPepperFilePath(
+ const ppapi::PepperFilePath& pepper_path,
+ int flags);
+
+ FilePath plugin_data_directory_;
+ int render_process_id_;
+ base::ProcessHandle plugin_process_handle_;
+
+ DISALLOW_COPY_AND_ASSIGN(PepperFlashFileMessageFilter);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_FLASH_FILE_MESSAGE_FILTER_H_