summaryrefslogtreecommitdiffstats
path: root/chromium/content/browser/renderer_host/pepper
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-08-08 14:30:41 +0200
committerJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-08-12 13:49:54 +0200
commitab0a50979b9eb4dfa3320eff7e187e41efedf7a9 (patch)
tree498dfb8a97ff3361a9f7486863a52bb4e26bb898 /chromium/content/browser/renderer_host/pepper
parent4ce69f7403811819800e7c5ae1318b2647e778d1 (diff)
Update Chromium to beta version 37.0.2062.68
Change-Id: I188e3b5aff1bec75566014291b654eb19f5bc8ca Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'chromium/content/browser/renderer_host/pepper')
-rw-r--r--chromium/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc84
-rw-r--r--chromium/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h51
-rw-r--r--chromium/content/browser/renderer_host/pepper/browser_ppapi_host_test.cc22
-rw-r--r--chromium/content/browser/renderer_host/pepper/content_browser_pepper_host_factory.cc85
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_browser_font_singleton_host.cc13
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.cc39
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.h16
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_file_io_host.cc430
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_file_io_host.h70
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_file_ref_host.cc79
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_file_ref_host.h7
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc248
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_file_system_browser_host.h57
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_file_system_browser_host_unittest.cc16
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc161
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.h3
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_gamepad_host.cc14
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_gamepad_host.h13
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_gamepad_host_unittest.cc38
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_host_resolver_message_filter.cc46
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_host_resolver_message_filter.h2
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.cc81
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.h18
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_lookup_request.h2
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_message_filter.cc19
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_message_filter.h3
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_network_monitor_host.cc49
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_network_monitor_host.h7
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_network_proxy_host.cc67
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_network_proxy_host.h2
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_print_settings_manager.cc45
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_printing_host.cc14
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_printing_host.h8
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_printing_host_unittest.cc52
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_renderer_connection.cc43
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_renderer_connection.h3
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_security_helper.cc21
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_socket_utils.cc75
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_socket_utils.h10
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc72
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.h11
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_tcp_socket.cc159
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc261
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.h25
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc26
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_truetype_font_list_win.cc23
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.cc129
-rw-r--r--chromium/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.h9
-rw-r--r--chromium/content/browser/renderer_host/pepper/quota_reservation.cc81
-rw-r--r--chromium/content/browser/renderer_host/pepper/quota_reservation.h24
-rw-r--r--chromium/content/browser/renderer_host/pepper/quota_reservation_unittest.cc150
-rw-r--r--chromium/content/browser/renderer_host/pepper/ssl_context_helper.cc6
52 files changed, 1424 insertions, 1565 deletions
diff --git a/chromium/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc b/chromium/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc
index c3c2c6f3932..403b129a469 100644
--- a/chromium/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc
+++ b/chromium/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc
@@ -4,12 +4,13 @@
#include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h"
+#include "base/metrics/sparse_histogram.h"
#include "content/browser/renderer_host/pepper/pepper_message_filter.h"
#include "content/browser/tracing/trace_message_filter.h"
#include "content/common/pepper_renderer_instance_data.h"
-#include "content/public/browser/render_view_host.h"
#include "content/public/common/process_type.h"
#include "ipc/ipc_message_macros.h"
+#include "ppapi/proxy/ppapi_messages.h"
namespace content {
@@ -24,8 +25,11 @@ BrowserPpapiHost* BrowserPpapiHost::CreateExternalPluginProcess(
const base::FilePath& profile_directory) {
// The plugin name and path shouldn't be needed for external plugins.
BrowserPpapiHostImpl* browser_ppapi_host =
- new BrowserPpapiHostImpl(sender, permissions, std::string(),
- base::FilePath(), profile_directory,
+ new BrowserPpapiHostImpl(sender,
+ permissions,
+ std::string(),
+ base::FilePath(),
+ profile_directory,
false /* in_process */,
true /* external_plugin */);
browser_ppapi_host->set_plugin_process_handle(plugin_child_process);
@@ -55,7 +59,7 @@ BrowserPpapiHostImpl::BrowserPpapiHostImpl(
in_process_(in_process),
external_plugin_(external_plugin),
ssl_context_helper_(new SSLContextHelper()) {
- message_filter_ = new HostMessageFilter(ppapi_host_.get());
+ message_filter_ = new HostMessageFilter(ppapi_host_.get(), this);
ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>(
new ContentBrowserPepperHostFactory(this)));
}
@@ -76,7 +80,7 @@ ppapi::host::PpapiHost* BrowserPpapiHostImpl::GetPpapiHost() {
base::ProcessHandle BrowserPpapiHostImpl::GetPluginProcessHandle() const {
// Handle should previously have been set before use.
- DCHECK(plugin_process_handle_ != base::kNullProcessHandle);
+ DCHECK(in_process_ || plugin_process_handle_ != base::kNullProcessHandle);
return plugin_process_handle_;
}
@@ -84,19 +88,19 @@ bool BrowserPpapiHostImpl::IsValidInstance(PP_Instance instance) const {
return instance_map_.find(instance) != instance_map_.end();
}
-bool BrowserPpapiHostImpl::GetRenderViewIDsForInstance(
+bool BrowserPpapiHostImpl::GetRenderFrameIDsForInstance(
PP_Instance instance,
int* render_process_id,
- int* render_view_id) const {
+ int* render_frame_id) const {
InstanceMap::const_iterator found = instance_map_.find(instance);
if (found == instance_map_.end()) {
*render_process_id = 0;
- *render_view_id = 0;
+ *render_frame_id = 0;
return false;
}
*render_process_id = found->second.render_process_id;
- *render_view_id = found->second.render_view_id;
+ *render_frame_id = found->second.render_frame_id;
return true;
}
@@ -126,6 +130,11 @@ GURL BrowserPpapiHostImpl::GetPluginURLForInstance(PP_Instance instance) {
return found->second.plugin_url;
}
+void BrowserPpapiHostImpl::SetOnKeepaliveCallback(
+ const BrowserPpapiHost::OnKeepaliveCallback& callback) {
+ on_keepalive_callback_ = callback;
+}
+
void BrowserPpapiHostImpl::AddInstance(
PP_Instance instance,
const PepperRendererInstanceData& instance_data) {
@@ -142,26 +151,71 @@ void BrowserPpapiHostImpl::DeleteInstance(PP_Instance instance) {
instance_map_.erase(found);
}
+BrowserPpapiHostImpl::HostMessageFilter::HostMessageFilter(
+ ppapi::host::PpapiHost* ppapi_host,
+ BrowserPpapiHostImpl* browser_ppapi_host_impl)
+ : ppapi_host_(ppapi_host),
+ browser_ppapi_host_impl_(browser_ppapi_host_impl) {}
+
bool BrowserPpapiHostImpl::HostMessageFilter::OnMessageReceived(
const IPC::Message& msg) {
// Don't forward messages if our owner object has been destroyed.
if (!ppapi_host_)
return false;
- /* TODO(brettw) when we add messages, here, the code should look like this:
bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(BrowserPpapiHostImpl, msg)
- // Add necessary message handlers here.
- IPC_MESSAGE_UNHANDLED(handled = ppapi_host_->OnMessageReceived(msg))
+ IPC_BEGIN_MESSAGE_MAP(BrowserPpapiHostImpl::HostMessageFilter, msg)
+ // Add necessary message handlers here.
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_Keepalive, OnKeepalive)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_LogInterfaceUsage,
+ OnHostMsgLogInterfaceUsage)
+ IPC_MESSAGE_UNHANDLED(handled = ppapi_host_->OnMessageReceived(msg))
IPC_END_MESSAGE_MAP();
return handled;
- */
- return ppapi_host_->OnMessageReceived(msg);
}
void BrowserPpapiHostImpl::HostMessageFilter::OnHostDestroyed() {
DCHECK(ppapi_host_);
ppapi_host_ = NULL;
+ browser_ppapi_host_impl_ = NULL;
+}
+
+BrowserPpapiHostImpl::HostMessageFilter::~HostMessageFilter() {}
+
+void BrowserPpapiHostImpl::HostMessageFilter::OnKeepalive() {
+ if (browser_ppapi_host_impl_)
+ browser_ppapi_host_impl_->OnKeepalive();
+}
+
+void BrowserPpapiHostImpl::HostMessageFilter::OnHostMsgLogInterfaceUsage(
+ int hash) const {
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Pepper.InterfaceUsed", hash);
+}
+
+void BrowserPpapiHostImpl::OnKeepalive() {
+ // An instance has been active. The on_keepalive_callback_ will be
+ // used to permit the content embedder to handle this, e.g. by tracking
+ // activity and shutting down processes that go idle.
+ //
+ // Currently embedders do not need to distinguish between instances having
+ // different idle state, and thus this implementation handles all instances
+ // for this module together.
+
+ if (on_keepalive_callback_.is_null())
+ return;
+
+ BrowserPpapiHost::OnKeepaliveInstanceData instance_data(instance_map_.size());
+
+ InstanceMap::iterator instance = instance_map_.begin();
+ int i = 0;
+ while (instance != instance_map_.end()) {
+ instance_data[i].render_process_id = instance->second.render_process_id;
+ instance_data[i].render_frame_id = instance->second.render_frame_id;
+ instance_data[i].document_url = instance->second.document_url;
+ ++instance;
+ ++i;
+ }
+ on_keepalive_callback_.Run(instance_data, profile_data_directory_);
}
} // namespace content
diff --git a/chromium/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h b/chromium/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h
index 5d953422c1b..16fec3d2907 100644
--- a/chromium/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h
+++ b/chromium/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h
@@ -12,13 +12,14 @@
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "content/browser/renderer_host/pepper/content_browser_pepper_host_factory.h"
#include "content/browser/renderer_host/pepper/ssl_context_helper.h"
#include "content/common/content_export.h"
#include "content/common/pepper_renderer_instance_data.h"
#include "content/public/browser/browser_ppapi_host.h"
#include "content/public/common/process_type.h"
-#include "ipc/ipc_channel_proxy.h"
+#include "ipc/message_filter.h"
#include "ppapi/host/ppapi_host.h"
namespace content {
@@ -30,34 +31,35 @@ class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost {
// when this object is created).
// |external_plugin| signfies that this is a proxy created for an embedder's
// plugin, i.e. using BrowserPpapiHost::CreateExternalPluginProcess.
- BrowserPpapiHostImpl(
- IPC::Sender* sender,
- const ppapi::PpapiPermissions& permissions,
- const std::string& plugin_name,
- const base::FilePath& plugin_path,
- const base::FilePath& profile_data_directory,
- bool in_process,
- bool external_plugin);
+ BrowserPpapiHostImpl(IPC::Sender* sender,
+ const ppapi::PpapiPermissions& permissions,
+ const std::string& plugin_name,
+ const base::FilePath& plugin_path,
+ const base::FilePath& profile_data_directory,
+ bool in_process,
+ bool external_plugin);
virtual ~BrowserPpapiHostImpl();
// BrowserPpapiHost.
virtual ppapi::host::PpapiHost* GetPpapiHost() OVERRIDE;
virtual base::ProcessHandle GetPluginProcessHandle() const OVERRIDE;
virtual bool IsValidInstance(PP_Instance instance) const OVERRIDE;
- virtual bool GetRenderViewIDsForInstance(PP_Instance instance,
- int* render_process_id,
- int* render_view_id) const OVERRIDE;
+ virtual bool GetRenderFrameIDsForInstance(PP_Instance instance,
+ int* render_process_id,
+ int* render_frame_id) const
+ OVERRIDE;
virtual const std::string& GetPluginName() OVERRIDE;
virtual const base::FilePath& GetPluginPath() OVERRIDE;
virtual const base::FilePath& GetProfileDataDirectory() OVERRIDE;
virtual GURL GetDocumentURLForInstance(PP_Instance instance) OVERRIDE;
virtual GURL GetPluginURLForInstance(PP_Instance instance) OVERRIDE;
+ virtual void SetOnKeepaliveCallback(
+ const BrowserPpapiHost::OnKeepaliveCallback& callback) OVERRIDE;
void set_plugin_process_handle(base::ProcessHandle handle) {
plugin_process_handle_ = handle;
}
- bool in_process() const { return in_process_; }
bool external_plugin() const { return external_plugin_; }
// These two functions are notifications that an instance has been created
@@ -67,7 +69,7 @@ class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost {
const PepperRendererInstanceData& instance_data);
void DeleteInstance(PP_Instance instance);
- scoped_refptr<IPC::ChannelProxy::MessageFilter> message_filter() {
+ scoped_refptr<IPC::MessageFilter> message_filter() {
return message_filter_;
}
@@ -81,21 +83,30 @@ class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost {
// Implementing MessageFilter on BrowserPpapiHostImpl makes it ref-counted,
// preventing us from returning these to embedders without holding a
// reference. To avoid that, define a message filter object.
- class HostMessageFilter : public IPC::ChannelProxy::MessageFilter {
+ class HostMessageFilter : public IPC::MessageFilter {
public:
- explicit HostMessageFilter(ppapi::host::PpapiHost* ppapi_host)
- : ppapi_host_(ppapi_host) {}
- // IPC::ChannelProxy::MessageFilter.
+ HostMessageFilter(ppapi::host::PpapiHost* ppapi_host,
+ BrowserPpapiHostImpl* browser_ppapi_host_impl);
+
+ // IPC::MessageFilter.
virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
void OnHostDestroyed();
private:
- virtual ~HostMessageFilter() {}
+ virtual ~HostMessageFilter();
+
+ void OnKeepalive();
+ void OnHostMsgLogInterfaceUsage(int hash) const;
+ // Non owning pointers cleared in OnHostDestroyed()
ppapi::host::PpapiHost* ppapi_host_;
+ BrowserPpapiHostImpl* browser_ppapi_host_impl_;
};
+ // Reports plugin activity to the callback set with SetOnKeepaliveCallback.
+ void OnKeepalive();
+
scoped_ptr<ppapi::host::PpapiHost> ppapi_host_;
base::ProcessHandle plugin_process_handle_;
std::string plugin_name_;
@@ -118,6 +129,8 @@ class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost {
scoped_refptr<HostMessageFilter> message_filter_;
+ BrowserPpapiHost::OnKeepaliveCallback on_keepalive_callback_;
+
DISALLOW_COPY_AND_ASSIGN(BrowserPpapiHostImpl);
};
diff --git a/chromium/content/browser/renderer_host/pepper/browser_ppapi_host_test.cc b/chromium/content/browser/renderer_host/pepper/browser_ppapi_host_test.cc
index ecbcd0e120a..428f63544b0 100644
--- a/chromium/content/browser/renderer_host/pepper/browser_ppapi_host_test.cc
+++ b/chromium/content/browser/renderer_host/pepper/browser_ppapi_host_test.cc
@@ -8,21 +8,19 @@
namespace content {
-BrowserPpapiHostTest::BrowserPpapiHostTest()
- : sink_() {
- ppapi_host_.reset(new BrowserPpapiHostImpl(
- &sink_,
- ppapi::PpapiPermissions::AllPermissions(),
- std::string(),
- base::FilePath(),
- base::FilePath(),
- false /* in_process */,
- false /* external_plugin */));
+BrowserPpapiHostTest::BrowserPpapiHostTest() : sink_() {
+ ppapi_host_.reset(
+ new BrowserPpapiHostImpl(&sink_,
+ ppapi::PpapiPermissions::AllPermissions(),
+ std::string(),
+ base::FilePath(),
+ base::FilePath(),
+ false /* in_process */,
+ false /* external_plugin */));
ppapi_host_->set_plugin_process_handle(base::GetCurrentProcessHandle());
}
-BrowserPpapiHostTest::~BrowserPpapiHostTest() {
-}
+BrowserPpapiHostTest::~BrowserPpapiHostTest() {}
BrowserPpapiHost* BrowserPpapiHostTest::GetBrowserPpapiHost() {
return ppapi_host_.get();
diff --git a/chromium/content/browser/renderer_host/pepper/content_browser_pepper_host_factory.cc b/chromium/content/browser/renderer_host/pepper/content_browser_pepper_host_factory.cc
index afa539608af..e1ce0320b6e 100644
--- a/chromium/content/browser/renderer_host/pepper/content_browser_pepper_host_factory.cc
+++ b/chromium/content/browser/renderer_host/pepper/content_browser_pepper_host_factory.cc
@@ -38,22 +38,19 @@ namespace {
const size_t kMaxSocketsAllowed = 1024;
bool CanCreateSocket() {
- return
- PepperTCPServerSocketMessageFilter::GetNumInstances() +
- PepperTCPSocketMessageFilter::GetNumInstances() +
- PepperUDPSocketMessageFilter::GetNumInstances() <
- kMaxSocketsAllowed;
+ return PepperTCPServerSocketMessageFilter::GetNumInstances() +
+ PepperTCPSocketMessageFilter::GetNumInstances() +
+ PepperUDPSocketMessageFilter::GetNumInstances() <
+ kMaxSocketsAllowed;
}
} // namespace
ContentBrowserPepperHostFactory::ContentBrowserPepperHostFactory(
BrowserPpapiHostImpl* host)
- : host_(host) {
-}
+ : host_(host) {}
-ContentBrowserPepperHostFactory::~ContentBrowserPepperHostFactory() {
-}
+ContentBrowserPepperHostFactory::~ContentBrowserPepperHostFactory() {}
scoped_ptr<ResourceHost> ContentBrowserPepperHostFactory::CreateResourceHost(
ppapi::host::PpapiHost* host,
@@ -69,13 +66,13 @@ scoped_ptr<ResourceHost> ContentBrowserPepperHostFactory::CreateResourceHost(
// Public interfaces.
switch (message.type()) {
case PpapiHostMsg_FileIO_Create::ID: {
- return scoped_ptr<ResourceHost>(new PepperFileIOHost(
- host_, instance, params.pp_resource()));
+ return scoped_ptr<ResourceHost>(
+ new PepperFileIOHost(host_, instance, params.pp_resource()));
}
case PpapiHostMsg_FileSystem_Create::ID: {
PP_FileSystemType file_system_type;
- if (!ppapi::UnpackMessage<PpapiHostMsg_FileSystem_Create>(message,
- &file_system_type)) {
+ if (!ppapi::UnpackMessage<PpapiHostMsg_FileSystem_Create>(
+ message, &file_system_type)) {
NOTREACHED();
return scoped_ptr<ResourceHost>();
}
@@ -83,25 +80,27 @@ scoped_ptr<ResourceHost> ContentBrowserPepperHostFactory::CreateResourceHost(
host_, instance, params.pp_resource(), file_system_type));
}
case PpapiHostMsg_Gamepad_Create::ID: {
- return scoped_ptr<ResourceHost>(new PepperGamepadHost(
- host_, instance, params.pp_resource()));
+ return scoped_ptr<ResourceHost>(
+ new PepperGamepadHost(host_, instance, params.pp_resource()));
}
case PpapiHostMsg_NetworkProxy_Create::ID: {
- return scoped_ptr<ResourceHost>(new PepperNetworkProxyHost(
- host_, instance, params.pp_resource()));
+ return scoped_ptr<ResourceHost>(
+ new PepperNetworkProxyHost(host_, instance, params.pp_resource()));
}
case PpapiHostMsg_HostResolver_Create::ID: {
scoped_refptr<ResourceMessageFilter> host_resolver(
new PepperHostResolverMessageFilter(host_, instance, false));
- return scoped_ptr<ResourceHost>(new MessageFilterHost(
- host_->GetPpapiHost(), instance, params.pp_resource(),
- host_resolver));
+ return scoped_ptr<ResourceHost>(
+ new MessageFilterHost(host_->GetPpapiHost(),
+ instance,
+ params.pp_resource(),
+ host_resolver));
}
- case PpapiHostMsg_FileRef_CreateInternal::ID: {
+ case PpapiHostMsg_FileRef_CreateForFileAPI::ID: {
PP_Resource file_system;
std::string internal_path;
- if (!UnpackMessage<PpapiHostMsg_FileRef_CreateInternal>(
- message, &file_system, &internal_path)) {
+ if (!UnpackMessage<PpapiHostMsg_FileRef_CreateForFileAPI>(
+ message, &file_system, &internal_path)) {
NOTREACHED();
return scoped_ptr<ResourceHost>();
}
@@ -135,9 +134,11 @@ scoped_ptr<ResourceHost> ContentBrowserPepperHostFactory::CreateResourceHost(
case PpapiHostMsg_Printing_Create::ID: {
scoped_ptr<PepperPrintSettingsManager> manager(
new PepperPrintSettingsManagerImpl());
- return scoped_ptr<ResourceHost>(new PepperPrintingHost(
- host_->GetPpapiHost(), instance,
- params.pp_resource(), manager.Pass()));
+ return scoped_ptr<ResourceHost>(
+ new PepperPrintingHost(host_->GetPpapiHost(),
+ instance,
+ params.pp_resource(),
+ manager.Pass()));
}
case PpapiHostMsg_TrueTypeFontSingleton_Create::ID: {
return scoped_ptr<ResourceHost>(new PepperTrueTypeFontListHost(
@@ -171,16 +172,18 @@ scoped_ptr<ResourceHost> ContentBrowserPepperHostFactory::CreateResourceHost(
if (CanCreateSocket()) {
scoped_refptr<ResourceMessageFilter> tcp_server_socket(
new PepperTCPServerSocketMessageFilter(this, host_, instance, true));
- return scoped_ptr<ResourceHost>(new MessageFilterHost(
- host_->GetPpapiHost(), instance, params.pp_resource(),
- tcp_server_socket));
+ return scoped_ptr<ResourceHost>(
+ new MessageFilterHost(host_->GetPpapiHost(),
+ instance,
+ params.pp_resource(),
+ tcp_server_socket));
} else {
return scoped_ptr<ResourceHost>();
}
}
if (message.type() == PpapiHostMsg_TCPSocket_CreatePrivate::ID) {
- return CreateNewTCPSocket(instance, params.pp_resource(),
- ppapi::TCP_SOCKET_VERSION_PRIVATE);
+ return CreateNewTCPSocket(
+ instance, params.pp_resource(), ppapi::TCP_SOCKET_VERSION_PRIVATE);
}
if (message.type() == PpapiHostMsg_UDPSocket_CreatePrivate::ID) {
if (CanCreateSocket()) {
@@ -203,9 +206,11 @@ scoped_ptr<ResourceHost> ContentBrowserPepperHostFactory::CreateResourceHost(
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));
+ return scoped_ptr<ResourceHost>(
+ new MessageFilterHost(host_->GetPpapiHost(),
+ instance,
+ params.pp_resource(),
+ file_filter));
}
}
}
@@ -221,10 +226,10 @@ ContentBrowserPepperHostFactory::CreateAcceptedTCPSocket(
if (!CanCreateSocket())
return scoped_ptr<ResourceHost>();
scoped_refptr<ResourceMessageFilter> tcp_socket(
- new PepperTCPSocketMessageFilter(host_, instance, version,
- socket.Pass()));
- return scoped_ptr<ResourceHost>(new MessageFilterHost(
- host_->GetPpapiHost(), instance, 0, tcp_socket));
+ new PepperTCPSocketMessageFilter(
+ host_, instance, version, socket.Pass()));
+ return scoped_ptr<ResourceHost>(
+ new MessageFilterHost(host_->GetPpapiHost(), instance, 0, tcp_socket));
}
scoped_ptr<ppapi::host::ResourceHost>
@@ -244,8 +249,8 @@ ContentBrowserPepperHostFactory::CreateNewTCPSocket(
host_->GetPpapiHost(), instance, resource, tcp_socket));
}
-const ppapi::PpapiPermissions&
-ContentBrowserPepperHostFactory::GetPermissions() const {
+const ppapi::PpapiPermissions& ContentBrowserPepperHostFactory::GetPermissions()
+ const {
return host_->GetPpapiHost()->permissions();
}
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_browser_font_singleton_host.cc b/chromium/content/browser/renderer_host/pepper/pepper_browser_font_singleton_host.cc
index 99a8e04fc70..40c13dfee01 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_browser_font_singleton_host.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_browser_font_singleton_host.cc
@@ -38,11 +38,9 @@ class FontMessageFilter : public ppapi::host::ResourceMessageFilter {
DISALLOW_COPY_AND_ASSIGN(FontMessageFilter);
};
-FontMessageFilter::FontMessageFilter() {
-}
+FontMessageFilter::FontMessageFilter() {}
-FontMessageFilter::~FontMessageFilter() {
-}
+FontMessageFilter::~FontMessageFilter() {}
scoped_refptr<base::TaskRunner> FontMessageFilter::OverrideTaskRunnerForMessage(
const IPC::Message& msg) {
@@ -57,11 +55,11 @@ scoped_refptr<base::TaskRunner> FontMessageFilter::OverrideTaskRunnerForMessage(
int32_t FontMessageFilter::OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) {
- IPC_BEGIN_MESSAGE_MAP(FontMessageFilter, msg)
+ PPAPI_BEGIN_MESSAGE_MAP(FontMessageFilter, msg)
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
PpapiHostMsg_BrowserFontSingleton_GetFontFamilies,
OnHostMsgGetFontFamilies)
- IPC_END_MESSAGE_MAP()
+ PPAPI_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
@@ -105,7 +103,6 @@ PepperBrowserFontSingletonHost::PepperBrowserFontSingletonHost(
new FontMessageFilter()));
}
-PepperBrowserFontSingletonHost::~PepperBrowserFontSingletonHost() {
-}
+PepperBrowserFontSingletonHost::~PepperBrowserFontSingletonHost() {}
} // namespace content
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.cc b/chromium/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.cc
index 4517e3725c0..a6b61981ac5 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.cc
@@ -20,20 +20,20 @@ namespace content {
PepperExternalFileRefBackend::PepperExternalFileRefBackend(
ppapi::host::PpapiHost* host,
int render_process_id,
- const base::FilePath& path) : host_(host),
- path_(path),
- render_process_id_(render_process_id),
- weak_factory_(this) {
+ const base::FilePath& path)
+ : host_(host),
+ path_(path),
+ render_process_id_(render_process_id),
+ weak_factory_(this) {
task_runner_ =
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE);
}
-PepperExternalFileRefBackend::~PepperExternalFileRefBackend() {
-}
+PepperExternalFileRefBackend::~PepperExternalFileRefBackend() {}
int32_t PepperExternalFileRefBackend::MakeDirectory(
ppapi::host::ReplyMessageContext reply_context,
- bool make_ancestors) {
+ int32_t make_directory_flags) {
// This operation isn't supported for external filesystems.
return PP_ERROR_NOACCESS;
}
@@ -88,7 +88,8 @@ int32_t PepperExternalFileRefBackend::ReadDirectoryEntries(
int32_t PepperExternalFileRefBackend::GetAbsolutePath(
ppapi::host::ReplyMessageContext reply_context) {
- host_->SendReply(reply_context,
+ host_->SendReply(
+ reply_context,
PpapiPluginMsg_FileRef_GetAbsolutePathReply(path_.AsUTF8Unsafe()));
// Use PP_OK_COMPLETIONPENDING instead of PP_OK since we've already sent our
@@ -105,8 +106,8 @@ base::FilePath PepperExternalFileRefBackend::GetExternalFilePath() const {
}
int32_t PepperExternalFileRefBackend::CanRead() const {
- if (!ChildProcessSecurityPolicyImpl::GetInstance()->
- CanReadFile(render_process_id_, path_)) {
+ if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(
+ render_process_id_, path_)) {
return PP_ERROR_NOACCESS;
}
return PP_OK;
@@ -123,8 +124,8 @@ int32_t PepperExternalFileRefBackend::CanCreate() const {
}
int32_t PepperExternalFileRefBackend::CanReadWrite() const {
- if (!ChildProcessSecurityPolicyImpl::GetInstance()->
- CanCreateReadWriteFile(render_process_id_, path_)) {
+ if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanCreateReadWriteFile(
+ render_process_id_, path_)) {
return PP_ERROR_NOACCESS;
}
return PP_OK;
@@ -133,20 +134,20 @@ int32_t PepperExternalFileRefBackend::CanReadWrite() const {
void PepperExternalFileRefBackend::DidFinish(
ppapi::host::ReplyMessageContext reply_context,
const IPC::Message& msg,
- base::PlatformFileError error) {
- reply_context.params.set_result(ppapi::PlatformFileErrorToPepperError(error));
+ base::File::Error error) {
+ reply_context.params.set_result(ppapi::FileErrorToPepperError(error));
host_->SendReply(reply_context, msg);
}
void PepperExternalFileRefBackend::GetMetadataComplete(
ppapi::host::ReplyMessageContext reply_context,
- const base::PlatformFileError error,
- const base::PlatformFileInfo& file_info) {
- reply_context.params.set_result(ppapi::PlatformFileErrorToPepperError(error));
+ const base::File::Error error,
+ const base::File::Info& file_info) {
+ reply_context.params.set_result(ppapi::FileErrorToPepperError(error));
PP_FileInfo pp_file_info;
- if (error == base::PLATFORM_FILE_OK) {
- ppapi::PlatformFileInfoToPepperFileInfo(
+ if (error == base::File::FILE_OK) {
+ ppapi::FileInfoToPepperFileInfo(
file_info, PP_FILESYSTEMTYPE_EXTERNAL, &pp_file_info);
} else {
memset(&pp_file_info, 0, sizeof(pp_file_info));
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.h b/chromium/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.h
index 525749d7893..4d2980ae421 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.h
+++ b/chromium/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.h
@@ -7,6 +7,7 @@
#include <string>
+#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/task_runner.h"
@@ -28,7 +29,7 @@ class PepperExternalFileRefBackend : public PepperFileRefBackend {
// PepperFileRefBackend overrides.
virtual int32_t MakeDirectory(ppapi::host::ReplyMessageContext context,
- bool make_ancestors) OVERRIDE;
+ int32_t make_directory_flags) OVERRIDE;
virtual int32_t Touch(ppapi::host::ReplyMessageContext context,
PP_Time last_accessed_time,
PP_Time last_modified_time) OVERRIDE;
@@ -36,8 +37,8 @@ class PepperExternalFileRefBackend : public PepperFileRefBackend {
virtual int32_t Rename(ppapi::host::ReplyMessageContext context,
PepperFileRefHost* new_file_ref) OVERRIDE;
virtual int32_t Query(ppapi::host::ReplyMessageContext context) OVERRIDE;
- virtual int32_t ReadDirectoryEntries(
- ppapi::host::ReplyMessageContext context) OVERRIDE;
+ virtual int32_t ReadDirectoryEntries(ppapi::host::ReplyMessageContext context)
+ OVERRIDE;
virtual int32_t GetAbsolutePath(ppapi::host::ReplyMessageContext context)
OVERRIDE;
virtual fileapi::FileSystemURL GetFileSystemURL() const OVERRIDE;
@@ -52,13 +53,12 @@ class PepperExternalFileRefBackend : public PepperFileRefBackend {
// Generic reply callback.
void DidFinish(ppapi::host::ReplyMessageContext reply_context,
const IPC::Message& msg,
- base::PlatformFileError error);
+ base::File::Error error);
// Operation specific callbacks.
- void GetMetadataComplete(
- ppapi::host::ReplyMessageContext reply_context,
- base::PlatformFileError error,
- const base::PlatformFileInfo& file_info);
+ void GetMetadataComplete(ppapi::host::ReplyMessageContext reply_context,
+ base::File::Error error,
+ const base::File::Info& file_info);
ppapi::host::PpapiHost* host_;
base::FilePath path_;
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_file_io_host.cc b/chromium/content/browser/renderer_host/pepper/pepper_file_io_host.cc
index 66a0ad2ae40..e350138f8a7 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_file_io_host.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_file_io_host.cc
@@ -41,17 +41,10 @@ using ppapi::PPTimeToTime;
namespace {
-int32_t ErrorOrByteNumber(int32_t pp_error, int32_t byte_number) {
- // On the plugin side, some callbacks expect a parameter that means different
- // things depending on whether it is negative or not. We translate for those
- // callbacks here.
- return pp_error == PP_OK ? byte_number : pp_error;
-}
-
-PepperFileIOHost::UIThreadStuff
-GetUIThreadStuffForInternalFileSystems(int render_process_id) {
+PepperFileIOHost::UIThreadStuff GetUIThreadStuffForInternalFileSystems(
+ int render_process_id) {
PepperFileIOHost::UIThreadStuff stuff;
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
RenderProcessHost* host = RenderProcessHost::FromID(render_process_id);
if (host) {
stuff.resolved_render_process_id = base::GetProcId(host->GetHandle());
@@ -63,7 +56,7 @@ GetUIThreadStuffForInternalFileSystems(int render_process_id) {
}
base::ProcessId GetResolvedRenderProcessId(int render_process_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
RenderProcessHost* host = RenderProcessHost::FromID(render_process_id);
if (!host)
return base::kNullProcessId;
@@ -72,13 +65,42 @@ base::ProcessId GetResolvedRenderProcessId(int render_process_id) {
bool GetPluginAllowedToCallRequestOSFileHandle(int render_process_id,
const GURL& document_url) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
ContentBrowserClient* client = GetContentClient()->browser();
RenderProcessHost* host = RenderProcessHost::FromID(render_process_id);
+ if (!host)
+ return false;
return client->IsPluginAllowedToCallRequestOSFileHandle(
host->GetBrowserContext(), document_url);
}
+bool FileOpenForWrite(int32_t open_flags) {
+ return (open_flags & (PP_FILEOPENFLAG_WRITE | PP_FILEOPENFLAG_APPEND)) != 0;
+}
+
+void FileCloser(base::File auto_close) {
+}
+
+void DidCloseFile(const base::Closure& on_close_callback) {
+ if (!on_close_callback.is_null())
+ on_close_callback.Run();
+}
+
+void DidOpenFile(base::WeakPtr<PepperFileIOHost> file_host,
+ fileapi::FileSystemOperation::OpenFileCallback callback,
+ base::File file,
+ const base::Closure& on_close_callback) {
+ if (file_host) {
+ callback.Run(file.Pass(), on_close_callback);
+ } else {
+ BrowserThread::PostTaskAndReply(
+ BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(&FileCloser, base::Passed(&file)),
+ base::Bind(&DidCloseFile, on_close_callback));
+ }
+}
+
} // namespace
PepperFileIOHost::PepperFileIOHost(BrowserPpapiHostImpl* host,
@@ -87,45 +109,34 @@ PepperFileIOHost::PepperFileIOHost(BrowserPpapiHostImpl* host,
: ResourceHost(host->GetPpapiHost(), instance, resource),
browser_ppapi_host_(host),
render_process_host_(NULL),
- file_(base::kInvalidPlatformFileValue),
+ file_(BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)),
open_flags_(0),
file_system_type_(PP_FILESYSTEMTYPE_INVALID),
max_written_offset_(0),
- check_quota_(false),
- weak_factory_(this) {
+ check_quota_(false) {
int unused;
- if (!host->GetRenderViewIDsForInstance(instance,
- &render_process_id_,
- &unused)) {
+ if (!host->GetRenderFrameIDsForInstance(
+ instance, &render_process_id_, &unused)) {
render_process_id_ = -1;
}
- file_message_loop_ = BrowserThread::GetMessageLoopProxyForThread(
- BrowserThread::FILE);
}
-PepperFileIOHost::~PepperFileIOHost() {
- OnHostMsgClose(NULL);
-}
+PepperFileIOHost::~PepperFileIOHost() {}
int32_t PepperFileIOHost::OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) {
- IPC_BEGIN_MESSAGE_MAP(PepperFileIOHost, msg)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileIO_Open,
- OnHostMsgOpen)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileIO_Touch,
- OnHostMsgTouch)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileIO_Write,
- OnHostMsgWrite)
+ PPAPI_BEGIN_MESSAGE_MAP(PepperFileIOHost, msg)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileIO_Open, OnHostMsgOpen)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileIO_Touch, OnHostMsgTouch)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileIO_SetLength,
OnHostMsgSetLength)
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileIO_Flush,
OnHostMsgFlush)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileIO_Close,
- OnHostMsgClose)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileIO_Close, OnHostMsgClose)
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileIO_RequestOSFileHandle,
OnHostMsgRequestOSFileHandle)
- IPC_END_MESSAGE_MAP()
+ PPAPI_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
@@ -133,8 +144,7 @@ PepperFileIOHost::UIThreadStuff::UIThreadStuff() {
resolved_render_process_id = base::kNullProcessId;
}
-PepperFileIOHost::UIThreadStuff::~UIThreadStuff() {
-}
+PepperFileIOHost::UIThreadStuff::~UIThreadStuff() {}
int32_t PepperFileIOHost::OnHostMsgOpen(
ppapi::host::HostMessageContext* context,
@@ -165,20 +175,38 @@ int32_t PepperFileIOHost::OnHostMsgOpen(
file_system_type_ = file_ref_host->GetFileSystemType();
file_system_url_ = file_ref_host->GetFileSystemURL();
- if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL) {
+ // For external file systems, if there is a valid FileSystemURL, then treat
+ // it like internal file systems and access it via the FileSystemURL.
+ bool is_internal_type = (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL) ||
+ file_system_url_.is_valid();
+
+ if (is_internal_type) {
if (!file_system_url_.is_valid())
return PP_ERROR_BADARGUMENT;
- if (!CanOpenFileSystemURLWithPepperFlags(open_flags,
- render_process_id_,
- file_system_url_))
+
+ // Not all external file systems are fully supported yet.
+ // Whitelist the supported ones.
+ if (file_system_url_.mount_type() == fileapi::kFileSystemTypeExternal) {
+ switch (file_system_url_.type()) {
+ case fileapi::kFileSystemTypeNativeMedia:
+ case fileapi::kFileSystemTypeDeviceMedia:
+ case fileapi::kFileSystemTypePicasa:
+ case fileapi::kFileSystemTypeItunes:
+ case fileapi::kFileSystemTypeIphoto:
+ break;
+ default:
+ return PP_ERROR_NOACCESS;
+ }
+ }
+ if (!CanOpenFileSystemURLWithPepperFlags(
+ open_flags, render_process_id_, file_system_url_))
return PP_ERROR_NOACCESS;
BrowserThread::PostTaskAndReplyWithResult(
BrowserThread::UI,
FROM_HERE,
- base::Bind(&GetUIThreadStuffForInternalFileSystems,
- render_process_id_),
+ base::Bind(&GetUIThreadStuffForInternalFileSystems, render_process_id_),
base::Bind(&PepperFileIOHost::GotUIThreadStuffForInternalFileSystems,
- weak_factory_.GetWeakPtr(),
+ AsWeakPtr(),
context->MakeReplyMessageContext(),
platform_file_flags));
} else {
@@ -190,7 +218,7 @@ int32_t PepperFileIOHost::OnHostMsgOpen(
FROM_HERE,
base::Bind(&GetResolvedRenderProcessId, render_process_id_),
base::Bind(&PepperFileIOHost::GotResolvedRenderProcessId,
- weak_factory_.GetWeakPtr(),
+ AsWeakPtr(),
context->MakeReplyMessageContext(),
path,
platform_file_flags));
@@ -203,70 +231,74 @@ void PepperFileIOHost::GotUIThreadStuffForInternalFileSystems(
ppapi::host::ReplyMessageContext reply_context,
int platform_file_flags,
UIThreadStuff ui_thread_stuff) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
file_system_context_ = ui_thread_stuff.file_system_context;
resolved_render_process_id_ = ui_thread_stuff.resolved_render_process_id;
if (resolved_render_process_id_ == base::kNullProcessId ||
!file_system_context_.get()) {
reply_context.params.set_result(PP_ERROR_FAILED);
- host()->SendReply(reply_context, PpapiPluginMsg_FileIO_OpenReply());
+ SendOpenErrorReply(reply_context);
return;
}
if (!file_system_context_->GetFileSystemBackend(file_system_url_.type())) {
reply_context.params.set_result(PP_ERROR_FAILED);
- host()->SendReply(reply_context, PpapiPluginMsg_FileIO_OpenReply());
+ SendOpenErrorReply(reply_context);
return;
}
DCHECK(file_system_host_.get());
DCHECK(file_system_host_->GetFileSystemOperationRunner());
+
file_system_host_->GetFileSystemOperationRunner()->OpenFile(
file_system_url_,
platform_file_flags,
- base::Bind(&PepperFileIOHost::DidOpenInternalFile,
- weak_factory_.GetWeakPtr(),
- reply_context));
+ base::Bind(&DidOpenFile,
+ AsWeakPtr(),
+ base::Bind(&PepperFileIOHost::DidOpenInternalFile,
+ AsWeakPtr(),
+ reply_context)));
}
void PepperFileIOHost::DidOpenInternalFile(
ppapi::host::ReplyMessageContext reply_context,
- base::PlatformFileError result,
- base::PlatformFile file,
+ base::File file,
const base::Closure& on_close_callback) {
- if (result == base::PLATFORM_FILE_OK) {
+ if (file.IsValid()) {
on_close_callback_ = on_close_callback;
- check_quota_ = file_system_host_ && file_system_host_->ChecksQuota();
- if (check_quota_) {
+ if (FileOpenForWrite(open_flags_) && file_system_host_->ChecksQuota()) {
+ check_quota_ = true;
file_system_host_->OpenQuotaFile(
this,
file_system_url_,
base::Bind(&PepperFileIOHost::DidOpenQuotaFile,
- weak_factory_.GetWeakPtr(),
+ AsWeakPtr(),
reply_context,
- file));
+ base::Passed(&file)));
return;
}
}
- ExecutePlatformOpenFileCallback(
- reply_context, result, base::PassPlatformFile(&file), true);
+ DCHECK(!file_.IsValid());
+ base::File::Error error =
+ file.IsValid() ? base::File::FILE_OK : file.error_details();
+ file_.SetFile(file.Pass());
+ OnOpenProxyCallback(reply_context, error);
}
void PepperFileIOHost::GotResolvedRenderProcessId(
ppapi::host::ReplyMessageContext reply_context,
base::FilePath path,
- int platform_file_flags,
+ int file_flags,
base::ProcessId resolved_render_process_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
resolved_render_process_id_ = resolved_render_process_id;
- base::FileUtilProxy::CreateOrOpen(
- file_message_loop_,
+ file_.CreateOrOpen(
path,
- platform_file_flags,
- base::Bind(&PepperFileIOHost::ExecutePlatformOpenFileCallback,
- weak_factory_.GetWeakPtr(),
+ file_flags,
+ base::Bind(&PepperFileIOHost::OnOpenProxyCallback,
+ AsWeakPtr(),
reply_context));
}
@@ -279,66 +311,16 @@ int32_t PepperFileIOHost::OnHostMsgTouch(
if (rv != PP_OK)
return rv;
- if (!base::FileUtilProxy::Touch(
- file_message_loop_,
- file_,
+ if (!file_.SetTimes(
PPTimeToTime(last_access_time),
PPTimeToTime(last_modified_time),
base::Bind(&PepperFileIOHost::ExecutePlatformGeneralCallback,
- weak_factory_.GetWeakPtr(),
- context->MakeReplyMessageContext())))
+ AsWeakPtr(),
+ context->MakeReplyMessageContext()))) {
return PP_ERROR_FAILED;
-
- state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE);
- return PP_OK_COMPLETIONPENDING;
-}
-
-int32_t PepperFileIOHost::OnHostMsgWrite(
- ppapi::host::HostMessageContext* context,
- int64_t offset,
- const std::string& buffer) {
- int32_t rv = state_manager_.CheckOperationState(
- FileIOStateManager::OPERATION_WRITE, true);
- if (rv != PP_OK)
- return rv;
- if (offset < 0)
- return PP_ERROR_BADARGUMENT;
-
- if (check_quota_) {
- int64_t actual_offset =
- (open_flags_ & PP_FILEOPENFLAG_APPEND) ? max_written_offset_ : offset;
-
- uint64_t max_offset = actual_offset + buffer.size();
- if (max_offset > static_cast<uint64_t>(std::numeric_limits<int64_t>::max()))
- return PP_ERROR_FAILED; // max_offset overflows.
- int64_t amount = static_cast<int64_t>(max_offset) - max_written_offset_;
-
- // Quota request amounts are restricted to 32 bits so we can use atomics
- // when we move this code to the plugin side of the proxy.
- if (amount > std::numeric_limits<int32_t>::max())
- return PP_ERROR_NOQUOTA;
-
- if (amount > 0) {
- int32_t result = file_system_host_->RequestQuota(
- static_cast<int32_t>(amount),
- base::Bind(&PepperFileIOHost::GotWriteQuota,
- weak_factory_.GetWeakPtr(),
- context->MakeReplyMessageContext(),
- offset, buffer));
- if (result == PP_OK_COMPLETIONPENDING) {
- state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_WRITE);
- return result;
- }
- // RequestQuota returns either PP_OK_COMPLETIONPENDING or the requested
- // quota amount.
- DCHECK(result > 0);
- }
}
- if (!CallWrite(context->MakeReplyMessageContext(), offset, buffer))
- return PP_ERROR_FAILED;
-
- state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_WRITE);
+ state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE);
return PP_OK_COMPLETIONPENDING;
}
@@ -352,33 +334,16 @@ int32_t PepperFileIOHost::OnHostMsgSetLength(
if (length < 0)
return PP_ERROR_BADARGUMENT;
- if (check_quota_) {
- int64_t amount = length - max_written_offset_;
- // Quota request amounts are restricted to 32 bits so we can use atomics
- // when we move this code to the plugin side of the proxy.
- if (amount > std::numeric_limits<int32_t>::max())
- return PP_ERROR_NOQUOTA;
-
- if (amount > 0) {
- int32_t result = file_system_host_->RequestQuota(
- static_cast<int32_t>(amount),
- base::Bind(&PepperFileIOHost::GotSetLengthQuota,
- weak_factory_.GetWeakPtr(),
- context->MakeReplyMessageContext(),
- length));
- if (result == PP_OK_COMPLETIONPENDING) {
- state_manager_.SetPendingOperation(
- FileIOStateManager::OPERATION_EXCLUSIVE);
- return result;
- }
- // RequestQuota returns either PP_OK_COMPLETIONPENDING or the requested
- // quota amount.
- DCHECK(result > 0);
- }
- }
+ // Quota checks are performed on the plugin side, in order to use the same
+ // quota reservation and request system as Write.
- if (!CallSetLength(context->MakeReplyMessageContext(), length))
+ if (!file_.SetLength(
+ length,
+ base::Bind(&PepperFileIOHost::ExecutePlatformGeneralCallback,
+ AsWeakPtr(),
+ context->MakeReplyMessageContext()))) {
return PP_ERROR_FAILED;
+ }
state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE);
return PP_OK_COMPLETIONPENDING;
@@ -391,111 +356,45 @@ int32_t PepperFileIOHost::OnHostMsgFlush(
if (rv != PP_OK)
return rv;
- if (!base::FileUtilProxy::Flush(
- file_message_loop_,
- file_,
+ if (!file_.Flush(
base::Bind(&PepperFileIOHost::ExecutePlatformGeneralCallback,
- weak_factory_.GetWeakPtr(),
- context->MakeReplyMessageContext())))
+ AsWeakPtr(),
+ context->MakeReplyMessageContext()))) {
return PP_ERROR_FAILED;
+ }
state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE);
return PP_OK_COMPLETIONPENDING;
}
int32_t PepperFileIOHost::OnHostMsgClose(
- ppapi::host::HostMessageContext* context) {
+ ppapi::host::HostMessageContext* context,
+ const ppapi::FileGrowth& file_growth) {
if (check_quota_) {
- file_system_host_->CloseQuotaFile(this);
+ file_system_host_->CloseQuotaFile(this, file_growth);
check_quota_ = false;
}
- if (file_ != base::kInvalidPlatformFileValue) {
- base::FileUtilProxy::Close(
- file_message_loop_,
- file_,
- base::Bind(&PepperFileIOHost::DidCloseFile,
- weak_factory_.GetWeakPtr()));
- file_ = base::kInvalidPlatformFileValue;
+ if (file_.IsValid()) {
+ file_.Close(base::Bind(&PepperFileIOHost::DidCloseFile,
+ AsWeakPtr()));
}
return PP_OK;
}
void PepperFileIOHost::DidOpenQuotaFile(
ppapi::host::ReplyMessageContext reply_context,
- base::PlatformFile file,
+ base::File file,
int64_t max_written_offset) {
+ DCHECK(!file_.IsValid());
+ DCHECK(file.IsValid());
max_written_offset_ = max_written_offset;
- DCHECK_LE(0, max_written_offset_);
+ file_.SetFile(file.Pass());
- ExecutePlatformOpenFileCallback(
- reply_context, base::PLATFORM_FILE_OK, base::PassPlatformFile(&file),
- true);
+ OnOpenProxyCallback(reply_context, base::File::FILE_OK);
}
-void PepperFileIOHost::GotWriteQuota(
- ppapi::host::ReplyMessageContext reply_context,
- int64_t offset,
- const std::string& buffer,
- int32_t granted) {
- if (granted == 0) {
- reply_context.params.set_result(PP_ERROR_NOQUOTA);
- } else if (!CallWrite(reply_context, offset, buffer)) {
- reply_context.params.set_result(PP_ERROR_FAILED);
- } else {
- max_written_offset_ += granted;
- return;
- }
- // Return the error result set above.
- host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply());
- state_manager_.SetOperationFinished();
-}
-
-void PepperFileIOHost::GotSetLengthQuota(
- ppapi::host::ReplyMessageContext reply_context,
- int64_t length,
- int32_t granted) {
- if (granted == 0) {
- reply_context.params.set_result(PP_ERROR_NOQUOTA);
- } else if (!CallSetLength(reply_context, length)) {
- reply_context.params.set_result(PP_ERROR_FAILED);
- } else {
- max_written_offset_ += granted;
- return;
- }
- // Return the error result set above.
- host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply());
- state_manager_.SetOperationFinished();
-}
-
-bool PepperFileIOHost::CallWrite(
- ppapi::host::ReplyMessageContext reply_context,
- int64_t offset,
- const std::string& buffer) {
- return base::FileUtilProxy::Write(
- file_message_loop_,
- file_,
- offset,
- buffer.c_str(),
- buffer.size(),
- base::Bind(&PepperFileIOHost::ExecutePlatformWriteCallback,
- weak_factory_.GetWeakPtr(),
- reply_context));
-}
-
-bool PepperFileIOHost::CallSetLength(
- ppapi::host::ReplyMessageContext reply_context,
- int64_t length) {
- return base::FileUtilProxy::Truncate(
- file_message_loop_,
- file_,
- length,
- base::Bind(&PepperFileIOHost::ExecutePlatformGeneralCallback,
- weak_factory_.GetWeakPtr(),
- reply_context));
-}
-
-void PepperFileIOHost::DidCloseFile(base::PlatformFileError error) {
+void PepperFileIOHost::DidCloseFile(base::File::Error /*error*/) {
// Silently ignore if we fail to close the file.
if (!on_close_callback_.is_null()) {
on_close_callback_.Run();
@@ -517,7 +416,7 @@ int32_t PepperFileIOHost::OnHostMsgRequestOSFileHandle(
render_process_id_,
document_url),
base::Bind(&PepperFileIOHost::GotPluginAllowedToCallRequestOSFileHandle,
- weak_factory_.GetWeakPtr(),
+ AsWeakPtr(),
context->MakeReplyMessageContext()));
return PP_OK_COMPLETIONPENDING;
}
@@ -525,7 +424,7 @@ int32_t PepperFileIOHost::OnHostMsgRequestOSFileHandle(
void PepperFileIOHost::GotPluginAllowedToCallRequestOSFileHandle(
ppapi::host::ReplyMessageContext reply_context,
bool plugin_allowed) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!browser_ppapi_host_->external_plugin() ||
host()->permissions().HasPermission(ppapi::PERMISSION_PRIVATE) ||
plugin_allowed) {
@@ -540,70 +439,57 @@ void PepperFileIOHost::GotPluginAllowedToCallRequestOSFileHandle(
void PepperFileIOHost::ExecutePlatformGeneralCallback(
ppapi::host::ReplyMessageContext reply_context,
- base::PlatformFileError error_code) {
- reply_context.params.set_result(
- ppapi::PlatformFileErrorToPepperError(error_code));
+ base::File::Error error_code) {
+ reply_context.params.set_result(ppapi::FileErrorToPepperError(error_code));
host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply());
state_manager_.SetOperationFinished();
}
-void PepperFileIOHost::ExecutePlatformOpenFileCallback(
+void PepperFileIOHost::OnOpenProxyCallback(
ppapi::host::ReplyMessageContext reply_context,
- base::PlatformFileError error_code,
- base::PassPlatformFile file,
- bool unused_created) {
- int32_t pp_error = ppapi::PlatformFileErrorToPepperError(error_code);
- if (pp_error == PP_OK)
- state_manager_.SetOpenSucceed();
+ base::File::Error error_code) {
+ int32_t pp_error = ppapi::FileErrorToPepperError(error_code);
+ if (file_.IsValid() && !AddFileToReplyContext(open_flags_, &reply_context))
+ pp_error = PP_ERROR_FAILED;
- DCHECK(file_ == base::kInvalidPlatformFileValue);
- file_ = file.ReleaseValue();
-
- if (file_ != base::kInvalidPlatformFileValue) {
- int32_t flags_to_send = open_flags_;
- if (!host()->permissions().HasPermission(ppapi::PERMISSION_DEV)) {
- // IMPORTANT: Clear PP_FILEOPENFLAG_WRITE and PP_FILEOPENFLAG_APPEND so
- // the plugin can't write and so bypass our quota checks.
- flags_to_send =
- open_flags_ & ~(PP_FILEOPENFLAG_WRITE | PP_FILEOPENFLAG_APPEND);
- }
- if (!AddFileToReplyContext(flags_to_send, &reply_context))
- pp_error = PP_ERROR_FAILED;
+ PP_Resource quota_file_system = 0;
+ if (pp_error == PP_OK) {
+ state_manager_.SetOpenSucceed();
+ // A non-zero resource id signals the plugin side to check quota.
+ if (check_quota_)
+ quota_file_system = file_system_host_->pp_resource();
}
+
reply_context.params.set_result(pp_error);
- host()->SendReply(reply_context, PpapiPluginMsg_FileIO_OpenReply());
+ host()->SendReply(
+ reply_context,
+ PpapiPluginMsg_FileIO_OpenReply(quota_file_system, max_written_offset_));
state_manager_.SetOperationFinished();
}
-void PepperFileIOHost::ExecutePlatformWriteCallback(
- ppapi::host::ReplyMessageContext reply_context,
- base::PlatformFileError error_code,
- int bytes_written) {
- // On the plugin side, the callback expects a parameter with different meaning
- // depends on whether is negative or not. It is the result here. We translate
- // for the callback.
- int32_t pp_error = ppapi::PlatformFileErrorToPepperError(error_code);
- reply_context.params.set_result(ErrorOrByteNumber(pp_error, bytes_written));
- host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply());
- state_manager_.SetOperationFinished();
+void PepperFileIOHost::SendOpenErrorReply(
+ ppapi::host::ReplyMessageContext reply_context) {
+ host()->SendReply(reply_context, PpapiPluginMsg_FileIO_OpenReply(0, 0));
}
bool PepperFileIOHost::AddFileToReplyContext(
int32_t open_flags,
ppapi::host::ReplyMessageContext* reply_context) const {
- base::ProcessId plugin_process_id;
- if (browser_ppapi_host_->in_process()) {
+ base::ProcessId plugin_process_id =
+ base::GetProcId(browser_ppapi_host_->GetPluginProcessHandle());
+ if (plugin_process_id == base::kNullProcessId)
plugin_process_id = resolved_render_process_id_;
- } else {
- plugin_process_id = base::GetProcId(
- browser_ppapi_host_->GetPluginProcessHandle());
- }
- IPC::PlatformFileForTransit transit_file = BrokerGetFileHandleForProcess(
- file_, plugin_process_id, false);
+
+ IPC::PlatformFileForTransit transit_file =
+ BrokerGetFileHandleForProcess(file_.GetPlatformFile(), plugin_process_id,
+ false);
if (transit_file == IPC::InvalidPlatformFileForTransit())
return false;
+
ppapi::proxy::SerializedHandle file_handle;
- file_handle.set_file_handle(transit_file, open_flags);
+ // A non-zero resource id signals NaClIPCAdapter to create a NaClQuotaDesc.
+ PP_Resource quota_file_io = check_quota_ ? pp_resource() : 0;
+ file_handle.set_file_handle(transit_file, open_flags, quota_file_io);
reply_context->params.AppendHandle(file_handle);
return true;
}
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_file_io_host.h b/chromium/content/browser/renderer_host/pepper/pepper_file_io_host.h
index 9394e6c7f28..abef036c95b 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_file_io_host.h
+++ b/chromium/content/browser/renderer_host/pepper/pepper_file_io_host.h
@@ -9,6 +9,8 @@
#include "base/basictypes.h"
#include "base/callback_forward.h"
+#include "base/files/file.h"
+#include "base/files/file_proxy.h"
#include "base/memory/weak_ptr.h"
#include "base/platform_file.h"
#include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h"
@@ -22,14 +24,17 @@
#include "url/gurl.h"
#include "webkit/browser/fileapi/file_system_context.h"
+namespace ppapi {
+struct FileGrowth;
+}
+
namespace content {
class PepperFileSystemBrowserHost;
class PepperFileIOHost : public ppapi::host::ResourceHost,
public base::SupportsWeakPtr<PepperFileIOHost> {
public:
- typedef base::Callback<void (base::PlatformFileError)>
- NotifyCloseFileCallback;
+ typedef base::Callback<void(base::File::Error)> NotifyCloseFileCallback;
PepperFileIOHost(BrowserPpapiHostImpl* host,
PP_Instance instance,
@@ -41,18 +46,13 @@ class PepperFileIOHost : public ppapi::host::ResourceHost,
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) OVERRIDE;
- // Direct access for PepperFileSystemBrowserHost.
- int64_t max_written_offset() const { return max_written_offset_; }
- void set_max_written_offset(int64_t max_written_offset) {
- max_written_offset_ = max_written_offset;
- }
-
struct UIThreadStuff {
UIThreadStuff();
~UIThreadStuff();
base::ProcessId resolved_render_process_id;
scoped_refptr<fileapi::FileSystemContext> file_system_context;
};
+
private:
int32_t OnHostMsgOpen(ppapi::host::HostMessageContext* context,
PP_Resource file_ref_resource,
@@ -60,12 +60,10 @@ class PepperFileIOHost : public ppapi::host::ResourceHost,
int32_t OnHostMsgTouch(ppapi::host::HostMessageContext* context,
PP_Time last_access_time,
PP_Time last_modified_time);
- int32_t OnHostMsgWrite(ppapi::host::HostMessageContext* context,
- int64_t offset,
- const std::string& buffer);
int32_t OnHostMsgSetLength(ppapi::host::HostMessageContext* context,
int64_t length);
- int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context);
+ int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context,
+ const ppapi::FileGrowth& file_growth);
int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context);
int32_t OnHostMsgRequestOSFileHandle(
ppapi::host::HostMessageContext* context);
@@ -74,55 +72,39 @@ class PepperFileIOHost : public ppapi::host::ResourceHost,
ppapi::host::ReplyMessageContext reply_context,
bool plugin_allowed);
- // Callback handlers. These mostly convert the PlatformFileError to the
+ // Callback handlers. These mostly convert the File::Error to the
// PP_Error code and send back the reply. Note that the argument
// ReplyMessageContext is copied so that we have a closure containing all
// necessary information to reply.
void ExecutePlatformGeneralCallback(
ppapi::host::ReplyMessageContext reply_context,
- base::PlatformFileError error_code);
- void ExecutePlatformOpenFileCallback(
- ppapi::host::ReplyMessageContext reply_context,
- base::PlatformFileError error_code,
- base::PassPlatformFile file,
- bool unused_created);
- void ExecutePlatformWriteCallback(
- ppapi::host::ReplyMessageContext reply_context,
- base::PlatformFileError error_code,
- int bytes_written);
+ base::File::Error error_code);
+
+ void OnOpenProxyCallback(ppapi::host::ReplyMessageContext reply_context,
+ base::File::Error error_code);
void GotUIThreadStuffForInternalFileSystems(
ppapi::host::ReplyMessageContext reply_context,
int platform_file_flags,
UIThreadStuff ui_thread_stuff);
- void DidOpenInternalFile(
- ppapi::host::ReplyMessageContext reply_context,
- base::PlatformFileError result,
- base::PlatformFile file,
- const base::Closure& on_close_callback);
+ void DidOpenInternalFile(ppapi::host::ReplyMessageContext reply_context,
+ base::File file,
+ const base::Closure& on_close_callback);
void GotResolvedRenderProcessId(
ppapi::host::ReplyMessageContext reply_context,
base::FilePath path,
- int platform_file_flags,
+ int file_flags,
base::ProcessId resolved_render_process_id);
void DidOpenQuotaFile(ppapi::host::ReplyMessageContext reply_context,
- base::PlatformFile file,
+ base::File file,
int64_t max_written_offset);
- void GotWriteQuota(ppapi::host::ReplyMessageContext reply_context,
- int64_t offset,
- const std::string& buffer,
- int32_t granted);
- void GotSetLengthQuota(ppapi::host::ReplyMessageContext reply_context,
- int64_t length,
- int32_t granted);
- bool CallWrite(ppapi::host::ReplyMessageContext reply_context,
- int64_t offset,
- const std::string& buffer);
bool CallSetLength(ppapi::host::ReplyMessageContext reply_context,
int64_t length);
- void DidCloseFile(base::PlatformFileError error);
+ void DidCloseFile(base::File::Error error);
+
+ void SendOpenErrorReply(ppapi::host::ReplyMessageContext reply_context);
// Adds file_ to |reply_context| with the specified |open_flags|.
bool AddFileToReplyContext(
@@ -135,7 +117,7 @@ class PepperFileIOHost : public ppapi::host::ResourceHost,
int render_process_id_;
base::ProcessId resolved_render_process_id_;
- base::PlatformFile file_;
+ base::FileProxy file_;
int32_t open_flags_;
// The file system type specified in the Open() call. This will be
@@ -153,10 +135,6 @@ class PepperFileIOHost : public ppapi::host::ResourceHost,
ppapi::FileIOStateManager state_manager_;
- scoped_refptr<base::MessageLoopProxy> file_message_loop_;
-
- base::WeakPtrFactory<PepperFileIOHost> weak_factory_;
-
DISALLOW_COPY_AND_ASSIGN(PepperFileIOHost);
};
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_file_ref_host.cc b/chromium/content/browser/renderer_host/pepper/pepper_file_ref_host.cc
index 75350a03632..a8d362d36e8 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_file_ref_host.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_file_ref_host.cc
@@ -23,8 +23,7 @@ using ppapi::host::ResourceHost;
namespace content {
-PepperFileRefBackend::~PepperFileRefBackend() {
-}
+PepperFileRefBackend::~PepperFileRefBackend() {}
PepperFileRefHost::PepperFileRefHost(BrowserPpapiHost* host,
PP_Instance instance,
@@ -39,9 +38,8 @@ PepperFileRefHost::PepperFileRefHost(BrowserPpapiHost* host,
int render_process_id;
int unused;
- if (!host->GetRenderViewIDsForInstance(instance,
- &render_process_id,
- &unused)) {
+ if (!host->GetRenderFrameIDsForInstance(
+ instance, &render_process_id, &unused)) {
return;
}
@@ -64,16 +62,22 @@ PepperFileRefHost::PepperFileRefHost(BrowserPpapiHost* host,
fs_type_ = file_system_host->GetType();
if ((fs_type_ != PP_FILESYSTEMTYPE_LOCALPERSISTENT) &&
(fs_type_ != PP_FILESYSTEMTYPE_LOCALTEMPORARY) &&
+ (fs_type_ != PP_FILESYSTEMTYPE_EXTERNAL) &&
(fs_type_ != PP_FILESYSTEMTYPE_ISOLATED)) {
DLOG(ERROR) << "Unsupported filesystem type: " << fs_type_;
return;
}
+ if ((fs_type_ == PP_FILESYSTEMTYPE_EXTERNAL) &&
+ (!file_system_host->GetRootUrl().is_valid())) {
+ DLOG(ERROR) << "Native external filesystems are not supported by this "
+ << "constructor.";
+ return;
+ }
- backend_.reset(new PepperInternalFileRefBackend(
- host->GetPpapiHost(),
- render_process_id,
- file_system_host->AsWeakPtr(),
- path));
+ backend_.reset(new PepperInternalFileRefBackend(host->GetPpapiHost(),
+ render_process_id,
+ file_system_host->AsWeakPtr(),
+ path));
}
PepperFileRefHost::PepperFileRefHost(BrowserPpapiHost* host,
@@ -88,23 +92,18 @@ PepperFileRefHost::PepperFileRefHost(BrowserPpapiHost* host,
int render_process_id;
int unused;
- if (!host->GetRenderViewIDsForInstance(instance,
- &render_process_id,
- &unused)) {
+ if (!host->GetRenderFrameIDsForInstance(
+ instance, &render_process_id, &unused)) {
return;
}
- backend_.reset(new PepperExternalFileRefBackend(host->GetPpapiHost(),
- render_process_id,
- external_path));
+ backend_.reset(new PepperExternalFileRefBackend(
+ host->GetPpapiHost(), render_process_id, external_path));
}
-PepperFileRefHost::~PepperFileRefHost() {
-}
+PepperFileRefHost::~PepperFileRefHost() {}
-bool PepperFileRefHost::IsFileRefHost() {
- return true;
-}
+bool PepperFileRefHost::IsFileRefHost() { return true; }
PP_FileSystemType PepperFileRefHost::GetFileSystemType() const {
return fs_type_;
@@ -157,35 +156,29 @@ int32_t PepperFileRefHost::OnResourceMessageReceived(
if (!backend_)
return PP_ERROR_FAILED;
- IPC_BEGIN_MESSAGE_MAP(PepperFileRefHost, msg)
+ PPAPI_BEGIN_MESSAGE_MAP(PepperFileRefHost, msg)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileRef_MakeDirectory,
- OnMakeDirectory);
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileRef_Touch,
- OnTouch);
- PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileRef_Delete,
- OnDelete);
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileRef_Rename,
- OnRename);
- PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileRef_Query,
- OnQuery);
+ OnMakeDirectory)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileRef_Touch, OnTouch)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileRef_Delete, OnDelete)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileRef_Rename, OnRename)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileRef_Query, OnQuery)
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
- PpapiHostMsg_FileRef_ReadDirectoryEntries,
- OnReadDirectoryEntries);
+ PpapiHostMsg_FileRef_ReadDirectoryEntries, OnReadDirectoryEntries)
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileRef_GetAbsolutePath,
- OnGetAbsolutePath);
-
- IPC_END_MESSAGE_MAP()
+ OnGetAbsolutePath)
+ PPAPI_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
int32_t PepperFileRefHost::OnMakeDirectory(
ppapi::host::HostMessageContext* context,
- bool make_ancestors) {
+ int32_t make_directory_flags) {
int32_t rv = CanCreate();
if (rv != PP_OK)
return rv;
return backend_->MakeDirectory(context->MakeReplyMessageContext(),
- make_ancestors);
+ make_directory_flags);
}
int32_t PepperFileRefHost::OnTouch(ppapi::host::HostMessageContext* context,
@@ -196,9 +189,8 @@ int32_t PepperFileRefHost::OnTouch(ppapi::host::HostMessageContext* context,
int32_t rv = CanCreate();
if (rv != PP_OK)
return rv;
- return backend_->Touch(context->MakeReplyMessageContext(),
- last_access_time,
- last_modified_time);
+ return backend_->Touch(
+ context->MakeReplyMessageContext(), last_access_time, last_modified_time);
}
int32_t PepperFileRefHost::OnDelete(ppapi::host::HostMessageContext* context) {
@@ -229,8 +221,7 @@ int32_t PepperFileRefHost::OnRename(ppapi::host::HostMessageContext* context,
if (rv != PP_OK)
return rv;
- return backend_->Rename(context->MakeReplyMessageContext(),
- file_ref_host);
+ return backend_->Rename(context->MakeReplyMessageContext(), file_ref_host);
}
int32_t PepperFileRefHost::OnQuery(ppapi::host::HostMessageContext* context) {
@@ -251,7 +242,7 @@ int32_t PepperFileRefHost::OnReadDirectoryEntries(
int32_t PepperFileRefHost::OnGetAbsolutePath(
ppapi::host::HostMessageContext* context) {
if (!host_->GetPpapiHost()->permissions().HasPermission(
- ppapi::PERMISSION_PRIVATE))
+ ppapi::PERMISSION_PRIVATE))
return PP_ERROR_NOACCESS;
return backend_->GetAbsolutePath(context->MakeReplyMessageContext());
}
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_file_ref_host.h b/chromium/content/browser/renderer_host/pepper/pepper_file_ref_host.h
index 10d9a3ee76e..d850504d175 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_file_ref_host.h
+++ b/chromium/content/browser/renderer_host/pepper/pepper_file_ref_host.h
@@ -29,7 +29,7 @@ class PepperFileRefBackend {
virtual ~PepperFileRefBackend();
virtual int32_t MakeDirectory(ppapi::host::ReplyMessageContext context,
- bool make_ancestors) = 0;
+ int32_t make_directory_flags) = 0;
virtual int32_t Touch(ppapi::host::ReplyMessageContext context,
PP_Time last_accessed_time,
PP_Time last_modified_time) = 0;
@@ -39,8 +39,7 @@ class PepperFileRefBackend {
virtual int32_t Query(ppapi::host::ReplyMessageContext context) = 0;
virtual int32_t ReadDirectoryEntries(
ppapi::host::ReplyMessageContext context) = 0;
- virtual int32_t GetAbsolutePath(
- ppapi::host::ReplyMessageContext context) = 0;
+ virtual int32_t GetAbsolutePath(ppapi::host::ReplyMessageContext context) = 0;
virtual fileapi::FileSystemURL GetFileSystemURL() const = 0;
virtual base::FilePath GetExternalFilePath() const = 0;
@@ -89,7 +88,7 @@ class CONTENT_EXPORT PepperFileRefHost
private:
int32_t OnMakeDirectory(ppapi::host::HostMessageContext* context,
- bool make_ancestors);
+ int32_t make_directory_flags);
int32_t OnTouch(ppapi::host::HostMessageContext* context,
PP_Time last_access_time,
PP_Time last_modified_time);
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc b/chromium/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc
index 740e9b861f8..5eec4105002 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc
@@ -23,7 +23,7 @@
#include "ppapi/shared_impl/file_type_conversion.h"
#include "webkit/browser/fileapi/file_system_operation_runner.h"
#include "webkit/browser/fileapi/isolated_context.h"
-#include "webkit/browser/quota/quota_manager.h"
+#include "webkit/browser/quota/quota_manager_proxy.h"
#include "webkit/common/fileapi/file_system_util.h"
#include "webkit/common/quota/quota_types.h"
@@ -34,9 +34,9 @@ namespace {
// This is the minimum amount of quota we reserve per file system.
const int64_t kMinimumQuotaReservationSize = 1024 * 1024; // 1 MB
-scoped_refptr<fileapi::FileSystemContext>
-GetFileSystemContextFromRenderId(int render_process_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+scoped_refptr<fileapi::FileSystemContext> GetFileSystemContextFromRenderId(
+ int render_process_id) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
RenderProcessHost* host = RenderProcessHost::FromID(render_process_id);
if (!host)
return NULL;
@@ -48,16 +48,6 @@ GetFileSystemContextFromRenderId(int render_process_id) {
} // namespace
-PepperFileSystemBrowserHost::QuotaRequest::QuotaRequest(
- int32_t amount_arg,
- const RequestQuotaCallback& callback_arg)
- : amount(amount_arg),
- callback(callback_arg) {
-}
-
-PepperFileSystemBrowserHost::QuotaRequest::~QuotaRequest() {
-}
-
PepperFileSystemBrowserHost::PepperFileSystemBrowserHost(BrowserPpapiHost* host,
PP_Instance instance,
PP_Resource resource,
@@ -70,10 +60,17 @@ PepperFileSystemBrowserHost::PepperFileSystemBrowserHost(BrowserPpapiHost* host,
file_system_context_(NULL),
reserved_quota_(0),
reserving_quota_(false),
- weak_factory_(this) {
-}
+ weak_factory_(this) {}
PepperFileSystemBrowserHost::~PepperFileSystemBrowserHost() {
+ // If |files_| is not empty, the plugin failed to close some files. It must
+ // have crashed.
+ if (!files_.empty()) {
+ file_system_context_->default_file_task_runner()->PostTask(
+ FROM_HERE,
+ base::Bind(&QuotaReservation::OnClientCrash, quota_reservation_));
+ }
+
// All FileRefs and FileIOs that reference us must have been destroyed. Cancel
// all pending file system operations.
if (file_system_operation_runner_)
@@ -85,8 +82,8 @@ void PepperFileSystemBrowserHost::OpenExisting(const GURL& root_url,
root_url_ = root_url;
int render_process_id = 0;
int unused;
- if (!browser_ppapi_host_->GetRenderViewIDsForInstance(
- pp_instance(), &render_process_id, &unused)) {
+ if (!browser_ppapi_host_->GetRenderFrameIDsForInstance(
+ pp_instance(), &render_process_id, &unused)) {
NOTREACHED();
}
called_open_ = true;
@@ -97,26 +94,26 @@ void PepperFileSystemBrowserHost::OpenExisting(const GURL& root_url,
FROM_HERE,
base::Bind(&GetFileSystemContextFromRenderId, render_process_id),
base::Bind(&PepperFileSystemBrowserHost::OpenExistingFileSystem,
- weak_factory_.GetWeakPtr(), callback));
+ weak_factory_.GetWeakPtr(),
+ callback));
}
int32_t PepperFileSystemBrowserHost::OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) {
- IPC_BEGIN_MESSAGE_MAP(PepperFileSystemBrowserHost, msg)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(
- PpapiHostMsg_FileSystem_Open,
- OnHostMsgOpen)
+ PPAPI_BEGIN_MESSAGE_MAP(PepperFileSystemBrowserHost, msg)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileSystem_Open,
+ OnHostMsgOpen)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(
PpapiHostMsg_FileSystem_InitIsolatedFileSystem,
OnHostMsgInitIsolatedFileSystem)
- IPC_END_MESSAGE_MAP()
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileSystem_ReserveQuota,
+ OnHostMsgReserveQuota)
+ PPAPI_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
-bool PepperFileSystemBrowserHost::IsFileSystemHost() {
- return true;
-}
+bool PepperFileSystemBrowserHost::IsFileSystemHost() { return true; }
void PepperFileSystemBrowserHost::OpenQuotaFile(
PepperFileIOHost* file_io_host,
@@ -129,10 +126,7 @@ void PepperFileSystemBrowserHost::OpenQuotaFile(
base::PostTaskAndReplyWithResult(
file_system_context_->default_file_task_runner(),
FROM_HERE,
- base::Bind(&QuotaReservation::OpenFile,
- quota_reservation_,
- id,
- url),
+ base::Bind(&QuotaReservation::OpenFile, quota_reservation_, id, url),
callback);
} else {
NOTREACHED();
@@ -140,12 +134,11 @@ void PepperFileSystemBrowserHost::OpenQuotaFile(
}
void PepperFileSystemBrowserHost::CloseQuotaFile(
- PepperFileIOHost* file_io_host) {
+ PepperFileIOHost* file_io_host,
+ const ppapi::FileGrowth& file_growth) {
int32_t id = file_io_host->pp_resource();
- int64_t max_written_offset = 0;
FileMap::iterator it = files_.find(id);
if (it != files_.end()) {
- max_written_offset = file_io_host->max_written_offset();
files_.erase(it);
} else {
NOTREACHED();
@@ -154,29 +147,8 @@ void PepperFileSystemBrowserHost::CloseQuotaFile(
file_system_context_->default_file_task_runner()->PostTask(
FROM_HERE,
- base::Bind(&QuotaReservation::CloseFile,
- quota_reservation_,
- id,
- max_written_offset));
-}
-
-int32_t PepperFileSystemBrowserHost::RequestQuota(
- int32_t amount,
- const RequestQuotaCallback& callback) {
- DCHECK(amount >= 0);
- if (!reserving_quota_ && reserved_quota_ >= amount) {
- reserved_quota_ -= amount;
- return amount;
- }
-
- // Queue up a pending quota request.
- pending_quota_requests_.push(QuotaRequest(amount, callback));
-
- // Reserve more quota if we haven't already.
- if (!reserving_quota_)
- ReserveQuota(amount);
-
- return PP_OK_COMPLETIONPENDING;
+ base::Bind(
+ &QuotaReservation::CloseFile, quota_reservation_, id, file_growth));
}
int32_t PepperFileSystemBrowserHost::OnHostMsgOpen(
@@ -197,10 +169,9 @@ int32_t PepperFileSystemBrowserHost::OnHostMsgOpen(
int render_process_id = 0;
int unused;
- if (!browser_ppapi_host_->GetRenderViewIDsForInstance(pp_instance(),
- &render_process_id,
- &unused)) {
- return PP_ERROR_FAILED;
+ if (!browser_ppapi_host_->GetRenderFrameIDsForInstance(
+ pp_instance(), &render_process_id, &unused)) {
+ return PP_ERROR_FAILED;
}
BrowserThread::PostTaskAndReplyWithResult(
@@ -239,15 +210,17 @@ void PepperFileSystemBrowserHost::OpenFileSystem(
scoped_refptr<fileapi::FileSystemContext> file_system_context) {
if (!file_system_context.get()) {
OpenFileSystemComplete(
- reply_context, GURL(), std::string(), base::PLATFORM_FILE_ERROR_FAILED);
+ reply_context, GURL(), std::string(), base::File::FILE_ERROR_FAILED);
return;
}
SetFileSystemContext(file_system_context);
- GURL origin = browser_ppapi_host_->GetDocumentURLForInstance(
- pp_instance()).GetOrigin();
- file_system_context_->OpenFileSystem(origin, file_system_type,
+ GURL origin =
+ browser_ppapi_host_->GetDocumentURLForInstance(pp_instance()).GetOrigin();
+ file_system_context_->OpenFileSystem(
+ origin,
+ file_system_type,
fileapi::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT,
base::Bind(&PepperFileSystemBrowserHost::OpenFileSystemComplete,
weak_factory_.GetWeakPtr(),
@@ -258,8 +231,8 @@ void PepperFileSystemBrowserHost::OpenFileSystemComplete(
ppapi::host::ReplyMessageContext reply_context,
const GURL& root,
const std::string& /* unused */,
- base::PlatformFileError error) {
- int32 pp_error = ppapi::PlatformFileErrorToPepperError(error);
+ base::File::Error error) {
+ int32 pp_error = ppapi::FileErrorToPepperError(error);
if (pp_error == PP_OK) {
opened_ = true;
root_url_ = root;
@@ -289,7 +262,8 @@ void PepperFileSystemBrowserHost::OpenIsolatedFileSystem(
root_url_ = GURL(fileapi::GetIsolatedFileSystemRootURIString(
browser_ppapi_host_->GetDocumentURLForInstance(pp_instance()).GetOrigin(),
- fsid, ppapi::IsolatedFileSystemTypeToRootName(type)));
+ fsid,
+ ppapi::IsolatedFileSystemTypeToRootName(type)));
if (!root_url_.is_valid()) {
SendReplyForIsolatedFileSystem(reply_context, fsid, PP_ERROR_FAILED);
return;
@@ -314,8 +288,8 @@ void PepperFileSystemBrowserHost::OpenPluginPrivateFileSystem(
ppapi::host::ReplyMessageContext reply_context,
const std::string& fsid,
scoped_refptr<fileapi::FileSystemContext> file_system_context) {
- GURL origin = browser_ppapi_host_->GetDocumentURLForInstance(
- pp_instance()).GetOrigin();
+ GURL origin =
+ browser_ppapi_host_->GetDocumentURLForInstance(pp_instance()).GetOrigin();
if (!origin.is_valid()) {
SendReplyForIsolatedFileSystem(reply_context, fsid, PP_ERROR_FAILED);
return;
@@ -328,18 +302,23 @@ void PepperFileSystemBrowserHost::OpenPluginPrivateFileSystem(
}
file_system_context->OpenPluginPrivateFileSystem(
- origin, fileapi::kFileSystemTypePluginPrivate, fsid, plugin_id,
+ origin,
+ fileapi::kFileSystemTypePluginPrivate,
+ fsid,
+ plugin_id,
fileapi::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT,
base::Bind(
&PepperFileSystemBrowserHost::OpenPluginPrivateFileSystemComplete,
- weak_factory_.GetWeakPtr(), reply_context, fsid));
+ weak_factory_.GetWeakPtr(),
+ reply_context,
+ fsid));
}
void PepperFileSystemBrowserHost::OpenPluginPrivateFileSystemComplete(
ppapi::host::ReplyMessageContext reply_context,
const std::string& fsid,
- base::PlatformFileError error) {
- int32 pp_error = ppapi::PlatformFileErrorToPepperError(error);
+ base::File::Error error) {
+ int32 pp_error = ppapi::FileErrorToPepperError(error);
if (pp_error == PP_OK)
opened_ = true;
SendReplyForIsolatedFileSystem(reply_context, fsid, pp_error);
@@ -360,16 +339,16 @@ int32_t PepperFileSystemBrowserHost::OnHostMsgInitIsolatedFileSystem(
int render_process_id = 0;
int unused;
- if (!browser_ppapi_host_->GetRenderViewIDsForInstance(pp_instance(),
- &render_process_id,
- &unused)) {
+ if (!browser_ppapi_host_->GetRenderFrameIDsForInstance(
+ pp_instance(), &render_process_id, &unused)) {
fileapi::IsolatedContext::GetInstance()->RevokeFileSystem(fsid);
return PP_ERROR_FAILED;
}
root_url_ = GURL(fileapi::GetIsolatedFileSystemRootURIString(
browser_ppapi_host_->GetDocumentURLForInstance(pp_instance()).GetOrigin(),
- fsid, ppapi::IsolatedFileSystemTypeToRootName(type)));
+ fsid,
+ ppapi::IsolatedFileSystemTypeToRootName(type)));
BrowserThread::PostTaskAndReplyWithResult(
BrowserThread::UI,
@@ -377,7 +356,35 @@ int32_t PepperFileSystemBrowserHost::OnHostMsgInitIsolatedFileSystem(
base::Bind(&GetFileSystemContextFromRenderId, render_process_id),
base::Bind(&PepperFileSystemBrowserHost::OpenIsolatedFileSystem,
weak_factory_.GetWeakPtr(),
- context->MakeReplyMessageContext(), fsid, type));
+ context->MakeReplyMessageContext(),
+ fsid,
+ type));
+ return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t PepperFileSystemBrowserHost::OnHostMsgReserveQuota(
+ ppapi::host::HostMessageContext* context,
+ int64_t amount,
+ const ppapi::FileGrowthMap& file_growths) {
+ DCHECK(ChecksQuota());
+ DCHECK_GT(amount, 0);
+
+ if (reserving_quota_)
+ return PP_ERROR_INPROGRESS;
+ reserving_quota_ = true;
+
+ int64_t reservation_amount =
+ std::max<int64_t>(kMinimumQuotaReservationSize, amount);
+ file_system_context_->default_file_task_runner()->PostTask(
+ FROM_HERE,
+ base::Bind(&QuotaReservation::ReserveQuota,
+ quota_reservation_,
+ reservation_amount,
+ file_growths,
+ base::Bind(&PepperFileSystemBrowserHost::GotReservedQuota,
+ weak_factory_.GetWeakPtr(),
+ context->MakeReplyMessageContext())));
+
return PP_OK_COMPLETIONPENDING;
}
@@ -402,7 +409,7 @@ void PepperFileSystemBrowserHost::SendReplyForIsolatedFileSystem(
void PepperFileSystemBrowserHost::SetFileSystemContext(
scoped_refptr<fileapi::FileSystemContext> file_system_context) {
file_system_context_ = file_system_context;
- if (type_ != PP_FILESYSTEMTYPE_EXTERNAL) {
+ if (type_ != PP_FILESYSTEMTYPE_EXTERNAL || root_url_.is_valid()) {
file_system_operation_runner_ =
file_system_context_->CreateFileSystemOperationRunner();
}
@@ -413,7 +420,7 @@ bool PepperFileSystemBrowserHost::ShouldCreateQuotaReservation() const {
if (!ppapi::FileSystemTypeHasQuota(type_))
return false;
- // For file system types with quota, ome origins have unlimited storage.
+ // For file system types with quota, some origins have unlimited storage.
quota::QuotaManagerProxy* quota_manager_proxy =
file_system_context_->quota_manager_proxy();
CHECK(quota_manager_proxy);
@@ -447,67 +454,18 @@ void PepperFileSystemBrowserHost::GotQuotaReservation(
callback.Run();
}
-void PepperFileSystemBrowserHost::ReserveQuota(int32_t amount) {
- DCHECK(!reserving_quota_);
- reserving_quota_ = true;
-
- // Get the max_written_offset for each open file.
- QuotaReservation::OffsetMap max_written_offsets;
- for (FileMap::iterator it = files_.begin(); it != files_.end(); ++ it) {
- max_written_offsets.insert(
- std::make_pair(it->first, it->second->max_written_offset()));
- }
-
- int64_t reservation_amount = std::max<int64_t>(kMinimumQuotaReservationSize,
- amount);
- file_system_context_->default_file_task_runner()->PostTask(
- FROM_HERE,
- base::Bind(&QuotaReservation::ReserveQuota,
- quota_reservation_,
- reservation_amount,
- max_written_offsets,
- base::Bind(&PepperFileSystemBrowserHost::GotReservedQuota,
- weak_factory_.GetWeakPtr())));
-}
-
void PepperFileSystemBrowserHost::GotReservedQuota(
+ ppapi::host::ReplyMessageContext reply_context,
int64_t amount,
- const QuotaReservation::OffsetMap& max_written_offsets) {
+ const ppapi::FileSizeMap& file_sizes) {
DCHECK(reserving_quota_);
reserving_quota_ = false;
reserved_quota_ = amount;
- // Update open files with their new base sizes. This won't write over any
- // updates since the files are waiting for quota and can't write.
- for (FileMap::iterator it = files_.begin(); it != files_.end(); ++ it) {
- QuotaReservation::OffsetMap::const_iterator offset_it =
- max_written_offsets.find(it->first);
- if (offset_it != max_written_offsets.end())
- it->second->set_max_written_offset(offset_it->second);
- else
- NOTREACHED();
- }
-
- DCHECK(!pending_quota_requests_.empty());
- // If we can't grant the first request after refreshing reserved_quota_, then
- // fail all pending quota requests to avoid an infinite refresh/fail loop.
- bool fail_all = reserved_quota_ < pending_quota_requests_.front().amount;
- while (!pending_quota_requests_.empty()) {
- QuotaRequest& request = pending_quota_requests_.front();
- if (fail_all) {
- request.callback.Run(0);
- pending_quota_requests_.pop();
- } else if (reserved_quota_ >= request.amount) {
- reserved_quota_ -= request.amount;
- request.callback.Run(request.amount);
- pending_quota_requests_.pop();
- } else {
- // Refresh the quota reservation for the first pending request that we
- // can't satisfy.
- ReserveQuota(request.amount);
- break;
- }
- }
+ reply_context.params.set_result(PP_OK);
+ host()->SendReply(
+ reply_context,
+ PpapiPluginMsg_FileSystem_ReserveQuotaReply(amount, file_sizes));
}
std::string PepperFileSystemBrowserHost::GetPluginMimeType() const {
@@ -526,19 +484,21 @@ std::string PepperFileSystemBrowserHost::GeneratePluginId(
// types). If we bring this API to stable, we might have to make it more
// general.
- if (!net::IsMimeType(mime_type))
+ std::string top_level_type;
+ std::string subtype;
+ if (!net::ParseMimeTypeWithoutParameter(
+ mime_type, &top_level_type, &subtype) ||
+ !net::IsValidTopLevelMimeType(top_level_type))
return std::string();
- std::string output = mime_type;
// Replace a slash used for type/subtype separator with an underscore.
- // NOTE: This assumes there is only one slash in the MIME type.
- ReplaceFirstSubstringAfterOffset(&output, 0, "/", "_");
+ std::string output = top_level_type + "_" + subtype;
// Verify |output| contains only alphabets, digits, or "._-".
- for (std::string::const_iterator it = output.begin();
- it != output.end(); ++it) {
- if (!IsAsciiAlpha(*it) && !IsAsciiDigit(*it) &&
- *it != '.' && *it != '_' && *it != '-') {
+ for (std::string::const_iterator it = output.begin(); it != output.end();
+ ++it) {
+ if (!IsAsciiAlpha(*it) && !IsAsciiDigit(*it) && *it != '.' && *it != '_' &&
+ *it != '-') {
LOG(WARNING) << "Failed to generate a plugin id.";
return std::string();
}
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_file_system_browser_host.h b/chromium/content/browser/renderer_host/pepper/pepper_file_system_browser_host.h
index f97ddde671d..f6f75fb9aa5 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_file_system_browser_host.h
+++ b/chromium/content/browser/renderer_host/pepper/pepper_file_system_browser_host.h
@@ -18,6 +18,7 @@
#include "ppapi/c/private/ppb_isolated_file_system_private.h"
#include "ppapi/host/host_message_context.h"
#include "ppapi/host/resource_host.h"
+#include "ppapi/shared_impl/file_growth.h"
#include "url/gurl.h"
#include "webkit/browser/fileapi/file_system_context.h"
@@ -72,26 +73,12 @@ class CONTENT_EXPORT PepperFileSystemBrowserHost
const OpenQuotaFileCallback& callback);
// Closes the file. This must be called after OpenQuotaFile and before the
// PepperFileIOHost is destroyed.
- void CloseQuotaFile(PepperFileIOHost* file_io_host);
- // Requests the given amount of quota. Returns the amount requested or
- // PP_OK_COMPLETIONPENDING, in which case the amount granted is returned in
- // the callback. Requests can't partially succeed so the amount granted is
- // either 0 or the amount of the request. Requesting an amount of 0 will
- // return immediately with a 0 result.
- typedef base::Callback<void(int32_t)> RequestQuotaCallback;
- int32_t RequestQuota(int32_t amount,
- const RequestQuotaCallback& callback);
+ void CloseQuotaFile(PepperFileIOHost* file_io_host,
+ const ppapi::FileGrowth& file_growth);
+
private:
friend class PepperFileSystemBrowserHostTest;
- struct QuotaRequest {
- QuotaRequest(int32_t amount, const RequestQuotaCallback& callback);
- ~QuotaRequest();
-
- int32_t amount;
- RequestQuotaCallback callback;
- };
-
void OpenExistingFileSystem(
const base::Closure& callback,
scoped_refptr<fileapi::FileSystemContext> file_system_context);
@@ -99,11 +86,10 @@ class CONTENT_EXPORT PepperFileSystemBrowserHost
ppapi::host::ReplyMessageContext reply_context,
fileapi::FileSystemType file_system_type,
scoped_refptr<fileapi::FileSystemContext> file_system_context);
- void OpenFileSystemComplete(
- ppapi::host::ReplyMessageContext reply_context,
- const GURL& root,
- const std::string& name,
- base::PlatformFileError error);
+ void OpenFileSystemComplete(ppapi::host::ReplyMessageContext reply_context,
+ const GURL& root,
+ const std::string& name,
+ base::File::Error error);
void OpenIsolatedFileSystem(
ppapi::host::ReplyMessageContext reply_context,
const std::string& fsid,
@@ -116,7 +102,7 @@ class CONTENT_EXPORT PepperFileSystemBrowserHost
void OpenPluginPrivateFileSystemComplete(
ppapi::host::ReplyMessageContext reply_context,
const std::string& fsid,
- base::PlatformFileError error);
+ base::File::Error error);
int32_t OnHostMsgOpen(ppapi::host::HostMessageContext* context,
int64_t expected_size);
@@ -124,10 +110,12 @@ class CONTENT_EXPORT PepperFileSystemBrowserHost
ppapi::host::HostMessageContext* context,
const std::string& fsid,
PP_IsolatedFileSystemType_Private type);
+ int32_t OnHostMsgReserveQuota(ppapi::host::HostMessageContext* context,
+ int64_t amount,
+ const ppapi::FileGrowthMap& file_growths);
- void SendReplyForFileSystem(
- ppapi::host::ReplyMessageContext reply_context,
- int32_t pp_error);
+ void SendReplyForFileSystem(ppapi::host::ReplyMessageContext reply_context,
+ int32_t pp_error);
void SendReplyForIsolatedFileSystem(
ppapi::host::ReplyMessageContext reply_context,
const std::string& fsid,
@@ -138,13 +126,15 @@ class CONTENT_EXPORT PepperFileSystemBrowserHost
bool ShouldCreateQuotaReservation() const;
void CreateQuotaReservation(const base::Closure& callback);
- void GotQuotaReservation(
- const base::Closure& callback,
- scoped_refptr<QuotaReservation> quota_reservation);
+ void GotQuotaReservation(const base::Closure& callback,
+ scoped_refptr<QuotaReservation> quota_reservation);
- void ReserveQuota(int32_t amount);
- void GotReservedQuota(int64_t amount,
- const QuotaReservation::OffsetMap& max_written_offsets);
+ void GotReservedQuota(ppapi::host::ReplyMessageContext reply_context,
+ int64_t amount,
+ const ppapi::FileSizeMap& file_sizes);
+ void DidOpenQuotaFile(PP_Resource file_io_resource,
+ const OpenQuotaFileCallback& callback,
+ int64_t max_written_offset);
std::string GetPluginMimeType() const;
@@ -155,7 +145,7 @@ class CONTENT_EXPORT PepperFileSystemBrowserHost
PP_FileSystemType type_;
bool called_open_; // whether open has been called.
- bool opened_; // whether open succeeded.
+ bool opened_; // whether open succeeded.
GURL root_url_;
scoped_refptr<fileapi::FileSystemContext> file_system_context_;
@@ -167,7 +157,6 @@ class CONTENT_EXPORT PepperFileSystemBrowserHost
// destroyed.
typedef std::map<int32_t, PepperFileIOHost*> FileMap;
FileMap files_;
- std::queue<QuotaRequest> pending_quota_requests_;
int64_t reserved_quota_;
bool reserving_quota_;
// Access only on the FileSystemContext's default_file_task_runner().
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_file_system_browser_host_unittest.cc b/chromium/content/browser/renderer_host/pepper/pepper_file_system_browser_host_unittest.cc
index fa07e3938ab..8aa144cf426 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_file_system_browser_host_unittest.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_file_system_browser_host_unittest.cc
@@ -15,9 +15,8 @@
namespace content {
-class PepperFileSystemBrowserHostTest
- : public testing::Test,
- public BrowserPpapiHostTest {
+class PepperFileSystemBrowserHostTest : public testing::Test,
+ public BrowserPpapiHostTest {
public:
PepperFileSystemBrowserHostTest() {}
virtual ~PepperFileSystemBrowserHostTest() {}
@@ -25,14 +24,13 @@ class PepperFileSystemBrowserHostTest
virtual void SetUp() OVERRIDE {
PP_Instance pp_instance = 12345;
PP_Resource pp_resource = 67890;
- host_.reset(new PepperFileSystemBrowserHost(
- GetBrowserPpapiHost(), pp_instance, pp_resource,
- PP_FILESYSTEMTYPE_ISOLATED));
+ host_.reset(new PepperFileSystemBrowserHost(GetBrowserPpapiHost(),
+ pp_instance,
+ pp_resource,
+ PP_FILESYSTEMTYPE_ISOLATED));
}
- virtual void TearDown() OVERRIDE {
- host_.reset();
- }
+ virtual void TearDown() OVERRIDE { host_.reset(); }
protected:
std::string GeneratePluginId(const std::string& mime_type) {
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc b/chromium/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc
index ba8a8b91368..d4413b20c9c 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/file_util.h"
+#include "base/files/file.h"
#include "base/files/file_enumerator.h"
#include "base/threading/sequenced_worker_pool.h"
#include "content/browser/child_process_security_policy_impl.h"
@@ -27,13 +28,13 @@ namespace content {
namespace {
bool CanRead(int process_id, const base::FilePath& path) {
- return ChildProcessSecurityPolicyImpl::GetInstance()->
- CanReadFile(process_id, path);
+ return ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(process_id,
+ path);
}
bool CanCreateReadWrite(int process_id, const base::FilePath& path) {
- return ChildProcessSecurityPolicyImpl::GetInstance()->
- CanCreateReadWriteFile(process_id, path);
+ return ChildProcessSecurityPolicyImpl::GetInstance()->CanCreateReadWriteFile(
+ process_id, path);
}
} // namespace
@@ -43,7 +44,7 @@ PepperFlashFileMessageFilter::PepperFlashFileMessageFilter(
BrowserPpapiHost* host)
: plugin_process_handle_(host->GetPluginProcessHandle()) {
int unused;
- host->GetRenderViewIDsForInstance(instance, &render_process_id_, &unused);
+ host->GetRenderFrameIDsForInstance(instance, &render_process_id_, &unused);
base::FilePath profile_data_directory = host->GetProfileDataDirectory();
std::string plugin_name = host->GetPluginName();
@@ -59,8 +60,7 @@ PepperFlashFileMessageFilter::PepperFlashFileMessageFilter(
}
}
-PepperFlashFileMessageFilter::~PepperFlashFileMessageFilter() {
-}
+PepperFlashFileMessageFilter::~PepperFlashFileMessageFilter() {}
// static
base::FilePath PepperFlashFileMessageFilter::GetDataDirName(
@@ -83,9 +83,9 @@ PepperFlashFileMessageFilter::OverrideTaskRunnerForMessage(
}
int32_t PepperFlashFileMessageFilter::OnResourceMessageReceived(
- const IPC::Message& msg,
- ppapi::host::HostMessageContext* context) {
- IPC_BEGIN_MESSAGE_MAP(PepperFlashFileMessageFilter, msg)
+ const IPC::Message& msg,
+ ppapi::host::HostMessageContext* context) {
+ PPAPI_BEGIN_MESSAGE_MAP(PepperFlashFileMessageFilter, msg)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashFile_OpenFile,
OnOpenFile)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashFile_RenameFile,
@@ -99,9 +99,8 @@ int32_t PepperFlashFileMessageFilter::OnResourceMessageReceived(
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashFile_GetDirContents,
OnGetDirContents)
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
- PpapiHostMsg_FlashFile_CreateTemporaryFile,
- OnCreateTemporaryFile)
- IPC_END_MESSAGE_MAP()
+ PpapiHostMsg_FlashFile_CreateTemporaryFile, OnCreateTemporaryFile)
+ PPAPI_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
@@ -110,43 +109,36 @@ int32_t PepperFlashFileMessageFilter::OnOpenFile(
const ppapi::PepperFilePath& path,
int pp_open_flags) {
base::FilePath full_path = ValidateAndConvertPepperFilePath(
- path,
- base::Bind(&CanOpenWithPepperFlags, pp_open_flags));
+ path, base::Bind(&CanOpenWithPepperFlags, pp_open_flags));
if (full_path.empty()) {
- return ppapi::PlatformFileErrorToPepperError(
- base::PLATFORM_FILE_ERROR_ACCESS_DENIED);
+ return ppapi::FileErrorToPepperError(base::File::FILE_ERROR_ACCESS_DENIED);
}
int platform_file_flags = 0;
- if (!ppapi::PepperFileOpenFlagsToPlatformFileFlags(
- pp_open_flags, &platform_file_flags)) {
- return base::PLATFORM_FILE_ERROR_FAILED;
+ if (!ppapi::PepperFileOpenFlagsToPlatformFileFlags(pp_open_flags,
+ &platform_file_flags)) {
+ return base::File::FILE_ERROR_FAILED;
}
- base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
- base::PlatformFile file_handle = base::CreatePlatformFile(
- full_path, platform_file_flags, NULL, &error);
- if (error != base::PLATFORM_FILE_OK) {
- DCHECK_EQ(file_handle, base::kInvalidPlatformFileValue);
- return ppapi::PlatformFileErrorToPepperError(error);
+ base::File file(full_path, platform_file_flags);
+ if (!file.IsValid()) {
+ return ppapi::FileErrorToPepperError(file.error_details());
}
// Make sure we didn't try to open a directory: directory fd shouldn't be
// passed to untrusted processes because they open security holes.
- base::PlatformFileInfo info;
- if (!base::GetPlatformFileInfo(file_handle, &info) || info.is_directory) {
+ base::File::Info info;
+ if (!file.GetInfo(&info) || info.is_directory) {
// When in doubt, throw it out.
- base::ClosePlatformFile(file_handle);
- return ppapi::PlatformFileErrorToPepperError(
- base::PLATFORM_FILE_ERROR_ACCESS_DENIED);
+ return ppapi::FileErrorToPepperError(base::File::FILE_ERROR_ACCESS_DENIED);
}
- IPC::PlatformFileForTransit file = IPC::GetFileHandleForProcess(file_handle,
- plugin_process_handle_, true);
+ IPC::PlatformFileForTransit transit_file =
+ IPC::TakeFileHandleForProcess(file.Pass(), plugin_process_handle_);
ppapi::host::ReplyMessageContext reply_context =
context->MakeReplyMessageContext();
reply_context.params.AppendHandle(ppapi::proxy::SerializedHandle(
- ppapi::proxy::SerializedHandle::FILE, file));
+ ppapi::proxy::SerializedHandle::FILE, transit_file));
SendReply(reply_context, IPC::Message());
return PP_OK_COMPLETIONPENDING;
}
@@ -160,84 +152,77 @@ int32_t PepperFlashFileMessageFilter::OnRenameFile(
base::FilePath to_full_path = ValidateAndConvertPepperFilePath(
to_path, base::Bind(&CanCreateReadWrite));
if (from_full_path.empty() || to_full_path.empty()) {
- return ppapi::PlatformFileErrorToPepperError(
- base::PLATFORM_FILE_ERROR_ACCESS_DENIED);
+ return ppapi::FileErrorToPepperError(base::File::FILE_ERROR_ACCESS_DENIED);
}
bool result = base::Move(from_full_path, to_full_path);
- return ppapi::PlatformFileErrorToPepperError(result ?
- base::PLATFORM_FILE_OK : base::PLATFORM_FILE_ERROR_ACCESS_DENIED);
+ return ppapi::FileErrorToPepperError(
+ result ? base::File::FILE_OK : base::File::FILE_ERROR_ACCESS_DENIED);
}
int32_t PepperFlashFileMessageFilter::OnDeleteFileOrDir(
ppapi::host::HostMessageContext* context,
const ppapi::PepperFilePath& path,
bool recursive) {
- base::FilePath full_path = ValidateAndConvertPepperFilePath(
- path, base::Bind(&CanCreateReadWrite));
+ base::FilePath full_path =
+ ValidateAndConvertPepperFilePath(path, base::Bind(&CanCreateReadWrite));
if (full_path.empty()) {
- return ppapi::PlatformFileErrorToPepperError(
- base::PLATFORM_FILE_ERROR_ACCESS_DENIED);
+ return ppapi::FileErrorToPepperError(base::File::FILE_ERROR_ACCESS_DENIED);
}
bool result = base::DeleteFile(full_path, recursive);
- return ppapi::PlatformFileErrorToPepperError(result ?
- base::PLATFORM_FILE_OK : base::PLATFORM_FILE_ERROR_ACCESS_DENIED);
+ return ppapi::FileErrorToPepperError(
+ result ? base::File::FILE_OK : base::File::FILE_ERROR_ACCESS_DENIED);
}
int32_t PepperFlashFileMessageFilter::OnCreateDir(
ppapi::host::HostMessageContext* context,
const ppapi::PepperFilePath& path) {
- base::FilePath full_path = ValidateAndConvertPepperFilePath(
- path, base::Bind(&CanCreateReadWrite));
+ base::FilePath full_path =
+ ValidateAndConvertPepperFilePath(path, base::Bind(&CanCreateReadWrite));
if (full_path.empty()) {
- return ppapi::PlatformFileErrorToPepperError(
- base::PLATFORM_FILE_ERROR_ACCESS_DENIED);
+ return ppapi::FileErrorToPepperError(base::File::FILE_ERROR_ACCESS_DENIED);
}
bool result = base::CreateDirectory(full_path);
- return ppapi::PlatformFileErrorToPepperError(result ?
- base::PLATFORM_FILE_OK : base::PLATFORM_FILE_ERROR_ACCESS_DENIED);
+ return ppapi::FileErrorToPepperError(
+ result ? base::File::FILE_OK : base::File::FILE_ERROR_ACCESS_DENIED);
}
int32_t PepperFlashFileMessageFilter::OnQueryFile(
ppapi::host::HostMessageContext* context,
const ppapi::PepperFilePath& path) {
- base::FilePath full_path = ValidateAndConvertPepperFilePath(
- path, base::Bind(&CanRead));
+ base::FilePath full_path =
+ ValidateAndConvertPepperFilePath(path, base::Bind(&CanRead));
if (full_path.empty()) {
- return ppapi::PlatformFileErrorToPepperError(
- base::PLATFORM_FILE_ERROR_ACCESS_DENIED);
+ return ppapi::FileErrorToPepperError(base::File::FILE_ERROR_ACCESS_DENIED);
}
- base::PlatformFileInfo info;
+ base::File::Info info;
bool result = base::GetFileInfo(full_path, &info);
context->reply_msg = PpapiPluginMsg_FlashFile_QueryFileReply(info);
- return ppapi::PlatformFileErrorToPepperError(result ?
- base::PLATFORM_FILE_OK : base::PLATFORM_FILE_ERROR_ACCESS_DENIED);
+ return ppapi::FileErrorToPepperError(
+ result ? base::File::FILE_OK : base::File::FILE_ERROR_ACCESS_DENIED);
}
int32_t PepperFlashFileMessageFilter::OnGetDirContents(
ppapi::host::HostMessageContext* context,
const ppapi::PepperFilePath& path) {
- base::FilePath full_path = ValidateAndConvertPepperFilePath(
- path, base::Bind(&CanRead));
+ base::FilePath full_path =
+ ValidateAndConvertPepperFilePath(path, base::Bind(&CanRead));
if (full_path.empty()) {
- return ppapi::PlatformFileErrorToPepperError(
- base::PLATFORM_FILE_ERROR_ACCESS_DENIED);
+ return ppapi::FileErrorToPepperError(base::File::FILE_ERROR_ACCESS_DENIED);
}
ppapi::DirContents contents;
- base::FileEnumerator enumerator(full_path, false,
- base::FileEnumerator::FILES |
- base::FileEnumerator::DIRECTORIES |
- base::FileEnumerator::INCLUDE_DOT_DOT);
+ base::FileEnumerator enumerator(full_path,
+ false,
+ base::FileEnumerator::FILES |
+ base::FileEnumerator::DIRECTORIES |
+ base::FileEnumerator::INCLUDE_DOT_DOT);
while (!enumerator.Next().empty()) {
base::FileEnumerator::FileInfo info = enumerator.GetInfo();
- ppapi::DirEntry entry = {
- info.GetName(),
- info.IsDirectory()
- };
+ ppapi::DirEntry entry = {info.GetName(), info.IsDirectory()};
contents.push_back(entry);
}
@@ -247,42 +232,35 @@ int32_t PepperFlashFileMessageFilter::OnGetDirContents(
int32_t PepperFlashFileMessageFilter::OnCreateTemporaryFile(
ppapi::host::HostMessageContext* context) {
- ppapi::PepperFilePath dir_path(
- ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL, base::FilePath());
+ ppapi::PepperFilePath dir_path(ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL,
+ base::FilePath());
base::FilePath validated_dir_path = ValidateAndConvertPepperFilePath(
dir_path, base::Bind(&CanCreateReadWrite));
if (validated_dir_path.empty() ||
(!base::DirectoryExists(validated_dir_path) &&
!base::CreateDirectory(validated_dir_path))) {
- return ppapi::PlatformFileErrorToPepperError(
- base::PLATFORM_FILE_ERROR_ACCESS_DENIED);
+ return ppapi::FileErrorToPepperError(base::File::FILE_ERROR_ACCESS_DENIED);
}
base::FilePath file_path;
if (!base::CreateTemporaryFileInDir(validated_dir_path, &file_path)) {
- return ppapi::PlatformFileErrorToPepperError(
- base::PLATFORM_FILE_ERROR_FAILED);
+ return ppapi::FileErrorToPepperError(base::File::FILE_ERROR_FAILED);
}
- base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
- base::PlatformFile file_handle = base::CreatePlatformFile(
- file_path,
- base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_READ |
- base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_TEMPORARY |
- base::PLATFORM_FILE_DELETE_ON_CLOSE,
- NULL, &error);
-
- if (error != base::PLATFORM_FILE_OK) {
- DCHECK_EQ(file_handle, base::kInvalidPlatformFileValue);
- return ppapi::PlatformFileErrorToPepperError(error);
- }
+ base::File file(file_path,
+ base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_READ |
+ base::File::FLAG_WRITE | base::File::FLAG_TEMPORARY |
+ base::File::FLAG_DELETE_ON_CLOSE);
+
+ if (!file.IsValid())
+ return ppapi::FileErrorToPepperError(file.error_details());
- IPC::PlatformFileForTransit file = IPC::GetFileHandleForProcess(file_handle,
- plugin_process_handle_, true);
+ IPC::PlatformFileForTransit transit_file =
+ IPC::TakeFileHandleForProcess(file.Pass(), plugin_process_handle_);
ppapi::host::ReplyMessageContext reply_context =
context->MakeReplyMessageContext();
reply_context.params.AppendHandle(ppapi::proxy::SerializedHandle(
- ppapi::proxy::SerializedHandle::FILE, file));
+ ppapi::proxy::SerializedHandle::FILE, transit_file));
SendReply(reply_context, IPC::Message());
return PP_OK_COMPLETIONPENDING;
}
@@ -301,8 +279,7 @@ base::FilePath PepperFlashFileMessageFilter::ValidateAndConvertPepperFilePath(
case ppapi::PepperFilePath::DOMAIN_MODULE_LOCAL:
// This filter provides the module name portion of the path to prevent
// plugins from accessing each other's data.
- if (!plugin_data_directory_.empty() &&
- !pepper_path.path().IsAbsolute() &&
+ if (!plugin_data_directory_.empty() && !pepper_path.path().IsAbsolute() &&
!pepper_path.path().ReferencesParent())
file_path = plugin_data_directory_.Append(pepper_path.path());
break;
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.h b/chromium/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.h
index f89d7cf5907..ab21076262b 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.h
+++ b/chromium/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.h
@@ -35,8 +35,7 @@ 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);
+ PepperFlashFileMessageFilter(PP_Instance instance, BrowserPpapiHost* host);
static base::FilePath GetDataDirName(const base::FilePath& profile_path);
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_gamepad_host.cc b/chromium/content/browser/renderer_host/pepper/pepper_gamepad_host.cc
index 818bf24a274..21d02d9bec8 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_gamepad_host.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_gamepad_host.cc
@@ -23,8 +23,7 @@ PepperGamepadHost::PepperGamepadHost(BrowserPpapiHost* host,
browser_ppapi_host_(host),
gamepad_service_(GamepadService::GetInstance()),
is_started_(false),
- weak_factory_(this) {
-}
+ weak_factory_(this) {}
PepperGamepadHost::PepperGamepadHost(GamepadService* gamepad_service,
BrowserPpapiHost* host,
@@ -34,21 +33,20 @@ PepperGamepadHost::PepperGamepadHost(GamepadService* gamepad_service,
browser_ppapi_host_(host),
gamepad_service_(gamepad_service),
is_started_(false),
- weak_factory_(this) {
-}
+ weak_factory_(this) {}
PepperGamepadHost::~PepperGamepadHost() {
if (is_started_)
- gamepad_service_->RemoveConsumer();
+ gamepad_service_->RemoveConsumer(this);
}
int32_t PepperGamepadHost::OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) {
- IPC_BEGIN_MESSAGE_MAP(PepperGamepadHost, msg)
+ PPAPI_BEGIN_MESSAGE_MAP(PepperGamepadHost, msg)
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_Gamepad_RequestMemory,
OnRequestMemory)
- IPC_END_MESSAGE_MAP()
+ PPAPI_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
@@ -57,7 +55,7 @@ int32_t PepperGamepadHost::OnRequestMemory(
if (is_started_)
return PP_ERROR_FAILED;
- gamepad_service_->AddConsumer();
+ gamepad_service_->ConsumerBecameActive(this);
is_started_ = true;
// Don't send the shared memory back until the user has interacted with the
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_gamepad_host.h b/chromium/content/browser/renderer_host/pepper/pepper_gamepad_host.h
index 1db73aa694a..c9f2c18fbc6 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_gamepad_host.h
+++ b/chromium/content/browser/renderer_host/pepper/pepper_gamepad_host.h
@@ -7,6 +7,7 @@
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
+#include "content/browser/gamepad/gamepad_consumer.h"
#include "content/common/content_export.h"
#include "ppapi/host/resource_host.h"
@@ -21,7 +22,9 @@ namespace content {
class BrowserPpapiHost;
class GamepadService;
-class CONTENT_EXPORT PepperGamepadHost : public ppapi::host::ResourceHost {
+class CONTENT_EXPORT PepperGamepadHost :
+ public ppapi::host::ResourceHost,
+ public GamepadConsumer {
public:
PepperGamepadHost(BrowserPpapiHost* host,
PP_Instance instance,
@@ -40,6 +43,14 @@ class CONTENT_EXPORT PepperGamepadHost : public ppapi::host::ResourceHost {
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) OVERRIDE;
+ // GamepadConsumer implementation.
+ virtual void OnGamepadConnected(
+ unsigned index,
+ const blink::WebGamepad& gamepad) OVERRIDE {}
+ virtual void OnGamepadDisconnected(
+ unsigned index,
+ const blink::WebGamepad& gamepad) OVERRIDE {}
+
private:
int32_t OnRequestMemory(ppapi::host::HostMessageContext* context);
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_gamepad_host_unittest.cc b/chromium/content/browser/renderer_host/pepper/pepper_gamepad_host_unittest.cc
index 43ff1170354..f86c944a46d 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_gamepad_host_unittest.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_gamepad_host_unittest.cc
@@ -22,14 +22,11 @@ namespace content {
namespace {
-class PepperGamepadHostTest
- : public testing::Test,
- public BrowserPpapiHostTest {
+class PepperGamepadHostTest : public testing::Test,
+ public BrowserPpapiHostTest {
public:
- PepperGamepadHostTest() {
- }
- virtual ~PepperGamepadHostTest() {
- }
+ PepperGamepadHostTest() {}
+ virtual ~PepperGamepadHostTest() {}
void ConstructService(const blink::WebGamepads& test_data) {
service_.reset(new GamepadServiceTestConstructor(test_data));
@@ -55,7 +52,7 @@ inline ptrdiff_t AddressDiff(const void* a, const void* b) {
TEST_F(PepperGamepadHostTest, ValidateHardwareBuffersMatch) {
// Hardware buffer.
COMPILE_ASSERT(sizeof(ppapi::ContentGamepadHardwareBuffer) ==
- sizeof(GamepadHardwareBuffer),
+ sizeof(GamepadHardwareBuffer),
gamepad_hardware_buffers_must_match);
ppapi::ContentGamepadHardwareBuffer ppapi_buf;
GamepadHardwareBuffer content_buf;
@@ -67,8 +64,7 @@ TEST_F(PepperGamepadHostTest, ValidateHardwareBuffersMatch) {
TEST_F(PepperGamepadHostTest, ValidateGamepadsMatch) {
// Gamepads.
- COMPILE_ASSERT(sizeof(ppapi::WebKitGamepads) ==
- sizeof(blink::WebGamepads),
+ COMPILE_ASSERT(sizeof(ppapi::WebKitGamepads) == sizeof(blink::WebGamepads),
gamepads_data_must_match);
ppapi::WebKitGamepads ppapi_gamepads;
blink::WebGamepads web_gamepads;
@@ -88,8 +84,7 @@ TEST_F(PepperGamepadHostTest, ValidateGamepadsMatch) {
TEST_F(PepperGamepadHostTest, ValidateGamepadMatch) {
// Gamepad.
- COMPILE_ASSERT(sizeof(ppapi::WebKitGamepad) ==
- sizeof(blink::WebGamepad),
+ COMPILE_ASSERT(sizeof(ppapi::WebKitGamepad) == sizeof(blink::WebGamepad),
gamepad_data_must_match);
ppapi::WebKitGamepad ppapi_gamepad;
blink::WebGamepad web_gamepad;
@@ -135,16 +130,15 @@ TEST_F(PepperGamepadHostTest, WaitForReply) {
PP_Instance pp_instance = 12345;
PP_Resource pp_resource = 67890;
- PepperGamepadHost gamepad_host(gamepad_service(), GetBrowserPpapiHost(),
- pp_instance, pp_resource);
+ PepperGamepadHost gamepad_host(
+ gamepad_service(), GetBrowserPpapiHost(), pp_instance, pp_resource);
// Synthesize a request for gamepad data.
ppapi::host::HostMessageContext context(
ppapi::proxy::ResourceMessageCallParams(pp_resource, 1));
EXPECT_EQ(PP_OK_COMPLETIONPENDING,
gamepad_host.OnResourceMessageReceived(
- PpapiHostMsg_Gamepad_RequestMemory(),
- &context));
+ PpapiHostMsg_Gamepad_RequestMemory(), &context));
// Wait for the gamepad background thread to read twice to make sure we
// don't get a message yet (see below for why).
@@ -164,7 +158,8 @@ TEST_F(PepperGamepadHostTest, WaitForReply) {
// ensures that it was able to issue callbacks for the first read (if it
// issued one) before we try to check for it.
blink::WebGamepads button_down_data = default_data;
- button_down_data.items[0].buttons[0] = 1.f;
+ button_down_data.items[0].buttons[0].value = 1.f;
+ button_down_data.items[0].buttons[0].pressed = true;
fetcher->SetTestData(button_down_data);
fetcher->WaitForDataRead();
fetcher->WaitForDataRead();
@@ -190,15 +185,16 @@ TEST_F(PepperGamepadHostTest, WaitForReply) {
EXPECT_EQ(button_down_data.items[0].buttonsLength,
buffer->buffer.items[0].buttons_length);
for (size_t i = 0; i < ppapi::WebKitGamepad::kButtonsLengthCap; i++) {
- EXPECT_EQ(button_down_data.items[0].buttons[i],
- buffer->buffer.items[0].buttons[i]);
+ EXPECT_EQ(button_down_data.items[0].buttons[i].value,
+ buffer->buffer.items[0].buttons[i].value);
+ EXPECT_EQ(button_down_data.items[0].buttons[i].pressed,
+ buffer->buffer.items[0].buttons[i].pressed);
}
// Duplicate requests should be denied.
EXPECT_EQ(PP_ERROR_FAILED,
gamepad_host.OnResourceMessageReceived(
- PpapiHostMsg_Gamepad_RequestMemory(),
- &context));
+ PpapiHostMsg_Gamepad_RequestMemory(), &context));
}
} // namespace content
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_host_resolver_message_filter.cc b/chromium/content/browser/renderer_host/pepper/pepper_host_resolver_message_filter.cc
index bdbdf871e27..3789ffa8593 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_host_resolver_message_filter.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_host_resolver_message_filter.cc
@@ -67,9 +67,8 @@ void CreateNetAddressListFromAddressList(
PP_NetAddress_Private address;
for (size_t i = 0; i < list.size(); ++i) {
- if (!ppapi::NetAddressPrivateImpl::IPEndPointToNetAddress(list[i].address(),
- list[i].port(),
- &address)) {
+ if (!ppapi::NetAddressPrivateImpl::IPEndPointToNetAddress(
+ list[i].address(), list[i].port(), &address)) {
net_address_list->clear();
return;
}
@@ -86,19 +85,16 @@ PepperHostResolverMessageFilter::PepperHostResolverMessageFilter(
: external_plugin_(host->external_plugin()),
private_api_(private_api),
render_process_id_(0),
- render_view_id_(0) {
+ render_frame_id_(0) {
DCHECK(host);
- if (!host->GetRenderViewIDsForInstance(
- instance,
- &render_process_id_,
- &render_view_id_)) {
+ if (!host->GetRenderFrameIDsForInstance(
+ instance, &render_process_id_, &render_frame_id_)) {
NOTREACHED();
}
}
-PepperHostResolverMessageFilter::~PepperHostResolverMessageFilter() {
-}
+PepperHostResolverMessageFilter::~PepperHostResolverMessageFilter() {}
scoped_refptr<base::TaskRunner>
PepperHostResolverMessageFilter::OverrideTaskRunnerForMessage(
@@ -111,10 +107,10 @@ PepperHostResolverMessageFilter::OverrideTaskRunnerForMessage(
int32_t PepperHostResolverMessageFilter::OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) {
- IPC_BEGIN_MESSAGE_MAP(PepperHostResolverMessageFilter, msg)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(
- PpapiHostMsg_HostResolver_Resolve, OnMsgResolve)
- IPC_END_MESSAGE_MAP()
+ PPAPI_BEGIN_MESSAGE_MAP(PepperHostResolverMessageFilter, msg)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_HostResolver_Resolve,
+ OnMsgResolve)
+ PPAPI_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
@@ -122,18 +118,16 @@ int32_t PepperHostResolverMessageFilter::OnMsgResolve(
const ppapi::host::HostMessageContext* context,
const ppapi::HostPortPair& host_port,
const PP_HostResolver_Private_Hint& hint) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
// Check plugin permissions.
SocketPermissionRequest request(
SocketPermissionRequest::RESOLVE_HOST, host_port.host, host_port.port);
- RenderViewHost* render_view_host =
- RenderViewHost::FromID(render_process_id_, render_view_id_);
- if (!render_view_host ||
- !pepper_socket_utils::CanUseSocketAPIs(external_plugin_,
+ if (!pepper_socket_utils::CanUseSocketAPIs(external_plugin_,
private_api_,
&request,
- render_view_host)) {
+ render_process_id_,
+ render_frame_id_)) {
return PP_ERROR_NOACCESS;
}
@@ -146,8 +140,10 @@ int32_t PepperHostResolverMessageFilter::OnMsgResolve(
return PP_ERROR_FAILED;
BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&PepperHostResolverMessageFilter::DoResolve, this,
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&PepperHostResolverMessageFilter::DoResolve,
+ this,
context->MakeReplyMessageContext(),
host_port,
hint,
@@ -160,7 +156,7 @@ void PepperHostResolverMessageFilter::DoResolve(
const ppapi::HostPortPair& host_port,
const PP_HostResolver_Private_Hint& hint,
ResourceContext* resource_context) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
net::HostResolver* host_resolver = resource_context->GetHostResolver();
if (!host_resolver) {
@@ -210,8 +206,8 @@ void PepperHostResolverMessageFilter::SendResolveReply(
ReplyMessageContext reply_context = context;
reply_context.params.set_result(result);
SendReply(reply_context,
- PpapiPluginMsg_HostResolver_ResolveReply(
- canonical_name, net_address_list));
+ PpapiPluginMsg_HostResolver_ResolveReply(canonical_name,
+ net_address_list));
}
void PepperHostResolverMessageFilter::SendResolveError(
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_host_resolver_message_filter.h b/chromium/content/browser/renderer_host/pepper/pepper_host_resolver_message_filter.h
index cc936036d3e..8fb404df4e3 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_host_resolver_message_filter.h
+++ b/chromium/content/browser/renderer_host/pepper/pepper_host_resolver_message_filter.h
@@ -79,7 +79,7 @@ class CONTENT_EXPORT PepperHostResolverMessageFilter
bool external_plugin_;
bool private_api_;
int render_process_id_;
- int render_view_id_;
+ int render_frame_id_;
DISALLOW_COPY_AND_ASSIGN(PepperHostResolverMessageFilter);
};
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.cc b/chromium/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.cc
index e57a237c503..bc7f2b6a119 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.cc
@@ -13,7 +13,6 @@
#include "content/browser/fileapi/browser_file_system_helper.h"
#include "content/browser/renderer_host/pepper/pepper_file_system_browser_host.h"
#include "content/public/browser/browser_context.h"
-#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/storage_partition.h"
#include "net/base/escape.h"
@@ -21,6 +20,7 @@
#include "ppapi/c/pp_file_info.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
+#include "ppapi/c/ppb_file_ref.h"
#include "ppapi/host/dispatch_host_message.h"
#include "ppapi/host/ppapi_host.h"
#include "ppapi/proxy/ppapi_messages.h"
@@ -47,22 +47,22 @@ PepperInternalFileRefBackend::PepperInternalFileRefBackend(
PpapiHost* host,
int render_process_id,
base::WeakPtr<PepperFileSystemBrowserHost> fs_host,
- const std::string& path) : host_(host),
- render_process_id_(render_process_id),
- fs_host_(fs_host),
- fs_type_(fs_host->GetType()),
- path_(path),
- weak_factory_(this) {
+ const std::string& path)
+ : host_(host),
+ render_process_id_(render_process_id),
+ fs_host_(fs_host),
+ fs_type_(fs_host->GetType()),
+ path_(path),
+ weak_factory_(this) {
ppapi::NormalizeInternalPath(&path_);
}
-PepperInternalFileRefBackend::~PepperInternalFileRefBackend() {
-}
+PepperInternalFileRefBackend::~PepperInternalFileRefBackend() {}
fileapi::FileSystemURL PepperInternalFileRefBackend::GetFileSystemURL() const {
if (!fs_url_.is_valid() && fs_host_.get() && fs_host_->IsOpened()) {
- GURL fs_path = fs_host_->GetRootUrl().Resolve(
- net::EscapePath(path_.substr(1)));
+ GURL fs_path =
+ fs_host_->GetRootUrl().Resolve(net::EscapePath(path_.substr(1)));
scoped_refptr<fileapi::FileSystemContext> fs_context =
GetFileSystemContext();
if (fs_context.get())
@@ -85,21 +85,21 @@ PepperInternalFileRefBackend::GetFileSystemContext() const {
void PepperInternalFileRefBackend::DidFinish(
ppapi::host::ReplyMessageContext context,
const IPC::Message& msg,
- base::PlatformFileError error) {
- context.params.set_result(ppapi::PlatformFileErrorToPepperError(error));
+ base::File::Error error) {
+ context.params.set_result(ppapi::FileErrorToPepperError(error));
host_->SendReply(context, msg);
}
int32_t PepperInternalFileRefBackend::MakeDirectory(
ppapi::host::ReplyMessageContext reply_context,
- bool make_ancestors) {
+ int32_t make_directory_flags) {
if (!GetFileSystemURL().is_valid())
return PP_ERROR_FAILED;
GetFileSystemContext()->operation_runner()->CreateDirectory(
GetFileSystemURL(),
- false,
- make_ancestors,
+ !!(make_directory_flags & PP_MAKEDIRECTORYFLAG_EXCLUSIVE),
+ !!(make_directory_flags & PP_MAKEDIRECTORYFLAG_WITH_ANCESTORS),
base::Bind(&PepperInternalFileRefBackend::DidFinish,
weak_factory_.GetWeakPtr(),
reply_context,
@@ -178,13 +178,13 @@ int32_t PepperInternalFileRefBackend::Query(
void PepperInternalFileRefBackend::GetMetadataComplete(
ppapi::host::ReplyMessageContext reply_context,
- base::PlatformFileError error,
- const base::PlatformFileInfo& file_info) {
- reply_context.params.set_result(ppapi::PlatformFileErrorToPepperError(error));
+ base::File::Error error,
+ const base::File::Info& file_info) {
+ reply_context.params.set_result(ppapi::FileErrorToPepperError(error));
PP_FileInfo pp_file_info;
- if (error == base::PLATFORM_FILE_OK)
- ppapi::PlatformFileInfoToPepperFileInfo(file_info, fs_type_, &pp_file_info);
+ if (error == base::File::FILE_OK)
+ ppapi::FileInfoToPepperFileInfo(file_info, fs_type_, &pp_file_info);
else
memset(&pp_file_info, 0, sizeof(pp_file_info));
@@ -197,33 +197,41 @@ int32_t PepperInternalFileRefBackend::ReadDirectoryEntries(
if (!GetFileSystemURL().is_valid())
return PP_ERROR_FAILED;
+ fileapi::FileSystemOperation::FileEntryList* accumulated_file_list =
+ new fileapi::FileSystemOperation::FileEntryList;
GetFileSystemContext()->operation_runner()->ReadDirectory(
GetFileSystemURL(),
base::Bind(&PepperInternalFileRefBackend::ReadDirectoryComplete,
weak_factory_.GetWeakPtr(),
- reply_context));
+ reply_context,
+ base::Owned(accumulated_file_list)));
return PP_OK_COMPLETIONPENDING;
}
void PepperInternalFileRefBackend::ReadDirectoryComplete(
ppapi::host::ReplyMessageContext context,
- base::PlatformFileError error,
+ fileapi::FileSystemOperation::FileEntryList* accumulated_file_list,
+ base::File::Error error,
const fileapi::FileSystemOperation::FileEntryList& file_list,
bool has_more) {
- // The current filesystem backend always returns false.
- DCHECK(!has_more);
+ accumulated_file_list->insert(
+ accumulated_file_list->end(), file_list.begin(), file_list.end());
+ if (has_more)
+ return;
- context.params.set_result(ppapi::PlatformFileErrorToPepperError(error));
+ context.params.set_result(ppapi::FileErrorToPepperError(error));
std::vector<ppapi::FileRefCreateInfo> infos;
std::vector<PP_FileType> file_types;
- if (error == base::PLATFORM_FILE_OK && fs_host_.get()) {
+ if (error == base::File::FILE_OK && fs_host_.get()) {
std::string dir_path = path_;
if (dir_path.empty() || dir_path[dir_path.size() - 1] != '/')
dir_path += '/';
for (fileapi::FileSystemOperation::FileEntryList::const_iterator it =
- file_list.begin(); it != file_list.end(); ++it) {
+ accumulated_file_list->begin();
+ it != accumulated_file_list->end();
+ ++it) {
if (it->is_directory)
file_types.push_back(PP_FILETYPE_DIRECTORY);
else
@@ -240,14 +248,15 @@ void PepperInternalFileRefBackend::ReadDirectoryComplete(
}
}
- host_->SendReply(context,
+ host_->SendReply(
+ context,
PpapiPluginMsg_FileRef_ReadDirectoryEntriesReply(infos, file_types));
}
int32_t PepperInternalFileRefBackend::GetAbsolutePath(
ppapi::host::ReplyMessageContext reply_context) {
host_->SendReply(reply_context,
- PpapiPluginMsg_FileRef_GetAbsolutePathReply(path_));
+ PpapiPluginMsg_FileRef_GetAbsolutePathReply(path_));
return PP_OK_COMPLETIONPENDING;
}
@@ -255,8 +264,8 @@ int32_t PepperInternalFileRefBackend::CanRead() const {
fileapi::FileSystemURL url = GetFileSystemURL();
if (!FileSystemURLIsValid(GetFileSystemContext().get(), url))
return PP_ERROR_FAILED;
- if (!ChildProcessSecurityPolicyImpl::GetInstance()->
- CanReadFileSystemFile(render_process_id_, url)) {
+ if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFileSystemFile(
+ render_process_id_, url)) {
return PP_ERROR_NOACCESS;
}
return PP_OK;
@@ -266,8 +275,8 @@ int32_t PepperInternalFileRefBackend::CanWrite() const {
fileapi::FileSystemURL url = GetFileSystemURL();
if (!FileSystemURLIsValid(GetFileSystemContext().get(), url))
return PP_ERROR_FAILED;
- if (!ChildProcessSecurityPolicyImpl::GetInstance()->
- CanWriteFileSystemFile(render_process_id_, url)) {
+ if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanWriteFileSystemFile(
+ render_process_id_, url)) {
return PP_ERROR_NOACCESS;
}
return PP_OK;
@@ -277,8 +286,8 @@ int32_t PepperInternalFileRefBackend::CanCreate() const {
fileapi::FileSystemURL url = GetFileSystemURL();
if (!FileSystemURLIsValid(GetFileSystemContext().get(), url))
return PP_ERROR_FAILED;
- if (!ChildProcessSecurityPolicyImpl::GetInstance()->
- CanCreateFileSystemFile(render_process_id_, url)) {
+ if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanCreateFileSystemFile(
+ render_process_id_, url)) {
return PP_ERROR_NOACCESS;
}
return PP_OK;
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.h b/chromium/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.h
index 93dbab97a3e..4214de01785 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.h
+++ b/chromium/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.h
@@ -32,7 +32,7 @@ class PepperInternalFileRefBackend : public PepperFileRefBackend {
// PepperFileRefBackend overrides.
virtual int32_t MakeDirectory(ppapi::host::ReplyMessageContext context,
- bool make_ancestors) OVERRIDE;
+ int32_t make_directory_flags) OVERRIDE;
virtual int32_t Touch(ppapi::host::ReplyMessageContext context,
PP_Time last_accessed_time,
PP_Time last_modified_time) OVERRIDE;
@@ -40,8 +40,8 @@ class PepperInternalFileRefBackend : public PepperFileRefBackend {
virtual int32_t Rename(ppapi::host::ReplyMessageContext context,
PepperFileRefHost* new_file_ref) OVERRIDE;
virtual int32_t Query(ppapi::host::ReplyMessageContext context) OVERRIDE;
- virtual int32_t ReadDirectoryEntries(
- ppapi::host::ReplyMessageContext context) OVERRIDE;
+ virtual int32_t ReadDirectoryEntries(ppapi::host::ReplyMessageContext context)
+ OVERRIDE;
virtual int32_t GetAbsolutePath(ppapi::host::ReplyMessageContext context)
OVERRIDE;
virtual fileapi::FileSystemURL GetFileSystemURL() const OVERRIDE;
@@ -56,16 +56,16 @@ class PepperInternalFileRefBackend : public PepperFileRefBackend {
// Generic reply callback.
void DidFinish(ppapi::host::ReplyMessageContext reply_context,
const IPC::Message& msg,
- base::PlatformFileError error);
+ base::File::Error error);
// Operation specific callbacks.
- void GetMetadataComplete(
- ppapi::host::ReplyMessageContext reply_context,
- base::PlatformFileError error,
- const base::PlatformFileInfo& file_info);
+ void GetMetadataComplete(ppapi::host::ReplyMessageContext reply_context,
+ base::File::Error error,
+ const base::File::Info& file_info);
void ReadDirectoryComplete(
ppapi::host::ReplyMessageContext context,
- base::PlatformFileError error,
+ fileapi::FileSystemOperation::FileEntryList* accumulated_file_list,
+ base::File::Error error,
const fileapi::FileSystemOperation::FileEntryList& file_list,
bool has_more);
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_lookup_request.h b/chromium/content/browser/renderer_host/pepper/pepper_lookup_request.h
index da116fd640c..b36bd5e2f4e 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_lookup_request.h
+++ b/chromium/content/browser/renderer_host/pepper/pepper_lookup_request.h
@@ -14,7 +14,7 @@
namespace content {
-template<class T>
+template <class T>
class PepperLookupRequest {
public:
typedef base::Callback<void(int, const net::AddressList&, const T&)>
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_message_filter.cc b/chromium/content/browser/renderer_host/pepper/pepper_message_filter.cc
index 1394d956f0d..0eaa5ec9bc1 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_message_filter.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_message_filter.cc
@@ -11,19 +11,18 @@
namespace content {
-PepperMessageFilter::PepperMessageFilter() {}
+PepperMessageFilter::PepperMessageFilter()
+ : BrowserMessageFilter(PpapiMsgStart) {}
+
PepperMessageFilter::~PepperMessageFilter() {}
-bool PepperMessageFilter::OnMessageReceived(const IPC::Message& msg,
- bool* message_was_ok) {
+bool PepperMessageFilter::OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
- IPC_BEGIN_MESSAGE_MAP_EX(PepperMessageFilter, msg, *message_was_ok)
- // X509 certificate messages.
+ IPC_BEGIN_MESSAGE_MAP(PepperMessageFilter, msg)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBX509Certificate_ParseDER,
- OnX509CertificateParseDER);
-
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP_EX()
+ OnX509CertificateParseDER)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
return handled;
}
@@ -32,7 +31,7 @@ void PepperMessageFilter::OnX509CertificateParseDER(
bool* succeeded,
ppapi::PPB_X509Certificate_Fields* result) {
*succeeded = (der.size() != 0 && pepper_socket_utils::GetCertificateFields(
- &der[0], der.size(), result));
+ &der[0], der.size(), result));
}
} // namespace content
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_message_filter.h b/chromium/content/browser/renderer_host/pepper/pepper_message_filter.h
index 3f5010ed40e..68dac47fc8d 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_message_filter.h
+++ b/chromium/content/browser/renderer_host/pepper/pepper_message_filter.h
@@ -24,8 +24,7 @@ class PepperMessageFilter : public BrowserMessageFilter {
PepperMessageFilter();
// BrowserMessageFilter methods.
- virtual bool OnMessageReceived(const IPC::Message& message,
- bool* message_was_ok) OVERRIDE;
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
protected:
virtual ~PepperMessageFilter();
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_network_monitor_host.cc b/chromium/content/browser/renderer_host/pepper/pepper_network_monitor_host.cc
index b53a60b779b..bc5795b6e41 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_network_monitor_host.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_network_monitor_host.cc
@@ -13,47 +13,49 @@
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/shared_impl/private/net_address_private_impl.h"
-
namespace content {
namespace {
bool CanUseNetworkMonitor(bool external_plugin,
int render_process_id,
- int render_view_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ int render_frame_id) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
SocketPermissionRequest request = SocketPermissionRequest(
SocketPermissionRequest::NETWORK_STATE, std::string(), 0);
- return pepper_socket_utils::CanUseSocketAPIs(
- external_plugin, false /* private_api */, &request, render_process_id,
- render_view_id);
+ return pepper_socket_utils::CanUseSocketAPIs(external_plugin,
+ false /* private_api */,
+ &request,
+ render_process_id,
+ render_frame_id);
}
scoped_ptr<net::NetworkInterfaceList> GetNetworkList() {
scoped_ptr<net::NetworkInterfaceList> list(new net::NetworkInterfaceList());
- net::GetNetworkList(list.get());
+ net::GetNetworkList(list.get(), net::INCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES);
return list.Pass();
}
} // namespace
-PepperNetworkMonitorHost::PepperNetworkMonitorHost(
- BrowserPpapiHostImpl* host,
- PP_Instance instance,
- PP_Resource resource)
+PepperNetworkMonitorHost::PepperNetworkMonitorHost(BrowserPpapiHostImpl* host,
+ PP_Instance instance,
+ PP_Resource resource)
: ResourceHost(host->GetPpapiHost(), instance, resource),
weak_factory_(this) {
int render_process_id;
- int render_view_id;
- host->GetRenderViewIDsForInstance(instance,
- &render_process_id,
- &render_view_id);
+ int render_frame_id;
+ host->GetRenderFrameIDsForInstance(
+ instance, &render_process_id, &render_frame_id);
BrowserThread::PostTaskAndReplyWithResult(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&CanUseNetworkMonitor, host->external_plugin(),
- render_process_id, render_view_id),
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&CanUseNetworkMonitor,
+ host->external_plugin(),
+ render_process_id,
+ render_frame_id),
base::Bind(&PepperNetworkMonitorHost::OnPermissionCheckResult,
weak_factory_.GetWeakPtr()));
}
@@ -62,9 +64,7 @@ PepperNetworkMonitorHost::~PepperNetworkMonitorHost() {
net::NetworkChangeNotifier::RemoveIPAddressObserver(this);
}
-void PepperNetworkMonitorHost::OnIPAddressChanged() {
- GetAndSendNetworkList();
-}
+void PepperNetworkMonitorHost::OnIPAddressChanged() { GetAndSendNetworkList(); }
void PepperNetworkMonitorHost::OnPermissionCheckResult(
bool can_use_network_monitor) {
@@ -79,11 +79,12 @@ void PepperNetworkMonitorHost::OnPermissionCheckResult(
}
void PepperNetworkMonitorHost::GetAndSendNetworkList() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
// Call GetNetworkList() on a thread that allows blocking IO.
base::PostTaskAndReplyWithResult(
- BrowserThread::GetBlockingPool(), FROM_HERE,
+ BrowserThread::GetBlockingPool(),
+ FROM_HERE,
base::Bind(&GetNetworkList),
base::Bind(&PepperNetworkMonitorHost::SendNetworkList,
weak_factory_.GetWeakPtr()));
@@ -91,7 +92,7 @@ void PepperNetworkMonitorHost::GetAndSendNetworkList() {
void PepperNetworkMonitorHost::SendNetworkList(
scoped_ptr<net::NetworkInterfaceList> list) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
scoped_ptr<ppapi::proxy::SerializedNetworkList> list_copy(
new ppapi::proxy::SerializedNetworkList(list->size()));
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_network_monitor_host.h b/chromium/content/browser/renderer_host/pepper/pepper_network_monitor_host.h
index e27f8a2ac21..12241c5c5b4 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_network_monitor_host.h
+++ b/chromium/content/browser/renderer_host/pepper/pepper_network_monitor_host.h
@@ -22,10 +22,9 @@ class CONTENT_EXPORT PepperNetworkMonitorHost
: public ppapi::host::ResourceHost,
public net::NetworkChangeNotifier::IPAddressObserver {
public:
- PepperNetworkMonitorHost(
- BrowserPpapiHostImpl* host,
- PP_Instance instance,
- PP_Resource resource);
+ PepperNetworkMonitorHost(BrowserPpapiHostImpl* host,
+ PP_Instance instance,
+ PP_Resource resource);
virtual ~PepperNetworkMonitorHost();
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_network_proxy_host.cc b/chromium/content/browser/renderer_host/pepper/pepper_network_proxy_host.cc
index 13f0fc3733f..4b3d817b66e 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_network_proxy_host.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_network_proxy_host.cc
@@ -30,15 +30,15 @@ PepperNetworkProxyHost::PepperNetworkProxyHost(BrowserPpapiHostImpl* host,
is_allowed_(false),
waiting_for_ui_thread_data_(true),
weak_factory_(this) {
- int render_process_id(0), render_view_id(0);
- host->GetRenderViewIDsForInstance(instance,
- &render_process_id,
- &render_view_id);
+ int render_process_id(0), render_frame_id(0);
+ host->GetRenderFrameIDsForInstance(
+ instance, &render_process_id, &render_frame_id);
BrowserThread::PostTaskAndReplyWithResult(
- BrowserThread::UI, FROM_HERE,
+ BrowserThread::UI,
+ FROM_HERE,
base::Bind(&GetUIThreadDataOnUIThread,
render_process_id,
- render_view_id,
+ render_frame_id,
host->external_plugin()),
base::Bind(&PepperNetworkProxyHost::DidGetUIThreadData,
weak_factory_.GetWeakPtr()));
@@ -55,38 +55,33 @@ PepperNetworkProxyHost::~PepperNetworkProxyHost() {
}
}
-PepperNetworkProxyHost::UIThreadData::UIThreadData()
- : is_allowed(false) {
-}
+PepperNetworkProxyHost::UIThreadData::UIThreadData() : is_allowed(false) {}
-PepperNetworkProxyHost::UIThreadData::~UIThreadData() {
-}
+PepperNetworkProxyHost::UIThreadData::~UIThreadData() {}
// static
PepperNetworkProxyHost::UIThreadData
PepperNetworkProxyHost::GetUIThreadDataOnUIThread(int render_process_id,
- int render_view_id,
+ int render_frame_id,
bool is_external_plugin) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
PepperNetworkProxyHost::UIThreadData result;
RenderProcessHost* render_process_host =
RenderProcessHost::FromID(render_process_id);
if (render_process_host && render_process_host->GetBrowserContext()) {
- result.context_getter = render_process_host->GetBrowserContext()->
- GetRequestContextForRenderProcess(render_process_id);
+ result.context_getter =
+ render_process_host->GetBrowserContext()
+ ->GetRequestContextForRenderProcess(render_process_id);
}
- RenderViewHost* render_view_host =
- RenderViewHost::FromID(render_process_id, render_view_id);
- if (render_view_host) {
- SocketPermissionRequest request(
- content::SocketPermissionRequest::RESOLVE_PROXY, std::string(), 0);
- result.is_allowed = pepper_socket_utils::CanUseSocketAPIs(
- is_external_plugin,
- false /* is_private_api */,
- &request,
- render_view_host);
- }
+ SocketPermissionRequest request(
+ content::SocketPermissionRequest::RESOLVE_PROXY, std::string(), 0);
+ result.is_allowed =
+ pepper_socket_utils::CanUseSocketAPIs(is_external_plugin,
+ false /* is_private_api */,
+ &request,
+ render_process_id,
+ render_frame_id);
return result;
}
@@ -109,10 +104,10 @@ void PepperNetworkProxyHost::DidGetUIThreadData(
int32_t PepperNetworkProxyHost::OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) {
- IPC_BEGIN_MESSAGE_MAP(PepperNetworkProxyHost, msg)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(
- PpapiHostMsg_NetworkProxy_GetProxyForURL, OnMsgGetProxyForURL)
- IPC_END_MESSAGE_MAP()
+ PPAPI_BEGIN_MESSAGE_MAP(PepperNetworkProxyHost, msg)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_NetworkProxy_GetProxyForURL,
+ OnMsgGetProxyForURL)
+ PPAPI_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
@@ -121,12 +116,11 @@ int32_t PepperNetworkProxyHost::OnMsgGetProxyForURL(
const std::string& url) {
GURL gurl(url);
if (gurl.is_valid()) {
- UnsentRequest request = { gurl, context->MakeReplyMessageContext() };
+ UnsentRequest request = {gurl, context->MakeReplyMessageContext()};
unsent_requests_.push(request);
TryToSendUnsentRequests();
} else {
- SendFailureReply(PP_ERROR_BADARGUMENT,
- context->MakeReplyMessageContext());
+ SendFailureReply(PP_ERROR_BADARGUMENT, context->MakeReplyMessageContext());
}
return PP_OK_COMPLETIONPENDING;
}
@@ -145,7 +139,7 @@ void PepperNetworkProxyHost::TryToSendUnsentRequests() {
// Everything looks valid, so try to resolve the proxy.
net::ProxyInfo* proxy_info = new net::ProxyInfo;
net::ProxyService::PacRequest* pending_request = NULL;
- base::Callback<void (int)> callback =
+ base::Callback<void(int)> callback =
base::Bind(&PepperNetworkProxyHost::OnResolveProxyCompleted,
weak_factory_.GetWeakPtr(),
request.reply_context,
@@ -187,9 +181,8 @@ void PepperNetworkProxyHost::SendFailureReply(
int32_t error,
ppapi::host::ReplyMessageContext context) {
context.params.set_result(error);
- host()->SendReply(context,
- PpapiPluginMsg_NetworkProxy_GetProxyForURLReply(
- std::string()));
+ host()->SendReply(
+ context, PpapiPluginMsg_NetworkProxy_GetProxyForURLReply(std::string()));
}
} // namespace content
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_network_proxy_host.h b/chromium/content/browser/renderer_host/pepper/pepper_network_proxy_host.h
index 38e36cb13e6..28f52b66273 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_network_proxy_host.h
+++ b/chromium/content/browser/renderer_host/pepper/pepper_network_proxy_host.h
@@ -50,7 +50,7 @@ class CONTENT_EXPORT PepperNetworkProxyHost : public ppapi::host::ResourceHost {
scoped_refptr<net::URLRequestContextGetter> context_getter;
};
static UIThreadData GetUIThreadDataOnUIThread(int render_process_id,
- int render_view_id,
+ int render_frame_id,
bool is_external_plugin);
void DidGetUIThreadData(const UIThreadData&);
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_print_settings_manager.cc b/chromium/content/browser/renderer_host/pepper/pepper_print_settings_manager.cc
index 84aaddfd2f7..de5f5fec949 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_print_settings_manager.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_print_settings_manager.cc
@@ -17,37 +17,37 @@ namespace {
// Print units conversion functions.
int32_t DeviceUnitsInPoints(int32_t device_units,
int32_t device_units_per_inch) {
- return printing::ConvertUnit(device_units, device_units_per_inch,
- printing::kPointsPerInch);
+ return printing::ConvertUnit(
+ device_units, device_units_per_inch, printing::kPointsPerInch);
}
PP_Size PrintSizeToPPPrintSize(const gfx::Size& print_size,
int32_t device_units_per_inch) {
PP_Size result;
result.width = DeviceUnitsInPoints(print_size.width(), device_units_per_inch);
- result.height = DeviceUnitsInPoints(print_size.height(),
- device_units_per_inch);
+ result.height =
+ DeviceUnitsInPoints(print_size.height(), device_units_per_inch);
return result;
}
PP_Rect PrintAreaToPPPrintArea(const gfx::Rect& print_area,
int32_t device_units_per_inch) {
PP_Rect result;
- result.point.x = DeviceUnitsInPoints(print_area.origin().x(),
- device_units_per_inch);
- result.point.y = DeviceUnitsInPoints(print_area.origin().y(),
- device_units_per_inch);
- result.size = PrintSizeToPPPrintSize(print_area.size(),
- device_units_per_inch);
+ result.point.x =
+ DeviceUnitsInPoints(print_area.origin().x(), device_units_per_inch);
+ result.point.y =
+ DeviceUnitsInPoints(print_area.origin().y(), device_units_per_inch);
+ result.size =
+ PrintSizeToPPPrintSize(print_area.size(), device_units_per_inch);
return result;
}
PepperPrintSettingsManager::Result ComputeDefaultPrintSettings() {
// This function should run on the UI thread because |PrintingContext| methods
// call into platform APIs.
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
scoped_ptr<printing::PrintingContext> context(
- printing::PrintingContext::Create(std::string()));
+ printing::PrintingContext::Create(std::string()));
if (!context.get() ||
context->UseDefaultSettings() != printing::PrintingContext::OK) {
return PepperPrintSettingsManager::Result(PP_PrintSettings_Dev(),
@@ -55,19 +55,19 @@ PepperPrintSettingsManager::Result ComputeDefaultPrintSettings() {
}
const printing::PrintSettings& print_settings = context->settings();
const printing::PageSetup& page_setup =
- print_settings.page_setup_device_units();
+ print_settings.page_setup_device_units();
int device_units_per_inch = print_settings.device_units_per_inch();
if (device_units_per_inch <= 0) {
return PepperPrintSettingsManager::Result(PP_PrintSettings_Dev(),
PP_ERROR_FAILED);
}
PP_PrintSettings_Dev settings;
- settings.printable_area = PrintAreaToPPPrintArea(
- page_setup.printable_area(), device_units_per_inch);
- settings.content_area = PrintAreaToPPPrintArea(
- page_setup.content_area(), device_units_per_inch);
- settings.paper_size = PrintSizeToPPPrintSize(
- page_setup.physical_size(), device_units_per_inch);
+ settings.printable_area = PrintAreaToPPPrintArea(page_setup.printable_area(),
+ device_units_per_inch);
+ settings.content_area =
+ PrintAreaToPPPrintArea(page_setup.content_area(), device_units_per_inch);
+ settings.paper_size =
+ PrintSizeToPPPrintSize(page_setup.physical_size(), device_units_per_inch);
settings.dpi = print_settings.dpi();
// The remainder of the attributes are hard-coded to the defaults as set
@@ -94,8 +94,11 @@ PepperPrintSettingsManager::Result ComputeDefaultPrintSettings() {
void PepperPrintSettingsManagerImpl::GetDefaultPrintSettings(
PepperPrintSettingsManager::Callback callback) {
- BrowserThread::PostTaskAndReplyWithResult(BrowserThread::UI, FROM_HERE,
- base::Bind(ComputeDefaultPrintSettings), callback);
+ BrowserThread::PostTaskAndReplyWithResult(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(ComputeDefaultPrintSettings),
+ callback);
}
} // namespace content
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_printing_host.cc b/chromium/content/browser/renderer_host/pepper/pepper_printing_host.cc
index c11939c34a8..047f1203d72 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_printing_host.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_printing_host.cc
@@ -20,20 +20,18 @@ PepperPrintingHost::PepperPrintingHost(
scoped_ptr<PepperPrintSettingsManager> print_settings_manager)
: ResourceHost(host, instance, resource),
print_settings_manager_(print_settings_manager.Pass()),
- weak_factory_(this) {
-}
+ weak_factory_(this) {}
-PepperPrintingHost::~PepperPrintingHost() {
-}
+PepperPrintingHost::~PepperPrintingHost() {}
int32_t PepperPrintingHost::OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) {
- IPC_BEGIN_MESSAGE_MAP(PepperPrintingHost, msg)
+ PPAPI_BEGIN_MESSAGE_MAP(PepperPrintingHost, msg)
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
PpapiHostMsg_Printing_GetDefaultPrintSettings,
OnGetDefaultPrintSettings)
- IPC_END_MESSAGE_MAP()
+ PPAPI_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
@@ -50,9 +48,9 @@ void PepperPrintingHost::PrintSettingsCallback(
ppapi::host::ReplyMessageContext reply_context,
PepperPrintSettingsManager::Result result) {
reply_context.params.set_result(result.second);
- host()->SendReply(reply_context,
+ host()->SendReply(
+ reply_context,
PpapiPluginMsg_Printing_GetDefaultPrintSettingsReply(result.first));
}
-
} // namespace content
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_printing_host.h b/chromium/content/browser/renderer_host/pepper/pepper_printing_host.h
index 4c302ee7f5a..ec956292b2d 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_printing_host.h
+++ b/chromium/content/browser/renderer_host/pepper/pepper_printing_host.h
@@ -30,12 +30,10 @@ class CONTENT_EXPORT PepperPrintingHost : public ppapi::host::ResourceHost {
ppapi::host::HostMessageContext* context) OVERRIDE;
private:
- int32_t OnGetDefaultPrintSettings(
- ppapi::host::HostMessageContext* context);
+ int32_t OnGetDefaultPrintSettings(ppapi::host::HostMessageContext* context);
- void PrintSettingsCallback(
- ppapi::host::ReplyMessageContext reply_context,
- PepperPrintSettingsManager::Result result);
+ void PrintSettingsCallback(ppapi::host::ReplyMessageContext reply_context,
+ PepperPrintSettingsManager::Result result);
scoped_ptr<PepperPrintSettingsManager> print_settings_manager_;
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_printing_host_unittest.cc b/chromium/content/browser/renderer_host/pepper/pepper_printing_host_unittest.cc
index a46db10b384..d9780425d20 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_printing_host_unittest.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_printing_host_unittest.cc
@@ -18,8 +18,7 @@ namespace content {
namespace {
// Mock implementation of |PepperPrintSettingsManager| for test purposes.
-class MockPepperPrintSettingsManager
- : public PepperPrintSettingsManager {
+class MockPepperPrintSettingsManager : public PepperPrintSettingsManager {
public:
MockPepperPrintSettingsManager(const PP_PrintSettings_Dev& settings);
virtual ~MockPepperPrintSettingsManager() {}
@@ -27,6 +26,7 @@ class MockPepperPrintSettingsManager
// PepperPrintSettingsManager implementation.
virtual void GetDefaultPrintSettings(
PepperPrintSettingsManager::Callback callback) OVERRIDE;
+
private:
PP_PrintSettings_Dev settings_;
@@ -35,23 +35,19 @@ class MockPepperPrintSettingsManager
MockPepperPrintSettingsManager::MockPepperPrintSettingsManager(
const PP_PrintSettings_Dev& settings)
- : settings_(settings) {
-}
+ : settings_(settings) {}
void MockPepperPrintSettingsManager::GetDefaultPrintSettings(
PepperPrintSettingsManager::Callback callback) {
callback.Run(PepperPrintSettingsManager::Result(settings_, PP_OK));
}
-class PepperPrintingHostTest
- : public testing::Test,
- public BrowserPpapiHostTest {
+class PepperPrintingHostTest : public testing::Test,
+ public BrowserPpapiHostTest {
public:
- PepperPrintingHostTest() {
- }
+ PepperPrintingHostTest() {}
- virtual ~PepperPrintingHostTest() {
- }
+ virtual ~PepperPrintingHostTest() {}
DISALLOW_COPY_AND_ASSIGN(PepperPrintingHostTest);
};
@@ -61,9 +57,8 @@ bool PP_SizeEqual(const PP_Size& lhs, const PP_Size& rhs) {
}
bool PP_RectEqual(const PP_Rect& lhs, const PP_Rect& rhs) {
- return lhs.point.x == rhs.point.x &&
- lhs.point.y == rhs.point.y &&
- PP_SizeEqual(lhs.size, rhs.size);
+ return lhs.point.x == rhs.point.x && lhs.point.y == rhs.point.y &&
+ PP_SizeEqual(lhs.size, rhs.size);
}
} // namespace
@@ -71,22 +66,22 @@ bool PP_RectEqual(const PP_Rect& lhs, const PP_Rect& rhs) {
TEST_F(PepperPrintingHostTest, GetDefaultPrintSettings) {
PP_Instance pp_instance = 12345;
PP_Resource pp_resource = 67890;
- PP_PrintSettings_Dev expected_settings = {
- { { 0, 0 }, { 500, 515 } },
- { { 25, 35 }, { 300, 720 } },
- { 600, 700 },
- 200,
- PP_PRINTORIENTATION_NORMAL,
- PP_PRINTSCALINGOPTION_NONE,
- PP_FALSE,
- PP_PRINTOUTPUTFORMAT_PDF
- };
+ PP_PrintSettings_Dev expected_settings = {{{0, 0}, {500, 515}},
+ {{25, 35}, {300, 720}},
+ {600, 700},
+ 200,
+ PP_PRINTORIENTATION_NORMAL,
+ PP_PRINTSCALINGOPTION_NONE,
+ PP_FALSE,
+ PP_PRINTOUTPUTFORMAT_PDF};
// Construct the resource host.
scoped_ptr<PepperPrintSettingsManager> manager(
new MockPepperPrintSettingsManager(expected_settings));
PepperPrintingHost printing(GetBrowserPpapiHost()->GetPpapiHost(),
- pp_instance, pp_resource, manager.Pass());
+ pp_instance,
+ pp_resource,
+ manager.Pass());
// Simulate a message being received.
ppapi::proxy::ResourceMessageCallParams call_params(pp_resource, 1);
@@ -99,7 +94,8 @@ TEST_F(PepperPrintingHostTest, GetDefaultPrintSettings) {
ppapi::proxy::ResourceMessageReplyParams reply_params;
IPC::Message reply_msg;
ASSERT_TRUE(sink().GetFirstResourceReplyMatching(
- PpapiPluginMsg_Printing_GetDefaultPrintSettingsReply::ID, &reply_params,
+ PpapiPluginMsg_Printing_GetDefaultPrintSettingsReply::ID,
+ &reply_params,
&reply_msg));
// Validation of reply.
@@ -115,8 +111,8 @@ TEST_F(PepperPrintingHostTest, GetDefaultPrintSettings) {
actual_settings.printable_area));
EXPECT_TRUE(PP_RectEqual(expected_settings.content_area,
actual_settings.content_area));
- EXPECT_TRUE(PP_SizeEqual(expected_settings.paper_size,
- actual_settings.paper_size));
+ EXPECT_TRUE(
+ PP_SizeEqual(expected_settings.paper_size, actual_settings.paper_size));
EXPECT_EQ(expected_settings.dpi, actual_settings.dpi);
EXPECT_EQ(expected_settings.orientation, actual_settings.orientation);
EXPECT_EQ(expected_settings.print_scaling_option,
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_renderer_connection.cc b/chromium/content/browser/renderer_host/pepper/pepper_renderer_connection.cc
index 1c00388870c..8c233bbc6a7 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_renderer_connection.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_renderer_connection.cc
@@ -19,18 +19,18 @@
#include "ppapi/host/resource_host.h"
#include "ppapi/proxy/ppapi_message_utils.h"
#include "ppapi/proxy/ppapi_messages.h"
-#include "ppapi/proxy/ppapi_message_utils.h"
#include "ppapi/proxy/resource_message_params.h"
namespace content {
namespace {
+const uint32 kFilteredMessageClasses[] = {PpapiMsgStart, ViewMsgStart, };
+
// Responsible for creating the pending resource hosts, holding their IDs until
// all of them have been created for a single message, and sending the reply to
// say that the hosts have been created.
-class PendingHostCreator
- : public base::RefCounted<PendingHostCreator> {
+class PendingHostCreator : public base::RefCounted<PendingHostCreator> {
public:
PendingHostCreator(BrowserPpapiHostImpl* host,
BrowserMessageFilter* connection,
@@ -87,7 +87,9 @@ PendingHostCreator::~PendingHostCreator() {
} // namespace
PepperRendererConnection::PepperRendererConnection(int render_process_id)
- : render_process_id_(render_process_id) {
+ : BrowserMessageFilter(kFilteredMessageClasses,
+ arraysize(kFilteredMessageClasses)),
+ render_process_id_(render_process_id) {
// Only give the renderer permission for stable APIs.
in_process_host_.reset(new BrowserPpapiHostImpl(this,
ppapi::PpapiPermissions(),
@@ -98,12 +100,11 @@ PepperRendererConnection::PepperRendererConnection(int render_process_id)
false /* external_plugin */));
}
-PepperRendererConnection::~PepperRendererConnection() {
-}
+PepperRendererConnection::~PepperRendererConnection() {}
BrowserPpapiHostImpl* PepperRendererConnection::GetHostForChildProcess(
int child_process_id) const {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
// Find the plugin which this message refers to. Check NaCl plugins first.
BrowserPpapiHostImpl* host = static_cast<BrowserPpapiHostImpl*>(
@@ -131,13 +132,12 @@ BrowserPpapiHostImpl* PepperRendererConnection::GetHostForChildProcess(
return host;
}
-bool PepperRendererConnection::OnMessageReceived(const IPC::Message& msg,
- bool* message_was_ok) {
+bool PepperRendererConnection::OnMessageReceived(const IPC::Message& msg) {
if (in_process_host_->GetPpapiHost()->OnMessageReceived(msg))
return true;
bool handled = true;
- IPC_BEGIN_MESSAGE_MAP_EX(PepperRendererConnection, msg, *message_was_ok)
+ IPC_BEGIN_MESSAGE_MAP(PepperRendererConnection, msg)
IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostsFromHost,
OnMsgCreateResourceHostsFromHost)
IPC_MESSAGE_HANDLER(ViewHostMsg_DidCreateInProcessInstance,
@@ -145,7 +145,7 @@ bool PepperRendererConnection::OnMessageReceived(const IPC::Message& msg,
IPC_MESSAGE_HANDLER(ViewHostMsg_DidDeleteInProcessInstance,
OnMsgDidDeleteInProcessInstance)
IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP_EX()
+ IPC_END_MESSAGE_MAP()
return handled;
}
@@ -168,12 +168,12 @@ void PepperRendererConnection::OnMsgCreateResourceHostsFromHost(
const IPC::Message& nested_msg = nested_msgs[i];
scoped_ptr<ppapi::host::ResourceHost> resource_host;
if (host->IsValidInstance(instance)) {
- if (nested_msg.type() == PpapiHostMsg_FileRef_CreateExternal::ID) {
- // FileRef_CreateExternal is only permitted from the renderer. Because
+ if (nested_msg.type() == PpapiHostMsg_FileRef_CreateForRawFS::ID) {
+ // FileRef_CreateForRawFS is only permitted from the renderer. Because
// of this, we handle this message here and not in
// content_browser_pepper_host_factory.cc.
base::FilePath external_path;
- if (ppapi::UnpackMessage<PpapiHostMsg_FileRef_CreateExternal>(
+ if (ppapi::UnpackMessage<PpapiHostMsg_FileRef_CreateForRawFS>(
nested_msg, &external_path)) {
resource_host.reset(new PepperFileRefHost(
host, instance, params.pp_resource(), external_path));
@@ -187,21 +187,18 @@ void PepperRendererConnection::OnMsgCreateResourceHostsFromHost(
if (ppapi::UnpackMessage<PpapiHostMsg_FileSystem_CreateFromRenderer>(
nested_msg, &root_url, &file_system_type)) {
PepperFileSystemBrowserHost* browser_host =
- new PepperFileSystemBrowserHost(host,
- instance,
- params.pp_resource(),
- file_system_type);
+ new PepperFileSystemBrowserHost(
+ host, instance, params.pp_resource(), file_system_type);
resource_host.reset(browser_host);
// Open the file system resource host. This is an asynchronous
// operation, and we must only add the pending resource host and
// send the message once it completes.
browser_host->OpenExisting(
GURL(root_url),
- base::Bind(
- &PendingHostCreator::AddPendingResourceHost,
- creator,
- i,
- base::Passed(&resource_host)));
+ base::Bind(&PendingHostCreator::AddPendingResourceHost,
+ creator,
+ i,
+ base::Passed(&resource_host)));
// Do not fall through; the fall-through case adds the pending
// resource host to the list. We must do this asynchronously.
continue;
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_renderer_connection.h b/chromium/content/browser/renderer_host/pepper/pepper_renderer_connection.h
index 157827a9cfd..5683ab9ed0c 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_renderer_connection.h
+++ b/chromium/content/browser/renderer_host/pepper/pepper_renderer_connection.h
@@ -36,8 +36,7 @@ class PepperRendererConnection : public BrowserMessageFilter {
explicit PepperRendererConnection(int render_process_id);
// BrowserMessageFilter overrides.
- virtual bool OnMessageReceived(const IPC::Message& msg,
- bool* message_was_ok) OVERRIDE;
+ virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
private:
virtual ~PepperRendererConnection();
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_security_helper.cc b/chromium/content/browser/renderer_host/pepper/pepper_security_helper.cc
index 4e1306eb816..ab516283d58 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_security_helper.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_security_helper.cc
@@ -12,8 +12,10 @@ namespace content {
namespace {
-template <typename CanRead, typename CanWrite,
- typename CanCreate, typename CanCreateReadWrite,
+template <typename CanRead,
+ typename CanWrite,
+ typename CanCreate,
+ typename CanCreateReadWrite,
typename FileID>
bool CanOpenFileWithPepperFlags(CanRead can_read,
CanWrite can_write,
@@ -58,27 +60,32 @@ bool CanOpenFileWithPepperFlags(CanRead can_read,
return true;
}
-
}
-bool CanOpenWithPepperFlags(int pp_open_flags, int child_id,
+bool CanOpenWithPepperFlags(int pp_open_flags,
+ int child_id,
const base::FilePath& file) {
return CanOpenFileWithPepperFlags(
&ChildProcessSecurityPolicyImpl::CanReadFile,
&ChildProcessSecurityPolicyImpl::CanCreateReadWriteFile,
&ChildProcessSecurityPolicyImpl::CanCreateReadWriteFile,
&ChildProcessSecurityPolicyImpl::CanCreateReadWriteFile,
- pp_open_flags, child_id, file);
+ pp_open_flags,
+ child_id,
+ file);
}
-bool CanOpenFileSystemURLWithPepperFlags(int pp_open_flags, int child_id,
+bool CanOpenFileSystemURLWithPepperFlags(int pp_open_flags,
+ int child_id,
const fileapi::FileSystemURL& url) {
return CanOpenFileWithPepperFlags(
&ChildProcessSecurityPolicyImpl::CanReadFileSystemFile,
&ChildProcessSecurityPolicyImpl::CanWriteFileSystemFile,
&ChildProcessSecurityPolicyImpl::CanCreateFileSystemFile,
&ChildProcessSecurityPolicyImpl::CanCreateReadWriteFileSystemFile,
- pp_open_flags, child_id, url);
+ pp_open_flags,
+ child_id,
+ url);
}
} // namespace content
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_socket_utils.cc b/chromium/content/browser/renderer_host/pepper/pepper_socket_utils.cc
index 2f109cddb71..dda97a1718b 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_socket_utils.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_socket_utils.cc
@@ -9,9 +9,10 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
+#include "base/strings/string_util.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
-#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/site_instance.h"
#include "content/public/common/content_client.h"
#include "net/cert/x509_certificate.h"
@@ -25,13 +26,12 @@ namespace pepper_socket_utils {
SocketPermissionRequest CreateSocketPermissionRequest(
SocketPermissionRequest::OperationType type,
const PP_NetAddress_Private& net_addr) {
- std::string host = ppapi::NetAddressPrivateImpl::DescribeNetAddress(net_addr,
- false);
+ std::string host =
+ ppapi::NetAddressPrivateImpl::DescribeNetAddress(net_addr, false);
int port = 0;
std::vector<unsigned char> address;
- ppapi::NetAddressPrivateImpl::NetAddressToIPEndPoint(net_addr,
- &address,
- &port);
+ ppapi::NetAddressPrivateImpl::NetAddressToIPEndPoint(
+ net_addr, &address, &port);
return SocketPermissionRequest(type, host, port);
}
@@ -39,22 +39,8 @@ bool CanUseSocketAPIs(bool external_plugin,
bool private_api,
const SocketPermissionRequest* params,
int render_process_id,
- int render_view_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- RenderViewHost* render_view_host = RenderViewHost::FromID(render_process_id,
- render_view_id);
- return render_view_host && CanUseSocketAPIs(external_plugin,
- private_api,
- params,
- render_view_host);
-}
-
-bool CanUseSocketAPIs(bool external_plugin,
- bool private_api,
- const SocketPermissionRequest* params,
- RenderViewHost* render_view_host) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
+ int render_frame_id) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!external_plugin) {
// Always allow socket APIs for out-process plugins (other than external
// plugins instantiated by the embeeder through
@@ -62,9 +48,11 @@ bool CanUseSocketAPIs(bool external_plugin,
return true;
}
- if (!render_view_host)
+ RenderFrameHost* render_frame_host =
+ RenderFrameHost::FromID(render_process_id, render_frame_id);
+ if (!render_frame_host)
return false;
- SiteInstance* site_instance = render_view_host->GetSiteInstance();
+ SiteInstance* site_instance = render_frame_host->GetSiteInstance();
if (!site_instance)
return false;
if (!GetContentClient()->browser()->AllowPepperSocketAPI(
@@ -84,43 +72,48 @@ bool GetCertificateFields(const net::X509Certificate& cert,
ppapi::PPB_X509Certificate_Fields* fields) {
const net::CertPrincipal& issuer = cert.issuer();
fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_COMMON_NAME,
- new base::StringValue(issuer.common_name));
+ new base::StringValue(issuer.common_name));
fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_LOCALITY_NAME,
- new base::StringValue(issuer.locality_name));
+ new base::StringValue(issuer.locality_name));
fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_STATE_OR_PROVINCE_NAME,
- new base::StringValue(issuer.state_or_province_name));
+ new base::StringValue(issuer.state_or_province_name));
fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_COUNTRY_NAME,
- new base::StringValue(issuer.country_name));
- fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_NAME,
+ new base::StringValue(issuer.country_name));
+ fields->SetField(
+ PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_NAME,
new base::StringValue(JoinString(issuer.organization_names, '\n')));
- fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_UNIT_NAME,
+ fields->SetField(
+ PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_UNIT_NAME,
new base::StringValue(JoinString(issuer.organization_unit_names, '\n')));
const net::CertPrincipal& subject = cert.subject();
fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_COMMON_NAME,
- new base::StringValue(subject.common_name));
+ new base::StringValue(subject.common_name));
fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_LOCALITY_NAME,
- new base::StringValue(subject.locality_name));
+ new base::StringValue(subject.locality_name));
fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_STATE_OR_PROVINCE_NAME,
- new base::StringValue(subject.state_or_province_name));
+ new base::StringValue(subject.state_or_province_name));
fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_COUNTRY_NAME,
- new base::StringValue(subject.country_name));
- fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_NAME,
+ new base::StringValue(subject.country_name));
+ fields->SetField(
+ PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_NAME,
new base::StringValue(JoinString(subject.organization_names, '\n')));
- fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_UNIT_NAME,
+ fields->SetField(
+ PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_UNIT_NAME,
new base::StringValue(JoinString(subject.organization_unit_names, '\n')));
const std::string& serial_number = cert.serial_number();
fields->SetField(PP_X509CERTIFICATE_PRIVATE_SERIAL_NUMBER,
- base::BinaryValue::CreateWithCopiedBuffer(serial_number.data(),
- serial_number.length()));
+ base::BinaryValue::CreateWithCopiedBuffer(
+ serial_number.data(), serial_number.length()));
fields->SetField(PP_X509CERTIFICATE_PRIVATE_VALIDITY_NOT_BEFORE,
- new base::FundamentalValue(cert.valid_start().ToDoubleT()));
+ new base::FundamentalValue(cert.valid_start().ToDoubleT()));
fields->SetField(PP_X509CERTIFICATE_PRIVATE_VALIDITY_NOT_AFTER,
- new base::FundamentalValue(cert.valid_expiry().ToDoubleT()));
+ new base::FundamentalValue(cert.valid_expiry().ToDoubleT()));
std::string der;
net::X509Certificate::GetDEREncoded(cert.os_cert_handle(), &der);
- fields->SetField(PP_X509CERTIFICATE_PRIVATE_RAW,
+ fields->SetField(
+ PP_X509CERTIFICATE_PRIVATE_RAW,
base::BinaryValue::CreateWithCopiedBuffer(der.data(), der.length()));
return true;
}
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_socket_utils.h b/chromium/content/browser/renderer_host/pepper/pepper_socket_utils.h
index 1a1a26cac19..e7bc1e3eb04 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_socket_utils.h
+++ b/chromium/content/browser/renderer_host/pepper/pepper_socket_utils.h
@@ -20,8 +20,6 @@ class PPB_X509Certificate_Fields;
namespace content {
-class RenderViewHost;
-
namespace pepper_socket_utils {
SocketPermissionRequest CreateSocketPermissionRequest(
@@ -35,13 +33,7 @@ bool CanUseSocketAPIs(bool external_plugin,
bool private_api,
const SocketPermissionRequest* params,
int render_process_id,
- int render_view_id);
-
-// TODO (ygorshenin@): remove this method.
-bool CanUseSocketAPIs(bool external_plugin,
- bool private_api,
- const SocketPermissionRequest* params,
- RenderViewHost* render_view_host);
+ int render_frame_id);
// Extracts the certificate field data from a net::X509Certificate into
// PPB_X509Certificate_Fields.
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc b/chromium/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc
index 063c11ed784..87ba64f54c1 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc
@@ -49,13 +49,12 @@ PepperTCPServerSocketMessageFilter::PepperTCPServerSocketMessageFilter(
external_plugin_(host->external_plugin()),
private_api_(private_api),
render_process_id_(0),
- render_view_id_(0) {
+ render_frame_id_(0) {
++g_num_instances;
DCHECK(factory_);
DCHECK(ppapi_host_);
- if (!host->GetRenderViewIDsForInstance(instance,
- &render_process_id_,
- &render_view_id_)) {
+ if (!host->GetRenderFrameIDsForInstance(
+ instance, &render_process_id_, &render_frame_id_)) {
NOTREACHED();
}
}
@@ -85,14 +84,14 @@ PepperTCPServerSocketMessageFilter::OverrideTaskRunnerForMessage(
int32_t PepperTCPServerSocketMessageFilter::OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) {
- IPC_BEGIN_MESSAGE_MAP(PepperTCPServerSocketMessageFilter, msg)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(
- PpapiHostMsg_TCPServerSocket_Listen, OnMsgListen)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
- PpapiHostMsg_TCPServerSocket_Accept, OnMsgAccept)
+ PPAPI_BEGIN_MESSAGE_MAP(PepperTCPServerSocketMessageFilter, msg)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_TCPServerSocket_Listen,
+ OnMsgListen)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_TCPServerSocket_Accept,
+ OnMsgAccept)
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
PpapiHostMsg_TCPServerSocket_StopListening, OnMsgStopListening)
- IPC_END_MESSAGE_MAP()
+ PPAPI_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
@@ -100,7 +99,7 @@ int32_t PepperTCPServerSocketMessageFilter::OnMsgListen(
const ppapi::host::HostMessageContext* context,
const PP_NetAddress_Private& addr,
int32_t backlog) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(context);
SocketPermissionRequest request =
@@ -110,20 +109,24 @@ int32_t PepperTCPServerSocketMessageFilter::OnMsgListen(
private_api_,
&request,
render_process_id_,
- render_view_id_)) {
+ render_frame_id_)) {
return PP_ERROR_NOACCESS;
}
BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&PepperTCPServerSocketMessageFilter::DoListen, this,
- context->MakeReplyMessageContext(), addr, backlog));
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&PepperTCPServerSocketMessageFilter::DoListen,
+ this,
+ context->MakeReplyMessageContext(),
+ addr,
+ backlog));
return PP_OK_COMPLETIONPENDING;
}
int32_t PepperTCPServerSocketMessageFilter::OnMsgAccept(
const ppapi::host::HostMessageContext* context) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(context);
if (state_ != STATE_LISTENING)
@@ -136,7 +139,8 @@ int32_t PepperTCPServerSocketMessageFilter::OnMsgAccept(
&accepted_socket_,
&accepted_address_,
base::Bind(&PepperTCPServerSocketMessageFilter::OnAcceptCompleted,
- base::Unretained(this), reply_context));
+ base::Unretained(this),
+ reply_context));
if (net_result != net::ERR_IO_PENDING)
OnAcceptCompleted(reply_context, net_result);
return PP_OK_COMPLETIONPENDING;
@@ -144,7 +148,7 @@ int32_t PepperTCPServerSocketMessageFilter::OnMsgAccept(
int32_t PepperTCPServerSocketMessageFilter::OnMsgStopListening(
const ppapi::host::HostMessageContext* context) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(context);
state_ = STATE_CLOSED;
@@ -156,7 +160,7 @@ void PepperTCPServerSocketMessageFilter::DoListen(
const ppapi::host::ReplyMessageContext& context,
const PP_NetAddress_Private& addr,
int32_t backlog) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
net::IPAddressNumber address;
int port;
@@ -215,9 +219,8 @@ void PepperTCPServerSocketMessageFilter::OnListenCompleted(
state_ = STATE_BEFORE_LISTENING;
return;
}
- if (!NetAddressPrivateImpl::IPEndPointToNetAddress(end_point.address(),
- end_point.port(),
- &addr)) {
+ if (!NetAddressPrivateImpl::IPEndPointToNetAddress(
+ end_point.address(), end_point.port(), &addr)) {
SendListenError(context, PP_ERROR_FAILED);
state_ = STATE_BEFORE_LISTENING;
return;
@@ -249,9 +252,8 @@ void PepperTCPServerSocketMessageFilter::OnAcceptCompleted(
PP_NetAddress_Private local_addr = NetAddressPrivateImpl::kInvalidNetAddress;
PP_NetAddress_Private remote_addr = NetAddressPrivateImpl::kInvalidNetAddress;
- int32_t pp_result =
- NetErrorToPepperError(accepted_socket_->GetLocalAddress(
- &ip_end_point_local));
+ int32_t pp_result = NetErrorToPepperError(
+ accepted_socket_->GetLocalAddress(&ip_end_point_local));
if (pp_result != PP_OK) {
SendAcceptError(context, pp_result);
return;
@@ -269,18 +271,17 @@ void PepperTCPServerSocketMessageFilter::OnAcceptCompleted(
}
scoped_ptr<ppapi::host::ResourceHost> host =
- factory_->CreateAcceptedTCPSocket(
- instance_, ppapi::TCP_SOCKET_VERSION_PRIVATE,
- accepted_socket_.Pass());
+ factory_->CreateAcceptedTCPSocket(instance_,
+ ppapi::TCP_SOCKET_VERSION_PRIVATE,
+ accepted_socket_.Pass());
if (!host) {
SendAcceptError(context, PP_ERROR_NOSPACE);
return;
}
int pending_resource_id = ppapi_host_->AddPendingResourceHost(host.Pass());
if (pending_resource_id) {
- SendAcceptReply(context, PP_OK, pending_resource_id,
- local_addr,
- remote_addr);
+ SendAcceptReply(
+ context, PP_OK, pending_resource_id, local_addr, remote_addr);
} else {
SendAcceptError(context, PP_ERROR_NOSPACE);
}
@@ -299,8 +300,8 @@ void PepperTCPServerSocketMessageFilter::SendListenReply(
void PepperTCPServerSocketMessageFilter::SendListenError(
const ppapi::host::ReplyMessageContext& context,
int32_t pp_result) {
- SendListenReply(context, pp_result,
- NetAddressPrivateImpl::kInvalidNetAddress);
+ SendListenReply(
+ context, pp_result, NetAddressPrivateImpl::kInvalidNetAddress);
}
void PepperTCPServerSocketMessageFilter::SendAcceptReply(
@@ -311,8 +312,9 @@ void PepperTCPServerSocketMessageFilter::SendAcceptReply(
const PP_NetAddress_Private& remote_addr) {
ppapi::host::ReplyMessageContext reply_context(context);
reply_context.params.set_result(pp_result);
- SendReply(reply_context, PpapiPluginMsg_TCPServerSocket_AcceptReply(
- pending_resource_id, local_addr, remote_addr));
+ SendReply(reply_context,
+ PpapiPluginMsg_TCPServerSocket_AcceptReply(
+ pending_resource_id, local_addr, remote_addr));
}
void PepperTCPServerSocketMessageFilter::SendAcceptError(
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.h b/chromium/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.h
index 5d17333c9e8..43262fc8c1a 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.h
+++ b/chromium/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.h
@@ -33,11 +33,10 @@ class ContentBrowserPepperHostFactory;
class CONTENT_EXPORT PepperTCPServerSocketMessageFilter
: public ppapi::host::ResourceMessageFilter {
public:
- PepperTCPServerSocketMessageFilter(
- ContentBrowserPepperHostFactory* factory,
- BrowserPpapiHostImpl* host,
- PP_Instance instance,
- bool private_api);
+ PepperTCPServerSocketMessageFilter(ContentBrowserPepperHostFactory* factory,
+ BrowserPpapiHostImpl* host,
+ PP_Instance instance,
+ bool private_api);
static size_t GetNumInstances();
@@ -105,7 +104,7 @@ class CONTENT_EXPORT PepperTCPServerSocketMessageFilter
const bool external_plugin_;
const bool private_api_;
int render_process_id_;
- int render_view_id_;
+ int render_frame_id_;
DISALLOW_COPY_AND_ASSIGN(PepperTCPServerSocketMessageFilter);
};
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_tcp_socket.cc b/chromium/content/browser/renderer_host/pepper/pepper_tcp_socket.cc
index c5b752aa7f5..474a2fd6bd5 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_tcp_socket.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_tcp_socket.cc
@@ -37,12 +37,11 @@ using ppapi::NetAddressPrivateImpl;
namespace content {
-PepperTCPSocket::PepperTCPSocket(
- PepperMessageFilter* manager,
- int32 routing_id,
- uint32 plugin_dispatcher_id,
- uint32 socket_id,
- bool private_api)
+PepperTCPSocket::PepperTCPSocket(PepperMessageFilter* manager,
+ int32 routing_id,
+ uint32 plugin_dispatcher_id,
+ uint32 socket_id,
+ bool private_api)
: manager_(manager),
routing_id_(routing_id),
plugin_dispatcher_id_(plugin_dispatcher_id),
@@ -53,13 +52,12 @@ PepperTCPSocket::PepperTCPSocket(
DCHECK(manager);
}
-PepperTCPSocket::PepperTCPSocket(
- PepperMessageFilter* manager,
- int32 routing_id,
- uint32 plugin_dispatcher_id,
- uint32 socket_id,
- net::StreamSocket* socket,
- bool private_api)
+PepperTCPSocket::PepperTCPSocket(PepperMessageFilter* manager,
+ int32 routing_id,
+ uint32 plugin_dispatcher_id,
+ uint32 socket_id,
+ net::StreamSocket* socket,
+ bool private_api)
: manager_(manager),
routing_id_(routing_id),
plugin_dispatcher_id_(plugin_dispatcher_id),
@@ -78,7 +76,7 @@ PepperTCPSocket::~PepperTCPSocket() {
}
void PepperTCPSocket::Connect(const std::string& host, uint16_t port) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (connection_state_ != BEFORE_CONNECT) {
SendConnectACKError(PP_ERROR_FAILED);
@@ -101,7 +99,7 @@ void PepperTCPSocket::Connect(const std::string& host, uint16_t port) {
void PepperTCPSocket::ConnectWithNetAddress(
const PP_NetAddress_Private& net_addr) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (connection_state_ != BEFORE_CONNECT) {
SendConnectACKError(PP_ERROR_FAILED);
@@ -110,8 +108,8 @@ void PepperTCPSocket::ConnectWithNetAddress(
net::IPAddressNumber address;
int port;
- if (!NetAddressPrivateImpl::NetAddressToIPEndPoint(net_addr, &address,
- &port)) {
+ if (!NetAddressPrivateImpl::NetAddressToIPEndPoint(
+ net_addr, &address, &port)) {
SendConnectACKError(PP_ERROR_ADDRESS_INVALID);
return;
}
@@ -128,7 +126,7 @@ void PepperTCPSocket::SSLHandshake(
uint16_t server_port,
const std::vector<std::vector<char> >& trusted_certs,
const std::vector<std::vector<char> >& untrusted_certs) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
// Allow to do SSL handshake only if currently the socket has been connected
// and there isn't pending read or write.
@@ -159,15 +157,14 @@ void PepperTCPSocket::SSLHandshake(
return;
}
- int net_result = socket_->Connect(
- base::Bind(&PepperTCPSocket::OnSSLHandshakeCompleted,
- base::Unretained(this)));
+ int net_result = socket_->Connect(base::Bind(
+ &PepperTCPSocket::OnSSLHandshakeCompleted, base::Unretained(this)));
if (net_result != net::ERR_IO_PENDING)
OnSSLHandshakeCompleted(net_result);
}
void PepperTCPSocket::Read(int32 bytes_to_read) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!IsConnected() || end_of_file_reached_) {
SendReadACKError(PP_ERROR_FAILED);
@@ -195,7 +192,7 @@ void PepperTCPSocket::Read(int32 bytes_to_read) {
}
void PepperTCPSocket::Write(const std::string& data) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!IsConnected()) {
SendWriteACKError(PP_ERROR_FAILED);
@@ -223,7 +220,7 @@ void PepperTCPSocket::Write(const std::string& data) {
void PepperTCPSocket::SetOption(PP_TCPSocket_Option name,
const ppapi::SocketOptionData& value) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!IsConnected() || IsSsl()) {
SendSetOptionACK(PP_ERROR_FAILED);
@@ -242,8 +239,8 @@ void PepperTCPSocket::SetOption(PP_TCPSocket_Option name,
return;
}
- SendSetOptionACK(
- tcp_socket->SetNoDelay(boolean_value) ? PP_OK : PP_ERROR_FAILED);
+ SendSetOptionACK(tcp_socket->SetNoDelay(boolean_value) ? PP_OK
+ : PP_ERROR_FAILED);
return;
}
case PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE:
@@ -254,21 +251,22 @@ void PepperTCPSocket::SetOption(PP_TCPSocket_Option name,
return;
}
- bool result = false;
+ int net_result = net::OK;
if (name == PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE) {
if (integer_value > ppapi::TCPSocketShared::kMaxSendBufferSize) {
SendSetOptionACK(PP_ERROR_BADARGUMENT);
return;
}
- result = tcp_socket->SetSendBufferSize(integer_value);
+ net_result = tcp_socket->SetSendBufferSize(integer_value);
} else {
if (integer_value > ppapi::TCPSocketShared::kMaxReceiveBufferSize) {
SendSetOptionACK(PP_ERROR_BADARGUMENT);
return;
}
- result = tcp_socket->SetReceiveBufferSize(integer_value);
+ net_result = tcp_socket->SetReceiveBufferSize(integer_value);
}
- SendSetOptionACK(result ? PP_OK : PP_ERROR_FAILED);
+ // TODO(wtc): Add error mapping.
+ SendSetOptionACK((net_result == net::OK) ? PP_OK : PP_ERROR_FAILED);
return;
}
default: {
@@ -282,18 +280,20 @@ void PepperTCPSocket::SetOption(PP_TCPSocket_Option name,
void PepperTCPSocket::StartConnect(const net::AddressList& addresses) {
DCHECK(connection_state_ == CONNECT_IN_PROGRESS);
- socket_.reset(new net::TCPClientSocket(addresses, NULL,
- net::NetLog::Source()));
+ socket_.reset(
+ new net::TCPClientSocket(addresses, NULL, net::NetLog::Source()));
int net_result = socket_->Connect(
- base::Bind(&PepperTCPSocket::OnConnectCompleted,
- base::Unretained(this)));
+ base::Bind(&PepperTCPSocket::OnConnectCompleted, base::Unretained(this)));
if (net_result != net::ERR_IO_PENDING)
OnConnectCompleted(net_result);
}
void PepperTCPSocket::SendConnectACKError(int32_t error) {
manager_->Send(new PpapiMsg_PPBTCPSocket_ConnectACK(
- routing_id_, plugin_dispatcher_id_, socket_id_, error,
+ routing_id_,
+ plugin_dispatcher_id_,
+ socket_id_,
+ error,
NetAddressPrivateImpl::kInvalidNetAddress,
NetAddressPrivateImpl::kInvalidNetAddress));
}
@@ -304,43 +304,48 @@ bool PepperTCPSocket::GetCertificateFields(
ppapi::PPB_X509Certificate_Fields* fields) {
const net::CertPrincipal& issuer = cert.issuer();
fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_COMMON_NAME,
- new base::StringValue(issuer.common_name));
+ new base::StringValue(issuer.common_name));
fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_LOCALITY_NAME,
- new base::StringValue(issuer.locality_name));
+ new base::StringValue(issuer.locality_name));
fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_STATE_OR_PROVINCE_NAME,
- new base::StringValue(issuer.state_or_province_name));
+ new base::StringValue(issuer.state_or_province_name));
fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_COUNTRY_NAME,
- new base::StringValue(issuer.country_name));
- fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_NAME,
+ new base::StringValue(issuer.country_name));
+ fields->SetField(
+ PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_NAME,
new base::StringValue(JoinString(issuer.organization_names, '\n')));
- fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_UNIT_NAME,
+ fields->SetField(
+ PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_UNIT_NAME,
new base::StringValue(JoinString(issuer.organization_unit_names, '\n')));
const net::CertPrincipal& subject = cert.subject();
fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_COMMON_NAME,
- new base::StringValue(subject.common_name));
+ new base::StringValue(subject.common_name));
fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_LOCALITY_NAME,
- new base::StringValue(subject.locality_name));
+ new base::StringValue(subject.locality_name));
fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_STATE_OR_PROVINCE_NAME,
- new base::StringValue(subject.state_or_province_name));
+ new base::StringValue(subject.state_or_province_name));
fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_COUNTRY_NAME,
- new base::StringValue(subject.country_name));
- fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_NAME,
+ new base::StringValue(subject.country_name));
+ fields->SetField(
+ PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_NAME,
new base::StringValue(JoinString(subject.organization_names, '\n')));
- fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_UNIT_NAME,
+ fields->SetField(
+ PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_UNIT_NAME,
new base::StringValue(JoinString(subject.organization_unit_names, '\n')));
const std::string& serial_number = cert.serial_number();
fields->SetField(PP_X509CERTIFICATE_PRIVATE_SERIAL_NUMBER,
- base::BinaryValue::CreateWithCopiedBuffer(serial_number.data(),
- serial_number.length()));
+ base::BinaryValue::CreateWithCopiedBuffer(
+ serial_number.data(), serial_number.length()));
fields->SetField(PP_X509CERTIFICATE_PRIVATE_VALIDITY_NOT_BEFORE,
- new base::FundamentalValue(cert.valid_start().ToDoubleT()));
+ new base::FundamentalValue(cert.valid_start().ToDoubleT()));
fields->SetField(PP_X509CERTIFICATE_PRIVATE_VALIDITY_NOT_AFTER,
- new base::FundamentalValue(cert.valid_expiry().ToDoubleT()));
+ new base::FundamentalValue(cert.valid_expiry().ToDoubleT()));
std::string der;
net::X509Certificate::GetDEREncoded(cert.os_cert_handle(), &der);
- fields->SetField(PP_X509CERTIFICATE_PRIVATE_RAW,
+ fields->SetField(
+ PP_X509CERTIFICATE_PRIVATE_RAW,
base::BinaryValue::CreateWithCopiedBuffer(der.data(), der.length()));
return true;
}
@@ -359,7 +364,7 @@ bool PepperTCPSocket::GetCertificateFields(
void PepperTCPSocket::SendReadACKError(int32_t error) {
manager_->Send(new PpapiMsg_PPBTCPSocket_ReadACK(
- routing_id_, plugin_dispatcher_id_, socket_id_, error, std::string()));
+ routing_id_, plugin_dispatcher_id_, socket_id_, error, std::string()));
}
void PepperTCPSocket::SendWriteACKError(int32_t error) {
@@ -379,12 +384,12 @@ void PepperTCPSocket::SendSSLHandshakeACK(bool succeeded) {
if (ssl_info.cert.get())
GetCertificateFields(*ssl_info.cert.get(), &certificate_fields);
}
- manager_->Send(new PpapiMsg_PPBTCPSocket_SSLHandshakeACK(
- routing_id_,
- plugin_dispatcher_id_,
- socket_id_,
- succeeded,
- certificate_fields));
+ manager_->Send(
+ new PpapiMsg_PPBTCPSocket_SSLHandshakeACK(routing_id_,
+ plugin_dispatcher_id_,
+ socket_id_,
+ succeeded,
+ certificate_fields));
}
void PepperTCPSocket::SendSetOptionACK(int32_t result) {
@@ -414,12 +419,12 @@ void PepperTCPSocket::OnConnectCompleted(int net_result) {
net::IPEndPoint ip_end_point_local;
net::IPEndPoint ip_end_point_remote;
- pp_result = NetErrorToPepperError(
- socket_->GetLocalAddress(&ip_end_point_local));
+ pp_result =
+ NetErrorToPepperError(socket_->GetLocalAddress(&ip_end_point_local));
if (pp_result != PP_OK)
break;
- pp_result = NetErrorToPepperError(
- socket_->GetPeerAddress(&ip_end_point_remote));
+ pp_result =
+ NetErrorToPepperError(socket_->GetPeerAddress(&ip_end_point_remote));
if (pp_result != PP_OK)
break;
@@ -439,9 +444,12 @@ void PepperTCPSocket::OnConnectCompleted(int net_result) {
break;
}
- manager_->Send(new PpapiMsg_PPBTCPSocket_ConnectACK(
- routing_id_, plugin_dispatcher_id_, socket_id_, PP_OK,
- local_addr, remote_addr));
+ manager_->Send(new PpapiMsg_PPBTCPSocket_ConnectACK(routing_id_,
+ plugin_dispatcher_id_,
+ socket_id_,
+ PP_OK,
+ local_addr,
+ remote_addr));
connection_state_ = CONNECTED;
return;
} while (false);
@@ -463,7 +471,10 @@ void PepperTCPSocket::OnReadCompleted(int net_result) {
if (net_result > 0) {
manager_->Send(new PpapiMsg_PPBTCPSocket_ReadACK(
- routing_id_, plugin_dispatcher_id_, socket_id_, PP_OK,
+ routing_id_,
+ plugin_dispatcher_id_,
+ socket_id_,
+ PP_OK,
std::string(read_buffer_->data(), net_result)));
} else if (net_result == 0) {
end_of_file_reached_ = true;
@@ -490,9 +501,11 @@ void PepperTCPSocket::OnWriteCompleted(int net_result) {
}
if (net_result >= 0) {
- manager_->Send(new PpapiMsg_PPBTCPSocket_WriteACK(
- routing_id_, plugin_dispatcher_id_, socket_id_,
- write_buffer_->BytesConsumed()));
+ manager_->Send(
+ new PpapiMsg_PPBTCPSocket_WriteACK(routing_id_,
+ plugin_dispatcher_id_,
+ socket_id_,
+ write_buffer_->BytesConsumed()));
} else {
SendWriteACKError(NetErrorToPepperError(net_result));
}
@@ -506,9 +519,9 @@ bool PepperTCPSocket::IsConnected() const {
}
bool PepperTCPSocket::IsSsl() const {
- return connection_state_ == SSL_HANDSHAKE_IN_PROGRESS ||
- connection_state_ == SSL_CONNECTED ||
- connection_state_ == SSL_HANDSHAKE_FAILED;
+ return connection_state_ == SSL_HANDSHAKE_IN_PROGRESS ||
+ connection_state_ == SSL_CONNECTED ||
+ connection_state_ == SSL_HANDSHAKE_FAILED;
}
void PepperTCPSocket::DoWrite() {
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc b/chromium/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc
index f943f39eb9e..38248f42341 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc
@@ -56,7 +56,7 @@ PepperTCPSocketMessageFilter::PepperTCPSocketMessageFilter(
: version_(version),
external_plugin_(host->external_plugin()),
render_process_id_(0),
- render_view_id_(0),
+ render_frame_id_(0),
ppapi_host_(host->GetPpapiHost()),
factory_(factory),
instance_(instance),
@@ -69,9 +69,8 @@ PepperTCPSocketMessageFilter::PepperTCPSocketMessageFilter(
pending_accept_(false) {
DCHECK(host);
++g_num_instances;
- if (!host->GetRenderViewIDsForInstance(instance,
- &render_process_id_,
- &render_view_id_)) {
+ if (!host->GetRenderFrameIDsForInstance(
+ instance, &render_process_id_, &render_frame_id_)) {
NOTREACHED();
}
}
@@ -84,7 +83,7 @@ PepperTCPSocketMessageFilter::PepperTCPSocketMessageFilter(
: version_(version),
external_plugin_(host->external_plugin()),
render_process_id_(0),
- render_view_id_(0),
+ render_frame_id_(0),
ppapi_host_(host->GetPpapiHost()),
factory_(NULL),
instance_(instance),
@@ -99,9 +98,8 @@ PepperTCPSocketMessageFilter::PepperTCPSocketMessageFilter(
DCHECK_NE(version, ppapi::TCP_SOCKET_VERSION_1_0);
++g_num_instances;
- if (!host->GetRenderViewIDsForInstance(instance,
- &render_process_id_,
- &render_view_id_)) {
+ if (!host->GetRenderFrameIDsForInstance(
+ instance, &render_process_id_, &render_frame_id_)) {
NOTREACHED();
}
}
@@ -142,36 +140,33 @@ PepperTCPSocketMessageFilter::OverrideTaskRunnerForMessage(
int32_t PepperTCPSocketMessageFilter::OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) {
- IPC_BEGIN_MESSAGE_MAP(PepperTCPSocketMessageFilter, msg)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(
- PpapiHostMsg_TCPSocket_Bind, OnMsgBind)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(
- PpapiHostMsg_TCPSocket_Connect, OnMsgConnect)
+ PPAPI_BEGIN_MESSAGE_MAP(PepperTCPSocketMessageFilter, msg)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_TCPSocket_Bind, OnMsgBind)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_TCPSocket_Connect,
+ OnMsgConnect)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(
PpapiHostMsg_TCPSocket_ConnectWithNetAddress,
OnMsgConnectWithNetAddress)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(
- PpapiHostMsg_TCPSocket_SSLHandshake, OnMsgSSLHandshake)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(
- PpapiHostMsg_TCPSocket_Read, OnMsgRead)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(
- PpapiHostMsg_TCPSocket_Write, OnMsgWrite)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(
- PpapiHostMsg_TCPSocket_Listen, OnMsgListen)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
- PpapiHostMsg_TCPSocket_Accept, OnMsgAccept)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
- PpapiHostMsg_TCPSocket_Close, OnMsgClose)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(
- PpapiHostMsg_TCPSocket_SetOption, OnMsgSetOption)
- IPC_END_MESSAGE_MAP()
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_TCPSocket_SSLHandshake,
+ OnMsgSSLHandshake)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_TCPSocket_Read, OnMsgRead)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_TCPSocket_Write, OnMsgWrite)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_TCPSocket_Listen,
+ OnMsgListen)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_TCPSocket_Accept,
+ OnMsgAccept)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_TCPSocket_Close,
+ OnMsgClose)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_TCPSocket_SetOption,
+ OnMsgSetOption)
+ PPAPI_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
int32_t PepperTCPSocketMessageFilter::OnMsgBind(
const ppapi::host::HostMessageContext* context,
const PP_NetAddress_Private& net_addr) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
// This is only supported by PPB_TCPSocket v1.1 or above.
if (version_ != ppapi::TCP_SOCKET_VERSION_1_1_OR_ABOVE) {
@@ -179,18 +174,22 @@ int32_t PepperTCPSocketMessageFilter::OnMsgBind(
return PP_ERROR_NOACCESS;
}
- if (!pepper_socket_utils::CanUseSocketAPIs(
- external_plugin_, false /* private_api */, NULL, render_process_id_,
- render_view_id_)) {
+ if (!pepper_socket_utils::CanUseSocketAPIs(external_plugin_,
+ false /* private_api */,
+ NULL,
+ render_process_id_,
+ render_frame_id_)) {
return PP_ERROR_NOACCESS;
}
bind_input_addr_ = net_addr;
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&PepperTCPSocketMessageFilter::DoBind, this,
- context->MakeReplyMessageContext(), net_addr));
+ BrowserThread::PostTask(BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&PepperTCPSocketMessageFilter::DoBind,
+ this,
+ context->MakeReplyMessageContext(),
+ net_addr));
return PP_OK_COMPLETIONPENDING;
}
@@ -198,7 +197,7 @@ int32_t PepperTCPSocketMessageFilter::OnMsgConnect(
const ppapi::host::HostMessageContext* context,
const std::string& host,
uint16_t port) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
// This is only supported by PPB_TCPSocket_Private.
if (!IsPrivateAPI()) {
@@ -206,12 +205,13 @@ int32_t PepperTCPSocketMessageFilter::OnMsgConnect(
return PP_ERROR_NOACCESS;
}
- SocketPermissionRequest request(SocketPermissionRequest::TCP_CONNECT,
- host,
- port);
- if (!pepper_socket_utils::CanUseSocketAPIs(
- external_plugin_, true /* private_api */, &request,
- render_process_id_, render_view_id_)) {
+ SocketPermissionRequest request(
+ SocketPermissionRequest::TCP_CONNECT, host, port);
+ if (!pepper_socket_utils::CanUseSocketAPIs(external_plugin_,
+ true /* private_api */,
+ &request,
+ render_process_id_,
+ render_frame_id_)) {
return PP_ERROR_NOACCESS;
}
@@ -223,32 +223,40 @@ int32_t PepperTCPSocketMessageFilter::OnMsgConnect(
if (!browser_context || !browser_context->GetResourceContext())
return PP_ERROR_FAILED;
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&PepperTCPSocketMessageFilter::DoConnect, this,
- context->MakeReplyMessageContext(),
- host, port, browser_context->GetResourceContext()));
+ BrowserThread::PostTask(BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&PepperTCPSocketMessageFilter::DoConnect,
+ this,
+ context->MakeReplyMessageContext(),
+ host,
+ port,
+ browser_context->GetResourceContext()));
return PP_OK_COMPLETIONPENDING;
}
int32_t PepperTCPSocketMessageFilter::OnMsgConnectWithNetAddress(
const ppapi::host::HostMessageContext* context,
const PP_NetAddress_Private& net_addr) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
content::SocketPermissionRequest request =
pepper_socket_utils::CreateSocketPermissionRequest(
content::SocketPermissionRequest::TCP_CONNECT, net_addr);
- if (!pepper_socket_utils::CanUseSocketAPIs(external_plugin_, IsPrivateAPI(),
- &request, render_process_id_,
- render_view_id_)) {
+ if (!pepper_socket_utils::CanUseSocketAPIs(external_plugin_,
+ IsPrivateAPI(),
+ &request,
+ render_process_id_,
+ render_frame_id_)) {
return PP_ERROR_NOACCESS;
}
BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&PepperTCPSocketMessageFilter::DoConnectWithNetAddress, this,
- context->MakeReplyMessageContext(), net_addr));
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&PepperTCPSocketMessageFilter::DoConnectWithNetAddress,
+ this,
+ context->MakeReplyMessageContext(),
+ net_addr));
return PP_OK_COMPLETIONPENDING;
}
@@ -258,7 +266,7 @@ int32_t PepperTCPSocketMessageFilter::OnMsgSSLHandshake(
uint16_t server_port,
const std::vector<std::vector<char> >& trusted_certs,
const std::vector<std::vector<char> >& untrusted_certs) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
// Allow to do SSL handshake only if currently the socket has been connected
// and there isn't pending read or write.
@@ -282,9 +290,11 @@ int32_t PepperTCPSocketMessageFilter::OnMsgSSLHandshake(
ssl_context.cert_verifier = ssl_context_helper_->GetCertVerifier();
ssl_context.transport_security_state =
ssl_context_helper_->GetTransportSecurityState();
- ssl_socket_ = factory->CreateSSLClientSocket(
- handle.Pass(), host_port_pair, ssl_context_helper_->ssl_config(),
- ssl_context);
+ ssl_socket_ =
+ factory->CreateSSLClientSocket(handle.Pass(),
+ host_port_pair,
+ ssl_context_helper_->ssl_config(),
+ ssl_context);
if (!ssl_socket_) {
LOG(WARNING) << "Failed to create an SSL client socket.";
state_.CompletePendingTransition(false);
@@ -297,7 +307,8 @@ int32_t PepperTCPSocketMessageFilter::OnMsgSSLHandshake(
context->MakeReplyMessageContext());
int net_result = ssl_socket_->Connect(
base::Bind(&PepperTCPSocketMessageFilter::OnSSLHandshakeCompleted,
- base::Unretained(this), reply_context));
+ base::Unretained(this),
+ reply_context));
if (net_result != net::ERR_IO_PENDING)
OnSSLHandshakeCompleted(reply_context, net_result);
return PP_OK_COMPLETIONPENDING;
@@ -306,7 +317,7 @@ int32_t PepperTCPSocketMessageFilter::OnMsgSSLHandshake(
int32_t PepperTCPSocketMessageFilter::OnMsgRead(
const ppapi::host::HostMessageContext* context,
int32_t bytes_to_read) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!state_.IsConnected() || end_of_file_reached_)
return PP_ERROR_FAILED;
if (read_buffer_.get())
@@ -323,18 +334,20 @@ int32_t PepperTCPSocketMessageFilter::OnMsgRead(
int net_result = net::ERR_FAILED;
if (socket_) {
DCHECK_EQ(state_.state(), TCPSocketState::CONNECTED);
- net_result = socket_->Read(
- read_buffer_.get(),
- bytes_to_read,
- base::Bind(&PepperTCPSocketMessageFilter::OnReadCompleted,
- base::Unretained(this), reply_context));
+ net_result =
+ socket_->Read(read_buffer_.get(),
+ bytes_to_read,
+ base::Bind(&PepperTCPSocketMessageFilter::OnReadCompleted,
+ base::Unretained(this),
+ reply_context));
} else if (ssl_socket_) {
DCHECK_EQ(state_.state(), TCPSocketState::SSL_CONNECTED);
net_result = ssl_socket_->Read(
read_buffer_.get(),
bytes_to_read,
base::Bind(&PepperTCPSocketMessageFilter::OnReadCompleted,
- base::Unretained(this), reply_context));
+ base::Unretained(this),
+ reply_context));
}
if (net_result != net::ERR_IO_PENDING)
OnReadCompleted(reply_context, net_result);
@@ -344,7 +357,7 @@ int32_t PepperTCPSocketMessageFilter::OnMsgRead(
int32_t PepperTCPSocketMessageFilter::OnMsgWrite(
const ppapi::host::HostMessageContext* context,
const std::string& data) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!state_.IsConnected())
return PP_ERROR_FAILED;
@@ -368,7 +381,7 @@ int32_t PepperTCPSocketMessageFilter::OnMsgWrite(
int32_t PepperTCPSocketMessageFilter::OnMsgListen(
const ppapi::host::HostMessageContext* context,
int32_t backlog) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
// This is only supported by PPB_TCPSocket v1.1 or above.
if (version_ != ppapi::TCP_SOCKET_VERSION_1_1_OR_ABOVE) {
@@ -379,22 +392,26 @@ int32_t PepperTCPSocketMessageFilter::OnMsgListen(
content::SocketPermissionRequest request =
pepper_socket_utils::CreateSocketPermissionRequest(
content::SocketPermissionRequest::TCP_LISTEN, bind_input_addr_);
- if (!pepper_socket_utils::CanUseSocketAPIs(
- external_plugin_, false /* private_api */, &request,
- render_process_id_, render_view_id_)) {
+ if (!pepper_socket_utils::CanUseSocketAPIs(external_plugin_,
+ false /* private_api */,
+ &request,
+ render_process_id_,
+ render_frame_id_)) {
return PP_ERROR_NOACCESS;
}
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&PepperTCPSocketMessageFilter::DoListen, this,
- context->MakeReplyMessageContext(), backlog));
+ BrowserThread::PostTask(BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&PepperTCPSocketMessageFilter::DoListen,
+ this,
+ context->MakeReplyMessageContext(),
+ backlog));
return PP_OK_COMPLETIONPENDING;
}
int32_t PepperTCPSocketMessageFilter::OnMsgAccept(
const ppapi::host::HostMessageContext* context) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (pending_accept_)
return PP_ERROR_INPROGRESS;
@@ -408,7 +425,8 @@ int32_t PepperTCPSocketMessageFilter::OnMsgAccept(
&accepted_socket_,
&accepted_address_,
base::Bind(&PepperTCPSocketMessageFilter::OnAcceptCompleted,
- base::Unretained(this), reply_context));
+ base::Unretained(this),
+ reply_context));
if (net_result != net::ERR_IO_PENDING)
OnAcceptCompleted(reply_context, net_result);
return PP_OK_COMPLETIONPENDING;
@@ -416,7 +434,7 @@ int32_t PepperTCPSocketMessageFilter::OnMsgAccept(
int32_t PepperTCPSocketMessageFilter::OnMsgClose(
const ppapi::host::HostMessageContext* context) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (state_.state() == TCPSocketState::CLOSED)
return PP_OK;
@@ -434,7 +452,7 @@ int32_t PepperTCPSocketMessageFilter::OnMsgSetOption(
const ppapi::host::HostMessageContext* context,
PP_TCPSocket_Option name,
const ppapi::SocketOptionData& value) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
switch (name) {
case PP_TCPSOCKET_OPTION_NO_DELAY: {
@@ -455,17 +473,18 @@ int32_t PepperTCPSocketMessageFilter::OnMsgSetOption(
if (!value.GetInt32(&integer_value) || integer_value <= 0)
return PP_ERROR_BADARGUMENT;
- bool result = false;
+ int net_result = net::ERR_UNEXPECTED;
if (name == PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE) {
if (integer_value > TCPSocketResourceBase::kMaxSendBufferSize)
return PP_ERROR_BADARGUMENT;
- result = socket_->SetSendBufferSize(integer_value);
+ net_result = socket_->SetSendBufferSize(integer_value);
} else {
if (integer_value > TCPSocketResourceBase::kMaxReceiveBufferSize)
return PP_ERROR_BADARGUMENT;
- result = socket_->SetReceiveBufferSize(integer_value);
+ net_result = socket_->SetReceiveBufferSize(integer_value);
}
- return result ? PP_OK : PP_ERROR_FAILED;
+ // TODO(wtc): Add error mapping code.
+ return (net_result == net::OK) ? PP_OK : PP_ERROR_FAILED;
}
default: {
NOTREACHED();
@@ -477,7 +496,7 @@ int32_t PepperTCPSocketMessageFilter::OnMsgSetOption(
void PepperTCPSocketMessageFilter::DoBind(
const ppapi::host::ReplyMessageContext& context,
const PP_NetAddress_Private& net_addr) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (state_.IsPending(TCPSocketState::BIND)) {
SendBindError(context, PP_ERROR_INPROGRESS);
@@ -492,8 +511,8 @@ void PepperTCPSocketMessageFilter::DoBind(
do {
net::IPAddressNumber address;
int port;
- if (!NetAddressPrivateImpl::NetAddressToIPEndPoint(net_addr, &address,
- &port)) {
+ if (!NetAddressPrivateImpl::NetAddressToIPEndPoint(
+ net_addr, &address, &port)) {
pp_result = PP_ERROR_ADDRESS_INVALID;
break;
}
@@ -513,8 +532,8 @@ void PepperTCPSocketMessageFilter::DoBind(
break;
net::IPEndPoint ip_end_point_local;
- pp_result = NetErrorToPepperError(
- socket_->GetLocalAddress(&ip_end_point_local));
+ pp_result =
+ NetErrorToPepperError(socket_->GetLocalAddress(&ip_end_point_local));
if (pp_result != PP_OK)
break;
@@ -543,7 +562,7 @@ void PepperTCPSocketMessageFilter::DoConnect(
const std::string& host,
uint16_t port,
ResourceContext* resource_context) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!state_.IsValidTransition(TCPSocketState::CONNECT)) {
SendConnectError(context, PP_ERROR_FAILED);
@@ -554,14 +573,15 @@ void PepperTCPSocketMessageFilter::DoConnect(
address_index_ = 0;
address_list_.clear();
net::HostResolver::RequestInfo request_info(net::HostPortPair(host, port));
- resolver_.reset(new net::SingleRequestHostResolver(
- resource_context->GetHostResolver()));
+ resolver_.reset(
+ new net::SingleRequestHostResolver(resource_context->GetHostResolver()));
int net_result = resolver_->Resolve(
request_info,
net::DEFAULT_PRIORITY,
&address_list_,
base::Bind(&PepperTCPSocketMessageFilter::OnResolveCompleted,
- base::Unretained(this), context),
+ base::Unretained(this),
+ context),
net::BoundNetLog());
if (net_result != net::ERR_IO_PENDING)
OnResolveCompleted(context, net_result);
@@ -570,7 +590,7 @@ void PepperTCPSocketMessageFilter::DoConnect(
void PepperTCPSocketMessageFilter::DoConnectWithNetAddress(
const ppapi::host::ReplyMessageContext& context,
const PP_NetAddress_Private& net_addr) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!state_.IsValidTransition(TCPSocketState::CONNECT)) {
SendConnectError(context, PP_ERROR_FAILED);
@@ -581,8 +601,8 @@ void PepperTCPSocketMessageFilter::DoConnectWithNetAddress(
net::IPAddressNumber address;
int port;
- if (!NetAddressPrivateImpl::NetAddressToIPEndPoint(net_addr, &address,
- &port)) {
+ if (!NetAddressPrivateImpl::NetAddressToIPEndPoint(
+ net_addr, &address, &port)) {
state_.CompletePendingTransition(false);
SendConnectError(context, PP_ERROR_ADDRESS_INVALID);
return;
@@ -597,7 +617,7 @@ void PepperTCPSocketMessageFilter::DoConnectWithNetAddress(
void PepperTCPSocketMessageFilter::DoWrite(
const ppapi::host::ReplyMessageContext& context) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(write_buffer_base_.get());
DCHECK(write_buffer_.get());
DCHECK_GT(write_buffer_->BytesRemaining(), 0);
@@ -610,14 +630,16 @@ void PepperTCPSocketMessageFilter::DoWrite(
write_buffer_.get(),
write_buffer_->BytesRemaining(),
base::Bind(&PepperTCPSocketMessageFilter::OnWriteCompleted,
- base::Unretained(this), context));
+ base::Unretained(this),
+ context));
} else if (ssl_socket_) {
DCHECK_EQ(state_.state(), TCPSocketState::SSL_CONNECTED);
net_result = ssl_socket_->Write(
write_buffer_.get(),
write_buffer_->BytesRemaining(),
base::Bind(&PepperTCPSocketMessageFilter::OnWriteCompleted,
- base::Unretained(this), context));
+ base::Unretained(this),
+ context));
}
if (net_result != net::ERR_IO_PENDING)
OnWriteCompleted(context, net_result);
@@ -626,7 +648,7 @@ void PepperTCPSocketMessageFilter::DoWrite(
void PepperTCPSocketMessageFilter::DoListen(
const ppapi::host::ReplyMessageContext& context,
int32_t backlog) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (state_.IsPending(TCPSocketState::LISTEN)) {
SendListenReply(context, PP_ERROR_INPROGRESS);
@@ -645,7 +667,7 @@ void PepperTCPSocketMessageFilter::DoListen(
void PepperTCPSocketMessageFilter::OnResolveCompleted(
const ppapi::host::ReplyMessageContext& context,
int net_result) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!state_.IsPending(TCPSocketState::CONNECT)) {
DCHECK(state_.state() == TCPSocketState::CLOSED);
@@ -664,7 +686,7 @@ void PepperTCPSocketMessageFilter::OnResolveCompleted(
void PepperTCPSocketMessageFilter::StartConnect(
const ppapi::host::ReplyMessageContext& context) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(state_.IsPending(TCPSocketState::CONNECT));
DCHECK_LT(address_index_, address_list_.size());
@@ -676,7 +698,8 @@ void PepperTCPSocketMessageFilter::StartConnect(
net_result = socket_->Connect(
address_list_[address_index_],
base::Bind(&PepperTCPSocketMessageFilter::OnConnectCompleted,
- base::Unretained(this), context));
+ base::Unretained(this),
+ context));
}
if (net_result != net::ERR_IO_PENDING)
OnConnectCompleted(context, net_result);
@@ -685,7 +708,7 @@ void PepperTCPSocketMessageFilter::StartConnect(
void PepperTCPSocketMessageFilter::OnConnectCompleted(
const ppapi::host::ReplyMessageContext& context,
int net_result) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!state_.IsPending(TCPSocketState::CONNECT)) {
DCHECK(state_.state() == TCPSocketState::CLOSED);
@@ -700,12 +723,12 @@ void PepperTCPSocketMessageFilter::OnConnectCompleted(
net::IPEndPoint ip_end_point_local;
net::IPEndPoint ip_end_point_remote;
- pp_result = NetErrorToPepperError(
- socket_->GetLocalAddress(&ip_end_point_local));
+ pp_result =
+ NetErrorToPepperError(socket_->GetLocalAddress(&ip_end_point_local));
if (pp_result != PP_OK)
break;
- pp_result = NetErrorToPepperError(
- socket_->GetPeerAddress(&ip_end_point_remote));
+ pp_result =
+ NetErrorToPepperError(socket_->GetPeerAddress(&ip_end_point_remote));
if (pp_result != PP_OK)
break;
@@ -758,7 +781,7 @@ void PepperTCPSocketMessageFilter::OnConnectCompleted(
void PepperTCPSocketMessageFilter::OnSSLHandshakeCompleted(
const ppapi::host::ReplyMessageContext& context,
int net_result) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!state_.IsPending(TCPSocketState::SSL_CONNECT)) {
DCHECK(state_.state() == TCPSocketState::CLOSED);
@@ -773,13 +796,12 @@ void PepperTCPSocketMessageFilter::OnSSLHandshakeCompleted(
void PepperTCPSocketMessageFilter::OnReadCompleted(
const ppapi::host::ReplyMessageContext& context,
int net_result) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(read_buffer_.get());
if (net_result > 0) {
- SendReadReply(context,
- PP_OK,
- std::string(read_buffer_->data(), net_result));
+ SendReadReply(
+ context, PP_OK, std::string(read_buffer_->data(), net_result));
} else if (net_result == 0) {
end_of_file_reached_ = true;
SendReadReply(context, PP_OK, std::string());
@@ -792,7 +814,7 @@ void PepperTCPSocketMessageFilter::OnReadCompleted(
void PepperTCPSocketMessageFilter::OnWriteCompleted(
const ppapi::host::ReplyMessageContext& context,
int net_result) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(write_buffer_base_.get());
DCHECK(write_buffer_.get());
@@ -818,7 +840,7 @@ void PepperTCPSocketMessageFilter::OnWriteCompleted(
void PepperTCPSocketMessageFilter::OnAcceptCompleted(
const ppapi::host::ReplyMessageContext& context,
int net_result) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(pending_accept_);
pending_accept_ = false;
@@ -834,9 +856,8 @@ void PepperTCPSocketMessageFilter::OnAcceptCompleted(
PP_NetAddress_Private local_addr = NetAddressPrivateImpl::kInvalidNetAddress;
PP_NetAddress_Private remote_addr = NetAddressPrivateImpl::kInvalidNetAddress;
- int32_t pp_result =
- NetErrorToPepperError(accepted_socket_->GetLocalAddress(
- &ip_end_point_local));
+ int32_t pp_result = NetErrorToPepperError(
+ accepted_socket_->GetLocalAddress(&ip_end_point_local));
if (pp_result != PP_OK) {
SendAcceptError(context, pp_result);
return;
@@ -971,7 +992,9 @@ void PepperTCPSocketMessageFilter::SendAcceptReply(
void PepperTCPSocketMessageFilter::SendAcceptError(
const ppapi::host::ReplyMessageContext& context,
int32_t pp_error) {
- SendAcceptReply(context, pp_error, 0,
+ SendAcceptReply(context,
+ pp_error,
+ 0,
NetAddressPrivateImpl::kInvalidNetAddress,
NetAddressPrivateImpl::kInvalidNetAddress);
}
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.h b/chromium/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.h
index fb34b988d3c..5c4e066b360 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.h
+++ b/chromium/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.h
@@ -49,18 +49,16 @@ class ResourceContext;
class CONTENT_EXPORT PepperTCPSocketMessageFilter
: public ppapi::host::ResourceMessageFilter {
public:
- PepperTCPSocketMessageFilter(
- ContentBrowserPepperHostFactory* factory,
- BrowserPpapiHostImpl* host,
- PP_Instance instance,
- ppapi::TCPSocketVersion version);
+ PepperTCPSocketMessageFilter(ContentBrowserPepperHostFactory* factory,
+ BrowserPpapiHostImpl* host,
+ PP_Instance instance,
+ ppapi::TCPSocketVersion version);
// Used for creating already connected sockets.
- PepperTCPSocketMessageFilter(
- BrowserPpapiHostImpl* host,
- PP_Instance instance,
- ppapi::TCPSocketVersion version,
- scoped_ptr<net::TCPSocket> socket);
+ PepperTCPSocketMessageFilter(BrowserPpapiHostImpl* host,
+ PP_Instance instance,
+ ppapi::TCPSocketVersion version,
+ scoped_ptr<net::TCPSocket> socket);
static size_t GetNumInstances();
@@ -106,9 +104,8 @@ class CONTENT_EXPORT PepperTCPSocketMessageFilter
const std::string& host,
uint16_t port,
ResourceContext* resource_context);
- void DoConnectWithNetAddress(
- const ppapi::host::ReplyMessageContext& context,
- const PP_NetAddress_Private& net_addr);
+ void DoConnectWithNetAddress(const ppapi::host::ReplyMessageContext& context,
+ const PP_NetAddress_Private& net_addr);
void DoWrite(const ppapi::host::ReplyMessageContext& context);
void DoListen(const ppapi::host::ReplyMessageContext& context,
int32_t backlog);
@@ -169,7 +166,7 @@ class CONTENT_EXPORT PepperTCPSocketMessageFilter
const bool external_plugin_;
int render_process_id_;
- int render_view_id_;
+ int render_frame_id_;
// The following fields are used only on the IO thread.
// Non-owning ptr.
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc b/chromium/content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc
index ceeb73e3df1..7479046cfe7 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc
@@ -6,7 +6,7 @@
#include <algorithm>
-#include "base/safe_numerics.h"
+#include "base/numerics/safe_conversions.h"
#include "base/threading/sequenced_worker_pool.h"
#include "content/browser/renderer_host/pepper/pepper_truetype_font_list.h"
#include "content/common/font_list.h"
@@ -44,11 +44,9 @@ class FontMessageFilter : public ppapi::host::ResourceMessageFilter {
DISALLOW_COPY_AND_ASSIGN(FontMessageFilter);
};
-FontMessageFilter::FontMessageFilter() {
-}
+FontMessageFilter::FontMessageFilter() {}
-FontMessageFilter::~FontMessageFilter() {
-}
+FontMessageFilter::~FontMessageFilter() {}
scoped_refptr<base::TaskRunner> FontMessageFilter::OverrideTaskRunnerForMessage(
const IPC::Message& msg) {
@@ -63,14 +61,14 @@ scoped_refptr<base::TaskRunner> FontMessageFilter::OverrideTaskRunnerForMessage(
int32_t FontMessageFilter::OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) {
- IPC_BEGIN_MESSAGE_MAP(FontMessageFilter, msg)
+ PPAPI_BEGIN_MESSAGE_MAP(FontMessageFilter, msg)
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
PpapiHostMsg_TrueTypeFontSingleton_GetFontFamilies,
OnHostMsgGetFontFamilies)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(
PpapiHostMsg_TrueTypeFontSingleton_GetFontsInFamily,
OnHostMsgGetFontsInFamily)
- IPC_END_MESSAGE_MAP()
+ PPAPI_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
@@ -84,7 +82,7 @@ int32_t FontMessageFilter::OnHostMsgGetFontFamilies(
context->reply_msg =
PpapiPluginMsg_TrueTypeFontSingleton_GetFontFamiliesReply(font_families);
- return base::checked_numeric_cast<int32_t>(font_families.size());
+ return base::checked_cast<int32_t>(font_families.size());
}
int32_t FontMessageFilter::OnHostMsgGetFontsInFamily(
@@ -97,21 +95,19 @@ int32_t FontMessageFilter::OnHostMsgGetFontsInFamily(
context->reply_msg =
PpapiPluginMsg_TrueTypeFontSingleton_GetFontsInFamilyReply(
fonts_in_family);
- return base::checked_numeric_cast<int32_t>(fonts_in_family.size());
+ return base::checked_cast<int32_t>(fonts_in_family.size());
}
} // namespace
-PepperTrueTypeFontListHost::PepperTrueTypeFontListHost(
- BrowserPpapiHost* host,
- PP_Instance instance,
- PP_Resource resource)
+PepperTrueTypeFontListHost::PepperTrueTypeFontListHost(BrowserPpapiHost* host,
+ PP_Instance instance,
+ PP_Resource resource)
: ResourceHost(host->GetPpapiHost(), instance, resource) {
AddFilter(scoped_refptr<ppapi::host::ResourceMessageFilter>(
new FontMessageFilter()));
}
-PepperTrueTypeFontListHost::~PepperTrueTypeFontListHost() {
-}
+PepperTrueTypeFontListHost::~PepperTrueTypeFontListHost() {}
} // namespace content
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_truetype_font_list_win.cc b/chromium/content/browser/renderer_host/pepper/pepper_truetype_font_list_win.cc
index 3530e1e1b5e..8e275904081 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_truetype_font_list_win.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_truetype_font_list_win.cc
@@ -27,7 +27,7 @@ static int CALLBACK EnumFontFamiliesProc(ENUMLOGFONTEXW* logical_font,
const LOGFONTW& lf = logical_font->elfLogFont;
if (lf.lfFaceName[0] && lf.lfFaceName[0] != '@' &&
lf.lfOutPrecision == OUT_STROKE_PRECIS) { // Outline fonts only.
- std::string face_name(UTF16ToUTF8(lf.lfFaceName));
+ std::string face_name(base::UTF16ToUTF8(lf.lfFaceName));
font_families->push_back(face_name);
}
}
@@ -44,13 +44,12 @@ static int CALLBACK EnumFontsInFamilyProc(ENUMLOGFONTEXW* logical_font,
if (lf.lfFaceName[0] && lf.lfFaceName[0] != '@' &&
lf.lfOutPrecision == OUT_STROKE_PRECIS) { // Outline fonts only.
ppapi::proxy::SerializedTrueTypeFontDesc desc;
- desc.family = UTF16ToUTF8(lf.lfFaceName);
+ desc.family = base::UTF16ToUTF8(lf.lfFaceName);
if (lf.lfItalic)
desc.style = PP_TRUETYPEFONTSTYLE_ITALIC;
desc.weight = static_cast<PP_TrueTypeFontWeight_Dev>(lf.lfWeight);
desc.width = PP_TRUETYPEFONTWIDTH_NORMAL; // TODO(bbudge) support widths.
- desc.charset =
- static_cast<PP_TrueTypeFontCharset_Dev>(lf.lfCharSet);
+ desc.charset = static_cast<PP_TrueTypeFontCharset_Dev>(lf.lfCharSet);
fonts_in_family->push_back(desc);
}
}
@@ -64,8 +63,11 @@ void GetFontFamilies_SlowBlocking(FontFamilyList* font_families) {
memset(&logfont, 0, sizeof(logfont));
logfont.lfCharSet = DEFAULT_CHARSET;
base::win::ScopedCreateDC hdc(::CreateCompatibleDC(NULL));
- ::EnumFontFamiliesExW(hdc, &logfont, (FONTENUMPROCW)&EnumFontFamiliesProc,
- (LPARAM)font_families, 0);
+ ::EnumFontFamiliesExW(hdc,
+ &logfont,
+ (FONTENUMPROCW) & EnumFontFamiliesProc,
+ (LPARAM)font_families,
+ 0);
}
void GetFontsInFamily_SlowBlocking(const std::string& family,
@@ -73,11 +75,14 @@ void GetFontsInFamily_SlowBlocking(const std::string& family,
LOGFONTW logfont;
memset(&logfont, 0, sizeof(logfont));
logfont.lfCharSet = DEFAULT_CHARSET;
- base::string16 family16 = UTF8ToUTF16(family);
+ base::string16 family16 = base::UTF8ToUTF16(family);
memcpy(&logfont.lfFaceName, &family16[0], sizeof(logfont.lfFaceName));
base::win::ScopedCreateDC hdc(::CreateCompatibleDC(NULL));
- ::EnumFontFamiliesExW(hdc, &logfont, (FONTENUMPROCW)&EnumFontsInFamilyProc,
- (LPARAM)fonts_in_family, 0);
+ ::EnumFontFamiliesExW(hdc,
+ &logfont,
+ (FONTENUMPROCW) & EnumFontsInFamilyProc,
+ (LPARAM)fonts_in_family,
+ 0);
}
} // namespace content
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.cc b/chromium/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.cc
index 3127ed278fd..a4ed3dca46e 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.cc
+++ b/chromium/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.cc
@@ -49,13 +49,12 @@ PepperUDPSocketMessageFilter::PepperUDPSocketMessageFilter(
external_plugin_(host->external_plugin()),
private_api_(private_api),
render_process_id_(0),
- render_view_id_(0) {
+ render_frame_id_(0) {
++g_num_instances;
DCHECK(host);
- if (!host->GetRenderViewIDsForInstance(instance,
- &render_process_id_,
- &render_view_id_)) {
+ if (!host->GetRenderFrameIDsForInstance(
+ instance, &render_process_id_, &render_frame_id_)) {
NOTREACHED();
}
}
@@ -88,18 +87,17 @@ PepperUDPSocketMessageFilter::OverrideTaskRunnerForMessage(
int32_t PepperUDPSocketMessageFilter::OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) {
- IPC_BEGIN_MESSAGE_MAP(PepperUDPSocketMessageFilter, msg)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(
- PpapiHostMsg_UDPSocket_SetOption, OnMsgSetOption)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(
- PpapiHostMsg_UDPSocket_Bind, OnMsgBind)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(
- PpapiHostMsg_UDPSocket_RecvFrom, OnMsgRecvFrom)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL(
- PpapiHostMsg_UDPSocket_SendTo, OnMsgSendTo)
- PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
- PpapiHostMsg_UDPSocket_Close, OnMsgClose)
- IPC_END_MESSAGE_MAP()
+ PPAPI_BEGIN_MESSAGE_MAP(PepperUDPSocketMessageFilter, msg)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UDPSocket_SetOption,
+ OnMsgSetOption)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UDPSocket_Bind, OnMsgBind)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UDPSocket_RecvFrom,
+ OnMsgRecvFrom)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UDPSocket_SendTo,
+ OnMsgSendTo)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_UDPSocket_Close,
+ OnMsgClose)
+ PPAPI_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}
@@ -107,7 +105,7 @@ int32_t PepperUDPSocketMessageFilter::OnMsgSetOption(
const ppapi::host::HostMessageContext* context,
PP_UDPSocket_Option name,
const ppapi::SocketOptionData& value) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (closed_)
return PP_ERROR_FAILED;
@@ -140,21 +138,22 @@ int32_t PepperUDPSocketMessageFilter::OnMsgSetOption(
if (!value.GetInt32(&integer_value) || integer_value <= 0)
return PP_ERROR_BADARGUMENT;
- bool result = false;
+ int net_result = net::ERR_UNEXPECTED;
if (name == PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE) {
if (integer_value >
- ppapi::proxy::UDPSocketResourceBase::kMaxSendBufferSize) {
+ ppapi::proxy::UDPSocketResourceBase::kMaxSendBufferSize) {
return PP_ERROR_BADARGUMENT;
}
- result = socket_->SetSendBufferSize(integer_value);
+ net_result = socket_->SetSendBufferSize(integer_value);
} else {
if (integer_value >
- ppapi::proxy::UDPSocketResourceBase::kMaxReceiveBufferSize) {
+ ppapi::proxy::UDPSocketResourceBase::kMaxReceiveBufferSize) {
return PP_ERROR_BADARGUMENT;
}
- result = socket_->SetReceiveBufferSize(integer_value);
+ net_result = socket_->SetReceiveBufferSize(integer_value);
}
- return result ? PP_OK : PP_ERROR_FAILED;
+ // TODO(wtc): Add error mapping code.
+ return (net_result == net::OK) ? PP_OK : PP_ERROR_FAILED;
}
default: {
NOTREACHED();
@@ -166,30 +165,33 @@ int32_t PepperUDPSocketMessageFilter::OnMsgSetOption(
int32_t PepperUDPSocketMessageFilter::OnMsgBind(
const ppapi::host::HostMessageContext* context,
const PP_NetAddress_Private& addr) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(context);
SocketPermissionRequest request =
pepper_socket_utils::CreateSocketPermissionRequest(
SocketPermissionRequest::UDP_BIND, addr);
- if (!pepper_socket_utils::CanUseSocketAPIs(external_plugin_, private_api_,
- &request, render_process_id_,
- render_view_id_)) {
+ if (!pepper_socket_utils::CanUseSocketAPIs(external_plugin_,
+ private_api_,
+ &request,
+ render_process_id_,
+ render_frame_id_)) {
return PP_ERROR_NOACCESS;
}
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&PepperUDPSocketMessageFilter::DoBind, this,
- context->MakeReplyMessageContext(),
- addr));
+ BrowserThread::PostTask(BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&PepperUDPSocketMessageFilter::DoBind,
+ this,
+ context->MakeReplyMessageContext(),
+ addr));
return PP_OK_COMPLETIONPENDING;
}
int32_t PepperUDPSocketMessageFilter::OnMsgRecvFrom(
const ppapi::host::HostMessageContext* context,
int32_t num_bytes) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(context);
DCHECK(socket_.get());
@@ -229,28 +231,33 @@ int32_t PepperUDPSocketMessageFilter::OnMsgSendTo(
const ppapi::host::HostMessageContext* context,
const std::string& data,
const PP_NetAddress_Private& addr) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(context);
SocketPermissionRequest request =
pepper_socket_utils::CreateSocketPermissionRequest(
SocketPermissionRequest::UDP_SEND_TO, addr);
- if (!pepper_socket_utils::CanUseSocketAPIs(external_plugin_, private_api_,
- &request, render_process_id_,
- render_view_id_)) {
+ if (!pepper_socket_utils::CanUseSocketAPIs(external_plugin_,
+ private_api_,
+ &request,
+ render_process_id_,
+ render_frame_id_)) {
return PP_ERROR_NOACCESS;
}
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&PepperUDPSocketMessageFilter::DoSendTo, this,
- context->MakeReplyMessageContext(), data, addr));
+ BrowserThread::PostTask(BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&PepperUDPSocketMessageFilter::DoSendTo,
+ this,
+ context->MakeReplyMessageContext(),
+ data,
+ addr));
return PP_OK_COMPLETIONPENDING;
}
int32_t PepperUDPSocketMessageFilter::OnMsgClose(
const ppapi::host::HostMessageContext* context) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
Close();
return PP_OK;
}
@@ -258,15 +265,15 @@ int32_t PepperUDPSocketMessageFilter::OnMsgClose(
void PepperUDPSocketMessageFilter::DoBind(
const ppapi::host::ReplyMessageContext& context,
const PP_NetAddress_Private& addr) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (closed_ || socket_.get()) {
SendBindError(context, PP_ERROR_FAILED);
return;
}
- scoped_ptr<net::UDPServerSocket> socket(new net::UDPServerSocket(
- NULL, net::NetLog::Source()));
+ scoped_ptr<net::UDPServerSocket> socket(
+ new net::UDPServerSocket(NULL, net::NetLog::Source()));
net::IPAddressNumber address;
int port;
@@ -280,8 +287,8 @@ void PepperUDPSocketMessageFilter::DoBind(
if (allow_broadcast_)
socket->AllowBroadcast();
- int32_t pp_result = NetErrorToPepperError(
- socket->Listen(net::IPEndPoint(address, port)));
+ int32_t pp_result =
+ NetErrorToPepperError(socket->Listen(net::IPEndPoint(address, port)));
if (pp_result != PP_OK) {
SendBindError(context, pp_result);
return;
@@ -294,11 +301,9 @@ void PepperUDPSocketMessageFilter::DoBind(
return;
}
- PP_NetAddress_Private net_address =
- NetAddressPrivateImpl::kInvalidNetAddress;
- if (!NetAddressPrivateImpl::IPEndPointToNetAddress(bound_address.address(),
- bound_address.port(),
- &net_address)) {
+ PP_NetAddress_Private net_address = NetAddressPrivateImpl::kInvalidNetAddress;
+ if (!NetAddressPrivateImpl::IPEndPointToNetAddress(
+ bound_address.address(), bound_address.port(), &net_address)) {
SendBindError(context, PP_ERROR_ADDRESS_INVALID);
return;
}
@@ -313,7 +318,7 @@ void PepperUDPSocketMessageFilter::DoSendTo(
const ppapi::host::ReplyMessageContext& context,
const std::string& data,
const PP_NetAddress_Private& addr) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(socket_.get());
if (closed_ || !socket_.get()) {
@@ -329,7 +334,7 @@ void PepperUDPSocketMessageFilter::DoSendTo(
size_t num_bytes = data.size();
if (num_bytes == 0 ||
num_bytes > static_cast<size_t>(
- ppapi::proxy::UDPSocketResourceBase::kMaxWriteSize)) {
+ ppapi::proxy::UDPSocketResourceBase::kMaxWriteSize)) {
// Size of |data| is checked on the plugin side.
NOTREACHED();
SendSendToError(context, PP_ERROR_BADARGUMENT);
@@ -360,7 +365,7 @@ void PepperUDPSocketMessageFilter::DoSendTo(
}
void PepperUDPSocketMessageFilter::Close() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (socket_.get() && !closed_)
socket_->Close();
closed_ = true;
@@ -369,7 +374,7 @@ void PepperUDPSocketMessageFilter::Close() {
void PepperUDPSocketMessageFilter::OnRecvFromCompleted(
const ppapi::host::ReplyMessageContext& context,
int net_result) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(recvfrom_buffer_.get());
int32_t pp_result = NetErrorToPepperError(net_result);
@@ -384,8 +389,8 @@ void PepperUDPSocketMessageFilter::OnRecvFromCompleted(
}
if (pp_result >= 0) {
- SendRecvFromReply(context, PP_OK,
- std::string(recvfrom_buffer_->data(), pp_result), addr);
+ SendRecvFromReply(
+ context, PP_OK, std::string(recvfrom_buffer_->data(), pp_result), addr);
} else {
SendRecvFromError(context, pp_result);
}
@@ -396,7 +401,7 @@ void PepperUDPSocketMessageFilter::OnRecvFromCompleted(
void PepperUDPSocketMessageFilter::OnSendToCompleted(
const ppapi::host::ReplyMessageContext& context,
int net_result) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(sendto_buffer_.get());
int32_t pp_result = NetErrorToPepperError(net_result);
@@ -423,8 +428,7 @@ void PepperUDPSocketMessageFilter::SendRecvFromReply(
const PP_NetAddress_Private& addr) {
ppapi::host::ReplyMessageContext reply_context(context);
reply_context.params.set_result(result);
- SendReply(reply_context,
- PpapiPluginMsg_UDPSocket_RecvFromReply(data, addr));
+ SendReply(reply_context, PpapiPluginMsg_UDPSocket_RecvFromReply(data, addr));
}
void PepperUDPSocketMessageFilter::SendSendToReply(
@@ -433,8 +437,7 @@ void PepperUDPSocketMessageFilter::SendSendToReply(
int32_t bytes_written) {
ppapi::host::ReplyMessageContext reply_context(context);
reply_context.params.set_result(result);
- SendReply(reply_context,
- PpapiPluginMsg_UDPSocket_SendToReply(bytes_written));
+ SendReply(reply_context, PpapiPluginMsg_UDPSocket_SendToReply(bytes_written));
}
void PepperUDPSocketMessageFilter::SendBindError(
diff --git a/chromium/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.h b/chromium/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.h
index 2df4ceec63c..8ca7f0800bc 100644
--- a/chromium/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.h
+++ b/chromium/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.h
@@ -63,10 +63,9 @@ class CONTENT_EXPORT PepperUDPSocketMessageFilter
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) OVERRIDE;
- int32_t OnMsgSetOption(
- const ppapi::host::HostMessageContext* context,
- PP_UDPSocket_Option name,
- const ppapi::SocketOptionData& value);
+ int32_t OnMsgSetOption(const ppapi::host::HostMessageContext* context,
+ PP_UDPSocket_Option name,
+ const ppapi::SocketOptionData& value);
int32_t OnMsgBind(const ppapi::host::HostMessageContext* context,
const PP_NetAddress_Private& addr);
int32_t OnMsgRecvFrom(const ppapi::host::HostMessageContext* context,
@@ -121,7 +120,7 @@ class CONTENT_EXPORT PepperUDPSocketMessageFilter
bool private_api_;
int render_process_id_;
- int render_view_id_;
+ int render_frame_id_;
DISALLOW_COPY_AND_ASSIGN(PepperUDPSocketMessageFilter);
};
diff --git a/chromium/content/browser/renderer_host/pepper/quota_reservation.cc b/chromium/content/browser/renderer_host/pepper/quota_reservation.cc
index 221b374f110..85a404cac36 100644
--- a/chromium/content/browser/renderer_host/pepper/quota_reservation.cc
+++ b/chromium/content/browser/renderer_host/pepper/quota_reservation.cc
@@ -19,8 +19,8 @@ scoped_refptr<QuotaReservation> QuotaReservation::Create(
scoped_refptr<fileapi::FileSystemContext> file_system_context,
const GURL& origin_url,
fileapi::FileSystemType type) {
- return scoped_refptr<QuotaReservation>(new QuotaReservation(
- file_system_context, origin_url, type));
+ return scoped_refptr<QuotaReservation>(
+ new QuotaReservation(file_system_context, origin_url, type));
}
QuotaReservation::QuotaReservation(
@@ -30,8 +30,7 @@ QuotaReservation::QuotaReservation(
: file_system_context_(file_system_context) {
quota_reservation_ =
file_system_context->CreateQuotaReservationOnFileTaskRunner(
- origin_url,
- file_system_type);
+ origin_url, file_system_type);
}
// For unit testing only.
@@ -39,13 +38,12 @@ QuotaReservation::QuotaReservation(
scoped_refptr<fileapi::QuotaReservation> quota_reservation,
const GURL& /* origin_url */,
fileapi::FileSystemType /* file_system_type */)
- : quota_reservation_(quota_reservation) {
-}
+ : quota_reservation_(quota_reservation) {}
QuotaReservation::~QuotaReservation() {
// We should have no open files at this point.
DCHECK(files_.size() == 0);
- for (FileMap::iterator it = files_.begin(); it != files_.end(); ++ it)
+ for (FileMap::iterator it = files_.begin(); it != files_.end(); ++it)
delete it->second;
}
@@ -53,10 +51,10 @@ int64_t QuotaReservation::OpenFile(int32_t id,
const fileapi::FileSystemURL& url) {
base::FilePath platform_file_path;
if (file_system_context_) {
- base::PlatformFileError error =
+ base::File::Error error =
file_system_context_->operation_runner()->SyncGetPlatformPath(
url, &platform_file_path);
- if (error != base::PLATFORM_FILE_OK) {
+ if (error != base::File::FILE_OK) {
NOTREACHED();
return 0;
}
@@ -70,7 +68,7 @@ int64_t QuotaReservation::OpenFile(int32_t id,
std::pair<FileMap::iterator, bool> insert_result =
files_.insert(std::make_pair(id, file_handle.get()));
if (insert_result.second) {
- int64_t max_written_offset = file_handle->base_file_size();
+ int64_t max_written_offset = file_handle->GetMaxWrittenOffset();
ignore_result(file_handle.release());
return max_written_offset;
}
@@ -79,10 +77,11 @@ int64_t QuotaReservation::OpenFile(int32_t id,
}
void QuotaReservation::CloseFile(int32_t id,
- int64_t max_written_offset) {
+ const ppapi::FileGrowth& file_growth) {
FileMap::iterator it = files_.find(id);
if (it != files_.end()) {
- it->second->UpdateMaxWrittenOffset(max_written_offset);
+ it->second->UpdateMaxWrittenOffset(file_growth.max_written_offset);
+ it->second->AddAppendModeWriteAmount(file_growth.append_mode_write_amount);
delete it->second;
files_.erase(it);
} else {
@@ -90,54 +89,50 @@ void QuotaReservation::CloseFile(int32_t id,
}
}
-void QuotaReservation::ReserveQuota(
- int64_t amount,
- const OffsetMap& max_written_offsets,
- const ReserveQuotaCallback& callback) {
- for (FileMap::iterator it = files_.begin(); it != files_.end(); ++ it) {
- OffsetMap::const_iterator offset_it = max_written_offsets.find(it->first);
- if (offset_it != max_written_offsets.end())
- it->second->UpdateMaxWrittenOffset(offset_it->second);
- else
+void QuotaReservation::ReserveQuota(int64_t amount,
+ const ppapi::FileGrowthMap& file_growths,
+ const ReserveQuotaCallback& callback) {
+ for (FileMap::iterator it = files_.begin(); it != files_.end(); ++it) {
+ ppapi::FileGrowthMap::const_iterator growth_it =
+ file_growths.find(it->first);
+ if (growth_it != file_growths.end()) {
+ it->second->UpdateMaxWrittenOffset(growth_it->second.max_written_offset);
+ it->second->AddAppendModeWriteAmount(
+ growth_it->second.append_mode_write_amount);
+ } else {
NOTREACHED();
+ }
}
quota_reservation_->RefreshReservation(
- amount,
- base::Bind(&QuotaReservation::GotReservedQuota,
- this,
- callback));
+ amount, base::Bind(&QuotaReservation::GotReservedQuota, this, callback));
}
-void QuotaReservation::GotReservedQuota(
- const ReserveQuotaCallback& callback,
- base::PlatformFileError error) {
- OffsetMap max_written_offsets;
- for (FileMap::iterator it = files_.begin(); it != files_.end(); ++ it) {
- max_written_offsets.insert(
- std::make_pair(it->first, it->second->base_file_size()));
- }
+void QuotaReservation::OnClientCrash() { quota_reservation_->OnClientCrash(); }
+
+void QuotaReservation::GotReservedQuota(const ReserveQuotaCallback& callback,
+ base::File::Error error) {
+ ppapi::FileSizeMap file_sizes;
+ for (FileMap::iterator it = files_.begin(); it != files_.end(); ++it)
+ file_sizes[it->first] = it->second->GetMaxWrittenOffset();
if (file_system_context_) {
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
- base::Bind(callback,
- quota_reservation_->remaining_quota(),
- max_written_offsets));
+ base::Bind(
+ callback, quota_reservation_->remaining_quota(), file_sizes));
} else {
// Unit testing code path.
- callback.Run(quota_reservation_->remaining_quota(), max_written_offsets);
+ callback.Run(quota_reservation_->remaining_quota(), file_sizes);
}
}
void QuotaReservation::DeleteOnCorrectThread() const {
- if (file_system_context_ &&
- !file_system_context_->
- default_file_task_runner()->RunsTasksOnCurrentThread()) {
- file_system_context_->default_file_task_runner()->DeleteSoon(
- FROM_HERE,
- this);
+ if (file_system_context_ && !file_system_context_->default_file_task_runner()
+ ->RunsTasksOnCurrentThread()) {
+ file_system_context_->default_file_task_runner()->DeleteSoon(FROM_HERE,
+ this);
} else {
// We're on the right thread to delete, or unit test.
delete this;
diff --git a/chromium/content/browser/renderer_host/pepper/quota_reservation.h b/chromium/content/browser/renderer_host/pepper/quota_reservation.h
index 845b868d345..33490918f93 100644
--- a/chromium/content/browser/renderer_host/pepper/quota_reservation.h
+++ b/chromium/content/browser/renderer_host/pepper/quota_reservation.h
@@ -9,9 +9,9 @@
#include "base/basictypes.h"
#include "base/callback.h"
-#include "base/platform_file.h"
#include "content/common/content_export.h"
#include "ppapi/c/pp_stdint.h" // For int64_t on Windows.
+#include "ppapi/shared_impl/file_growth.h"
#include "url/gurl.h"
#include "webkit/browser/fileapi/file_system_context.h"
@@ -43,15 +43,20 @@ class CONTENT_EXPORT QuotaReservation
// Opens a file with the given id and path and returns its current size.
int64_t OpenFile(int32_t id, const fileapi::FileSystemURL& url);
// Closes the file opened by OpenFile with the given id.
- void CloseFile(int32_t id, int64_t max_written_offset);
+ void CloseFile(int32_t id, const ppapi::FileGrowth& file_growth);
// Refreshes the quota reservation to a new amount. A map that associates file
// ids with maximum written offsets is provided as input. The callback will
// receive a similar map with the updated file sizes.
- typedef std::map<int32_t, int64_t> OffsetMap;
- typedef base::Callback<void(int64_t, const OffsetMap&)> ReserveQuotaCallback;
+ typedef base::Callback<void(int64_t, const ppapi::FileSizeMap&)>
+ ReserveQuotaCallback;
void ReserveQuota(int64_t amount,
- const OffsetMap& max_written_offsets,
+ const ppapi::FileGrowthMap& file_growth,
const ReserveQuotaCallback& callback);
+
+ // Notifies underlying QuotaReservation that the associated client crashed,
+ // and that the reserved quota is no longer traceable.
+ void OnClientCrash();
+
private:
friend class base::RefCountedThreadSafe<QuotaReservation,
QuotaReservationDeleter>;
@@ -66,15 +71,14 @@ class CONTENT_EXPORT QuotaReservation
// For unit testing only. A QuotaReservation intended for unit testing will
// have file_system_context_ == NULL.
- QuotaReservation(
- scoped_refptr<fileapi::QuotaReservation> quota_reservation,
- const GURL& origin_url,
- fileapi::FileSystemType file_system_type);
+ QuotaReservation(scoped_refptr<fileapi::QuotaReservation> quota_reservation,
+ const GURL& origin_url,
+ fileapi::FileSystemType file_system_type);
~QuotaReservation();
void GotReservedQuota(const ReserveQuotaCallback& callback,
- base::PlatformFileError error);
+ base::File::Error error);
void DeleteOnCorrectThread() const;
diff --git a/chromium/content/browser/renderer_host/pepper/quota_reservation_unittest.cc b/chromium/content/browser/renderer_host/pepper/quota_reservation_unittest.cc
index 3f760e55664..e949074efb8 100644
--- a/chromium/content/browser/renderer_host/pepper/quota_reservation_unittest.cc
+++ b/chromium/content/browser/renderer_host/pepper/quota_reservation_unittest.cc
@@ -7,13 +7,13 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/file_util.h"
+#include "base/files/file.h"
#include "base/files/scoped_temp_dir.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/browser/fileapi/quota/quota_reservation.h"
-using fileapi::FileSystemType;
using fileapi::QuotaReservationManager;
namespace content {
@@ -21,7 +21,7 @@ namespace content {
namespace {
const char kOrigin[] = "http://example.com";
-const FileSystemType kType = fileapi::kFileSystemTypeTemporary;
+const fileapi::FileSystemType kType = fileapi::kFileSystemTypeTemporary;
const base::FilePath::StringType file1_name = FILE_PATH_LITERAL("file1");
const base::FilePath::StringType file2_name = FILE_PATH_LITERAL("file2");
@@ -37,28 +37,26 @@ class FakeBackend : public QuotaReservationManager::QuotaBackend {
virtual void ReserveQuota(
const GURL& origin,
- FileSystemType type,
+ fileapi::FileSystemType type,
int64 delta,
const QuotaReservationManager::ReserveQuotaCallback& callback) OVERRIDE {
base::MessageLoopProxy::current()->PostTask(
FROM_HERE,
- base::Bind(base::IgnoreResult(callback), base::PLATFORM_FILE_OK));
+ base::Bind(base::IgnoreResult(callback), base::File::FILE_OK, delta));
}
virtual void ReleaseReservedQuota(const GURL& origin,
- FileSystemType type,
- int64 size) OVERRIDE {
- }
+ fileapi::FileSystemType type,
+ int64 size) OVERRIDE {}
virtual void CommitQuotaUsage(const GURL& origin,
- FileSystemType type,
- int64 delta) OVERRIDE {
- }
+ fileapi::FileSystemType type,
+ int64 delta) OVERRIDE {}
virtual void IncrementDirtyCount(const GURL& origin,
- FileSystemType type) OVERRIDE {}
+ fileapi::FileSystemType type) OVERRIDE {}
virtual void DecrementDirtyCount(const GURL& origin,
- FileSystemType type) OVERRIDE {}
+ fileapi::FileSystemType type) OVERRIDE {}
private:
DISALLOW_COPY_AND_ASSIGN(FakeBackend);
@@ -80,6 +78,7 @@ class QuotaReservationTest : public testing::Test {
virtual void TearDown() OVERRIDE {
reservation_manager_.reset();
+ base::RunLoop().RunUntilIdle();
}
base::FilePath MakeFilePath(const base::FilePath::StringType& file_name) {
@@ -95,22 +94,17 @@ class QuotaReservationTest : public testing::Test {
scoped_refptr<QuotaReservation> CreateQuotaReservation(
scoped_refptr<fileapi::QuotaReservation> reservation,
const GURL& origin,
- FileSystemType type) {
+ fileapi::FileSystemType type) {
// Sets reservation_ as a side effect.
return scoped_refptr<QuotaReservation>(
new QuotaReservation(reservation, origin, type));
}
void SetFileSize(const base::FilePath::StringType& file_name, int64 size) {
- bool created = false;
- base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
- base::PlatformFile file = CreatePlatformFile(
- MakeFilePath(file_name),
- base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_WRITE,
- &created, &error);
- ASSERT_EQ(base::PLATFORM_FILE_OK, error);
- ASSERT_TRUE(base::TruncatePlatformFile(file, size));
- ASSERT_TRUE(base::ClosePlatformFile(file));
+ base::File file(MakeFilePath(file_name),
+ base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_WRITE);
+ ASSERT_TRUE(file.IsValid());
+ ASSERT_TRUE(file.SetLength(size));
}
QuotaReservationManager* reservation_manager() {
@@ -125,124 +119,126 @@ class QuotaReservationTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(QuotaReservationTest);
};
-void GotReservedQuota(
- int64* reserved_quota_ptr,
- QuotaReservation::OffsetMap* maximum_written_offsets_ptr,
- int64 reserved_quota,
- const QuotaReservation::OffsetMap& maximum_written_offsets) {
+void GotReservedQuota(int64* reserved_quota_ptr,
+ ppapi::FileGrowthMap* file_growths_ptr,
+ int64 reserved_quota,
+ const ppapi::FileSizeMap& maximum_written_offsets) {
*reserved_quota_ptr = reserved_quota;
- *maximum_written_offsets_ptr = maximum_written_offsets;
+
+ file_growths_ptr->clear();
+ for (ppapi::FileSizeMap::const_iterator it = maximum_written_offsets.begin();
+ it != maximum_written_offsets.end();
+ ++it)
+ (*file_growths_ptr)[it->first] = ppapi::FileGrowth(it->second, 0);
}
-void ReserveQuota(
- scoped_refptr<QuotaReservation> quota_reservation,
- int64 amount,
- int64* reserved_quota,
- QuotaReservation::OffsetMap* max_written_offsets) {
- quota_reservation->ReserveQuota(amount,
- *max_written_offsets,
- base::Bind(&GotReservedQuota,
- reserved_quota,
- max_written_offsets));
+void ReserveQuota(scoped_refptr<QuotaReservation> quota_reservation,
+ int64 amount,
+ int64* reserved_quota,
+ ppapi::FileGrowthMap* file_growths) {
+ quota_reservation->ReserveQuota(
+ amount,
+ *file_growths,
+ base::Bind(&GotReservedQuota, reserved_quota, file_growths));
base::RunLoop().RunUntilIdle();
}
// Tests that:
// 1) We can reserve quota with no files open.
// 2) Open a file, grow it, close it, and reserve quota with correct sizes.
-TEST_F(QuotaReservationTest, DISABLED_ReserveQuota) {
+TEST_F(QuotaReservationTest, ReserveQuota) {
GURL origin(kOrigin);
- FileSystemType type = kType;
+ fileapi::FileSystemType type = kType;
scoped_refptr<fileapi::QuotaReservation> reservation(
- reservation_manager()->CreateReservation(origin, type));
+ reservation_manager()->CreateReservation(origin, type));
scoped_refptr<QuotaReservation> test =
CreateQuotaReservation(reservation, origin, type);
// Reserve quota with no files open.
int64 amount = 100;
int64 reserved_quota;
- QuotaReservation::OffsetMap max_written_offsets;
- ReserveQuota(test, amount, &reserved_quota, &max_written_offsets);
+ ppapi::FileGrowthMap file_growths;
+ ReserveQuota(test, amount, &reserved_quota, &file_growths);
EXPECT_EQ(amount, reserved_quota);
- EXPECT_EQ(0U, max_written_offsets.size());
+ EXPECT_EQ(0U, file_growths.size());
// Open a file, refresh the reservation, extend the file, and close it.
int64 file_size = 10;
SetFileSize(file1_name, file_size);
- int64 open_file_size = test->OpenFile(kFile1ID,
- MakeFileSystemURL(file1_name));
+ int64 open_file_size =
+ test->OpenFile(kFile1ID, MakeFileSystemURL(file1_name));
EXPECT_EQ(file_size, open_file_size);
- max_written_offsets[kFile1ID] = file_size; // 1 file open.
- ReserveQuota(test, amount, &reserved_quota, &max_written_offsets);
+ file_growths[kFile1ID] = ppapi::FileGrowth(file_size, 0); // 1 file open.
+ ReserveQuota(test, amount, &reserved_quota, &file_growths);
EXPECT_EQ(amount, reserved_quota);
- EXPECT_EQ(1U, max_written_offsets.size());
- EXPECT_EQ(file_size, max_written_offsets[kFile1ID]);
+ EXPECT_EQ(1U, file_growths.size());
+ EXPECT_EQ(file_size, file_growths[kFile1ID].max_written_offset);
int64 new_file_size = 30;
SetFileSize(file1_name, new_file_size);
EXPECT_EQ(amount, reservation->remaining_quota());
- test->CloseFile(kFile1ID, new_file_size);
+ test->CloseFile(kFile1ID, ppapi::FileGrowth(new_file_size, 0));
EXPECT_EQ(amount - (new_file_size - file_size),
reservation->remaining_quota());
}
// Tests that:
// 1) We can open and close multiple files.
-TEST_F(QuotaReservationTest, DISABLED_MultipleFiles) {
+TEST_F(QuotaReservationTest, MultipleFiles) {
GURL origin(kOrigin);
- FileSystemType type = kType;
+ fileapi::FileSystemType type = kType;
scoped_refptr<fileapi::QuotaReservation> reservation(
- reservation_manager()->CreateReservation(origin, type));
+ reservation_manager()->CreateReservation(origin, type));
scoped_refptr<QuotaReservation> test =
CreateQuotaReservation(reservation, origin, type);
// Open some files of different sizes.
int64 file1_size = 10;
SetFileSize(file1_name, file1_size);
- int64 open_file1_size = test->OpenFile(kFile1ID,
- MakeFileSystemURL(file1_name));
+ int64 open_file1_size =
+ test->OpenFile(kFile1ID, MakeFileSystemURL(file1_name));
EXPECT_EQ(file1_size, open_file1_size);
int64 file2_size = 20;
SetFileSize(file2_name, file2_size);
- int64 open_file2_size = test->OpenFile(kFile2ID,
- MakeFileSystemURL(file2_name));
+ int64 open_file2_size =
+ test->OpenFile(kFile2ID, MakeFileSystemURL(file2_name));
EXPECT_EQ(file2_size, open_file2_size);
int64 file3_size = 30;
SetFileSize(file3_name, file3_size);
- int64 open_file3_size = test->OpenFile(kFile3ID,
- MakeFileSystemURL(file3_name));
+ int64 open_file3_size =
+ test->OpenFile(kFile3ID, MakeFileSystemURL(file3_name));
EXPECT_EQ(file3_size, open_file3_size);
// Reserve quota.
int64 amount = 100;
int64 reserved_quota;
- QuotaReservation::OffsetMap max_written_offsets;
- max_written_offsets[kFile1ID] = file1_size; // 3 files open.
- max_written_offsets[kFile2ID] = file2_size;
- max_written_offsets[kFile3ID] = file3_size;
+ ppapi::FileGrowthMap file_growths;
+ file_growths[kFile1ID] = ppapi::FileGrowth(file1_size, 0); // 3 files open.
+ file_growths[kFile2ID] = ppapi::FileGrowth(file2_size, 0);
+ file_growths[kFile3ID] = ppapi::FileGrowth(file3_size, 0);
- ReserveQuota(test, amount, &reserved_quota, &max_written_offsets);
+ ReserveQuota(test, amount, &reserved_quota, &file_growths);
EXPECT_EQ(amount, reserved_quota);
- EXPECT_EQ(3U, max_written_offsets.size());
- EXPECT_EQ(file1_size, max_written_offsets[kFile1ID]);
- EXPECT_EQ(file2_size, max_written_offsets[kFile2ID]);
- EXPECT_EQ(file3_size, max_written_offsets[kFile3ID]);
+ EXPECT_EQ(3U, file_growths.size());
+ EXPECT_EQ(file1_size, file_growths[kFile1ID].max_written_offset);
+ EXPECT_EQ(file2_size, file_growths[kFile2ID].max_written_offset);
+ EXPECT_EQ(file3_size, file_growths[kFile3ID].max_written_offset);
- test->CloseFile(kFile2ID, file2_size);
+ test->CloseFile(kFile2ID, ppapi::FileGrowth(file2_size, 0));
- max_written_offsets.erase(max_written_offsets.find(kFile2ID));
- ReserveQuota(test, amount, &reserved_quota, &max_written_offsets);
+ file_growths.erase(kFile2ID);
+ ReserveQuota(test, amount, &reserved_quota, &file_growths);
EXPECT_EQ(amount, reserved_quota);
- EXPECT_EQ(2U, max_written_offsets.size());
- EXPECT_EQ(file1_size, max_written_offsets[kFile1ID]);
- EXPECT_EQ(file3_size, max_written_offsets[kFile3ID]);
+ EXPECT_EQ(2U, file_growths.size());
+ EXPECT_EQ(file1_size, file_growths[kFile1ID].max_written_offset);
+ EXPECT_EQ(file3_size, file_growths[kFile3ID].max_written_offset);
- test->CloseFile(kFile1ID, file1_size);
- test->CloseFile(kFile3ID, file3_size);
+ test->CloseFile(kFile1ID, ppapi::FileGrowth(file1_size, 0));
+ test->CloseFile(kFile3ID, ppapi::FileGrowth(file3_size, 0));
}
} // namespace content
diff --git a/chromium/content/browser/renderer_host/pepper/ssl_context_helper.cc b/chromium/content/browser/renderer_host/pepper/ssl_context_helper.cc
index 3b92e6d0c16..a5ab3c806ae 100644
--- a/chromium/content/browser/renderer_host/pepper/ssl_context_helper.cc
+++ b/chromium/content/browser/renderer_host/pepper/ssl_context_helper.cc
@@ -9,11 +9,9 @@
namespace content {
-SSLContextHelper::SSLContextHelper() {
-}
+SSLContextHelper::SSLContextHelper() {}
-SSLContextHelper::~SSLContextHelper() {
-}
+SSLContextHelper::~SSLContextHelper() {}
net::CertVerifier* SSLContextHelper::GetCertVerifier() {
if (!cert_verifier_)