diff options
46 files changed, 880 insertions, 945 deletions
diff --git a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc index 94ddd54..403b129 100644 --- a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc +++ b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc @@ -25,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); @@ -128,7 +131,7 @@ GURL BrowserPpapiHostImpl::GetPluginURLForInstance(PP_Instance instance) { } void BrowserPpapiHostImpl::SetOnKeepaliveCallback( - const BrowserPpapiHost::OnKeepaliveCallback& callback) { + const BrowserPpapiHost::OnKeepaliveCallback& callback) { on_keepalive_callback_ = callback; } @@ -151,9 +154,8 @@ void BrowserPpapiHostImpl::DeleteInstance(PP_Instance instance) { 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) { -} + : ppapi_host_(ppapi_host), + browser_ppapi_host_impl_(browser_ppapi_host_impl) {} bool BrowserPpapiHostImpl::HostMessageFilter::OnMessageReceived( const IPC::Message& msg) { @@ -163,11 +165,11 @@ bool BrowserPpapiHostImpl::HostMessageFilter::OnMessageReceived( bool handled = true; 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)) + // 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; } @@ -178,8 +180,7 @@ void BrowserPpapiHostImpl::HostMessageFilter::OnHostDestroyed() { browser_ppapi_host_impl_ = NULL; } -BrowserPpapiHostImpl::HostMessageFilter::~HostMessageFilter() { -} +BrowserPpapiHostImpl::HostMessageFilter::~HostMessageFilter() {} void BrowserPpapiHostImpl::HostMessageFilter::OnKeepalive() { if (browser_ppapi_host_impl_) @@ -203,8 +204,7 @@ void BrowserPpapiHostImpl::OnKeepalive() { if (on_keepalive_callback_.is_null()) return; - BrowserPpapiHost::OnKeepaliveInstanceData - instance_data(instance_map_.size()); + BrowserPpapiHost::OnKeepaliveInstanceData instance_data(instance_map_.size()); InstanceMap::iterator instance = instance_map_.begin(); int i = 0; diff --git a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h index 0383e0d..0732214 100644 --- a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h +++ b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h @@ -31,24 +31,23 @@ 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 GetRenderFrameIDsForInstance( - PP_Instance instance, - int* render_process_id, - int* render_frame_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; diff --git a/content/browser/renderer_host/pepper/browser_ppapi_host_test.cc b/content/browser/renderer_host/pepper/browser_ppapi_host_test.cc index ecbcd0e..428f635 100644 --- a/content/browser/renderer_host/pepper/browser_ppapi_host_test.cc +++ b/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/content/browser/renderer_host/pepper/content_browser_pepper_host_factory.cc b/content/browser/renderer_host/pepper/content_browser_pepper_host_factory.cc index 8321934..e1ce032 100644 --- a/content/browser/renderer_host/pepper/content_browser_pepper_host_factory.cc +++ b/content/browser/renderer_host/pepper/content_browser_pepper_host_factory.cc @@ -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_CreateForFileAPI::ID: { PP_Resource file_system; std::string internal_path; if (!UnpackMessage<PpapiHostMsg_FileRef_CreateForFileAPI>( - message, &file_system, &internal_path)) { + 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/content/browser/renderer_host/pepper/pepper_browser_font_singleton_host.cc b/content/browser/renderer_host/pepper/pepper_browser_font_singleton_host.cc index 99a8e04..92a8162 100644 --- a/content/browser/renderer_host/pepper/pepper_browser_font_singleton_host.cc +++ b/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) { @@ -58,9 +56,9 @@ int32_t FontMessageFilter::OnResourceMessageReceived( const IPC::Message& msg, ppapi::host::HostMessageContext* context) { IPC_BEGIN_MESSAGE_MAP(FontMessageFilter, msg) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( - PpapiHostMsg_BrowserFontSingleton_GetFontFamilies, - OnHostMsgGetFontFamilies) + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( + PpapiHostMsg_BrowserFontSingleton_GetFontFamilies, + OnHostMsgGetFontFamilies) IPC_END_MESSAGE_MAP() return PP_ERROR_FAILED; } @@ -105,7 +103,6 @@ PepperBrowserFontSingletonHost::PepperBrowserFontSingletonHost( new FontMessageFilter())); } -PepperBrowserFontSingletonHost::~PepperBrowserFontSingletonHost() { -} +PepperBrowserFontSingletonHost::~PepperBrowserFontSingletonHost() {} } // namespace content diff --git a/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.cc b/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.cc index 72eecd4..a6b61981a 100644 --- a/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.cc +++ b/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.cc @@ -20,16 +20,16 @@ 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, @@ -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; @@ -146,8 +147,8 @@ void PepperExternalFileRefBackend::GetMetadataComplete( PP_FileInfo pp_file_info; if (error == base::File::FILE_OK) { - ppapi::FileInfoToPepperFileInfo(file_info, PP_FILESYSTEMTYPE_EXTERNAL, - &pp_file_info); + ppapi::FileInfoToPepperFileInfo( + file_info, PP_FILESYSTEMTYPE_EXTERNAL, &pp_file_info); } else { memset(&pp_file_info, 0, sizeof(pp_file_info)); } diff --git a/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.h b/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.h index 31dc45a..4d2980a 100644 --- a/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.h +++ b/content/browser/renderer_host/pepper/pepper_external_file_ref_backend.h @@ -37,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; @@ -56,10 +56,9 @@ class PepperExternalFileRefBackend : public PepperFileRefBackend { base::File::Error error); // Operation specific callbacks. - void GetMetadataComplete( - ppapi::host::ReplyMessageContext reply_context, - base::File::Error error, - const base::File::Info& 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/content/browser/renderer_host/pepper/pepper_file_io_host.cc b/content/browser/renderer_host/pepper/pepper_file_io_host.cc index b9532b7..56b6d922a 100644 --- a/content/browser/renderer_host/pepper/pepper_file_io_host.cc +++ b/content/browser/renderer_host/pepper/pepper_file_io_host.cc @@ -41,8 +41,8 @@ using ppapi::PPTimeToTime; namespace { -PepperFileIOHost::UIThreadStuff -GetUIThreadStuffForInternalFileSystems(int render_process_id) { +PepperFileIOHost::UIThreadStuff GetUIThreadStuffForInternalFileSystems( + int render_process_id) { PepperFileIOHost::UIThreadStuff stuff; DCHECK_CURRENTLY_ON(BrowserThread::UI); RenderProcessHost* host = RenderProcessHost::FromID(render_process_id); @@ -93,34 +93,28 @@ PepperFileIOHost::PepperFileIOHost(BrowserPpapiHostImpl* host, check_quota_(false), weak_factory_(this) { int unused; - if (!host->GetRenderFrameIDsForInstance(instance, - &render_process_id_, - &unused)) { + if (!host->GetRenderFrameIDsForInstance( + instance, &render_process_id_, &unused)) { render_process_id_ = -1; } - file_message_loop_ = BrowserThread::GetMessageLoopProxyForThread( - BrowserThread::FILE); + file_message_loop_ = + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE); } -PepperFileIOHost::~PepperFileIOHost() { -} +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_SetLength, - OnHostMsgSetLength) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileIO_Flush, - OnHostMsgFlush) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileIO_Close, - OnHostMsgClose) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileIO_RequestOSFileHandle, - OnHostMsgRequestOSFileHandle) + 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(PpapiHostMsg_FileIO_Close, OnHostMsgClose) + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileIO_RequestOSFileHandle, + OnHostMsgRequestOSFileHandle) IPC_END_MESSAGE_MAP() return PP_ERROR_FAILED; } @@ -129,8 +123,7 @@ PepperFileIOHost::UIThreadStuff::UIThreadStuff() { resolved_render_process_id = base::kNullProcessId; } -PepperFileIOHost::UIThreadStuff::~UIThreadStuff() { -} +PepperFileIOHost::UIThreadStuff::~UIThreadStuff() {} int32_t PepperFileIOHost::OnHostMsgOpen( ppapi::host::HostMessageContext* context, @@ -164,7 +157,7 @@ int32_t PepperFileIOHost::OnHostMsgOpen( // 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(); + file_system_url_.is_valid(); if (is_internal_type) { if (!file_system_url_.is_valid()) @@ -184,15 +177,13 @@ int32_t PepperFileIOHost::OnHostMsgOpen( return PP_ERROR_NOACCESS; } } - if (!CanOpenFileSystemURLWithPepperFlags(open_flags, - render_process_id_, - file_system_url_)) + 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(), context->MakeReplyMessageContext(), @@ -323,12 +314,12 @@ int32_t PepperFileIOHost::OnHostMsgSetLength( // quota reservation and request system as Write. if (!base::FileUtilProxy::Truncate( - file_message_loop_, - file_, - length, - base::Bind(&PepperFileIOHost::ExecutePlatformGeneralCallback, - weak_factory_.GetWeakPtr(), - context->MakeReplyMessageContext()))) + file_message_loop_, + file_, + length, + base::Bind(&PepperFileIOHost::ExecutePlatformGeneralCallback, + weak_factory_.GetWeakPtr(), + context->MakeReplyMessageContext()))) return PP_ERROR_FAILED; state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE); @@ -363,11 +354,10 @@ int32_t PepperFileIOHost::OnHostMsgClose( } if (file_ != base::kInvalidPlatformFileValue) { - base::FileUtilProxy::Close( - file_message_loop_, - file_, - base::Bind(&PepperFileIOHost::DidCloseFile, - weak_factory_.GetWeakPtr())); + base::FileUtilProxy::Close(file_message_loop_, + file_, + base::Bind(&PepperFileIOHost::DidCloseFile, + weak_factory_.GetWeakPtr())); file_ = base::kInvalidPlatformFileValue; } return PP_OK; @@ -380,8 +370,7 @@ void PepperFileIOHost::DidOpenQuotaFile( max_written_offset_ = max_written_offset; ExecutePlatformOpenFileCallback( - reply_context, base::File::FILE_OK, base::PassPlatformFile(&file), - true); + reply_context, base::File::FILE_OK, base::PassPlatformFile(&file), true); } void PepperFileIOHost::DidCloseFile(base::File::Error /*error*/) { @@ -430,8 +419,7 @@ void PepperFileIOHost::GotPluginAllowedToCallRequestOSFileHandle( void PepperFileIOHost::ExecutePlatformGeneralCallback( ppapi::host::ReplyMessageContext reply_context, base::File::Error error_code) { - reply_context.params.set_result( - ppapi::FileErrorToPepperError(error_code)); + reply_context.params.set_result(ppapi::FileErrorToPepperError(error_code)); host()->SendReply(reply_context, PpapiPluginMsg_FileIO_GeneralReply()); state_manager_.SetOperationFinished(); } @@ -458,9 +446,9 @@ void PepperFileIOHost::ExecutePlatformOpenFileCallback( } reply_context.params.set_result(pp_error); - host()->SendReply(reply_context, - PpapiPluginMsg_FileIO_OpenReply(quota_file_system, - max_written_offset_)); + host()->SendReply( + reply_context, + PpapiPluginMsg_FileIO_OpenReply(quota_file_system, max_written_offset_)); state_manager_.SetOperationFinished(); } @@ -477,8 +465,8 @@ bool PepperFileIOHost::AddFileToReplyContext( if (plugin_process_id == base::kNullProcessId) plugin_process_id = resolved_render_process_id_; - IPC::PlatformFileForTransit transit_file = BrokerGetFileHandleForProcess( - file_, plugin_process_id, false); + IPC::PlatformFileForTransit transit_file = + BrokerGetFileHandleForProcess(file_, plugin_process_id, false); if (transit_file == IPC::InvalidPlatformFileForTransit()) return false; diff --git a/content/browser/renderer_host/pepper/pepper_file_io_host.h b/content/browser/renderer_host/pepper/pepper_file_io_host.h index 45953c9..9d729fe 100644 --- a/content/browser/renderer_host/pepper/pepper_file_io_host.h +++ b/content/browser/renderer_host/pepper/pepper_file_io_host.h @@ -33,8 +33,7 @@ class PepperFileSystemBrowserHost; class PepperFileIOHost : public ppapi::host::ResourceHost, public base::SupportsWeakPtr<PepperFileIOHost> { public: - typedef base::Callback<void (base::File::Error)> - NotifyCloseFileCallback; + typedef base::Callback<void(base::File::Error)> NotifyCloseFileCallback; PepperFileIOHost(BrowserPpapiHostImpl* host, PP_Instance instance, @@ -52,6 +51,7 @@ class PepperFileIOHost : public ppapi::host::ResourceHost, 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, @@ -88,11 +88,10 @@ class PepperFileIOHost : public ppapi::host::ResourceHost, ppapi::host::ReplyMessageContext reply_context, int platform_file_flags, UIThreadStuff ui_thread_stuff); - void DidOpenInternalFile( - ppapi::host::ReplyMessageContext reply_context, - base::File::Error result, - base::PlatformFile file, - const base::Closure& on_close_callback); + void DidOpenInternalFile(ppapi::host::ReplyMessageContext reply_context, + base::File::Error result, + base::PlatformFile file, + const base::Closure& on_close_callback); void GotResolvedRenderProcessId( ppapi::host::ReplyMessageContext reply_context, base::FilePath path, diff --git a/content/browser/renderer_host/pepper/pepper_file_ref_host.cc b/content/browser/renderer_host/pepper/pepper_file_ref_host.cc index 627d3a0..c2d83af 100644 --- a/content/browser/renderer_host/pepper/pepper_file_ref_host.cc +++ b/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->GetRenderFrameIDsForInstance(instance, - &render_process_id, - &unused)) { + if (!host->GetRenderFrameIDsForInstance( + instance, &render_process_id, &unused)) { return; } @@ -76,11 +74,10 @@ PepperFileRefHost::PepperFileRefHost(BrowserPpapiHost* host, 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, @@ -95,23 +92,18 @@ PepperFileRefHost::PepperFileRefHost(BrowserPpapiHost* host, int render_process_id; int unused; - if (!host->GetRenderFrameIDsForInstance(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_; @@ -165,21 +157,16 @@ int32_t PepperFileRefHost::OnResourceMessageReceived( return PP_ERROR_FAILED; IPC_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); - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( - PpapiHostMsg_FileRef_ReadDirectoryEntries, - OnReadDirectoryEntries); - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileRef_GetAbsolutePath, - OnGetAbsolutePath); + 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); + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileRef_ReadDirectoryEntries, + OnReadDirectoryEntries); + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FileRef_GetAbsolutePath, + OnGetAbsolutePath); IPC_END_MESSAGE_MAP() return PP_ERROR_FAILED; @@ -191,8 +178,8 @@ int32_t PepperFileRefHost::OnMakeDirectory( int32_t rv = CanCreate(); if (rv != PP_OK) return rv; - return backend_->MakeDirectory( - context->MakeReplyMessageContext(), make_directory_flags); + return backend_->MakeDirectory(context->MakeReplyMessageContext(), + make_directory_flags); } int32_t PepperFileRefHost::OnTouch(ppapi::host::HostMessageContext* context, @@ -203,9 +190,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) { @@ -236,8 +222,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) { @@ -258,7 +243,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/content/browser/renderer_host/pepper/pepper_file_ref_host.h b/content/browser/renderer_host/pepper/pepper_file_ref_host.h index 9ae7931..d850504 100644 --- a/content/browser/renderer_host/pepper/pepper_file_ref_host.h +++ b/content/browser/renderer_host/pepper/pepper_file_ref_host.h @@ -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; diff --git a/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc b/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc index 8ae466c..0284ba4 100644 --- a/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc +++ b/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc @@ -34,8 +34,8 @@ 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) { +scoped_refptr<fileapi::FileSystemContext> GetFileSystemContextFromRenderId( + int render_process_id) { DCHECK_CURRENTLY_ON(BrowserThread::UI); RenderProcessHost* host = RenderProcessHost::FromID(render_process_id); if (!host) @@ -60,8 +60,7 @@ 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 @@ -84,7 +83,7 @@ void PepperFileSystemBrowserHost::OpenExisting(const GURL& root_url, int render_process_id = 0; int unused; if (!browser_ppapi_host_->GetRenderFrameIDsForInstance( - pp_instance(), &render_process_id, &unused)) { + pp_instance(), &render_process_id, &unused)) { NOTREACHED(); } called_open_ = true; @@ -95,29 +94,25 @@ 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_DISPATCH_HOST_RESOURCE_CALL( - PpapiHostMsg_FileSystem_InitIsolatedFileSystem, - OnHostMsgInitIsolatedFileSystem) - PPAPI_DISPATCH_HOST_RESOURCE_CALL( - PpapiHostMsg_FileSystem_ReserveQuota, - OnHostMsgReserveQuota) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileSystem_Open, OnHostMsgOpen) + PPAPI_DISPATCH_HOST_RESOURCE_CALL( + PpapiHostMsg_FileSystem_InitIsolatedFileSystem, + OnHostMsgInitIsolatedFileSystem) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FileSystem_ReserveQuota, + OnHostMsgReserveQuota) IPC_END_MESSAGE_MAP() return PP_ERROR_FAILED; } -bool PepperFileSystemBrowserHost::IsFileSystemHost() { - return true; -} +bool PepperFileSystemBrowserHost::IsFileSystemHost() { return true; } void PepperFileSystemBrowserHost::OpenQuotaFile( PepperFileIOHost* file_io_host, @@ -130,10 +125,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(); @@ -154,10 +146,8 @@ void PepperFileSystemBrowserHost::CloseQuotaFile( file_system_context_->default_file_task_runner()->PostTask( FROM_HERE, - base::Bind(&QuotaReservation::CloseFile, - quota_reservation_, - id, - file_growth)); + base::Bind( + &QuotaReservation::CloseFile, quota_reservation_, id, file_growth)); } int32_t PepperFileSystemBrowserHost::OnHostMsgOpen( @@ -178,10 +168,9 @@ int32_t PepperFileSystemBrowserHost::OnHostMsgOpen( int render_process_id = 0; int unused; - if (!browser_ppapi_host_->GetRenderFrameIDsForInstance(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( @@ -226,9 +215,11 @@ void PepperFileSystemBrowserHost::OpenFileSystem( 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(), @@ -270,7 +261,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; @@ -295,8 +287,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; @@ -309,11 +301,16 @@ 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( @@ -341,16 +338,16 @@ int32_t PepperFileSystemBrowserHost::OnHostMsgInitIsolatedFileSystem( int render_process_id = 0; int unused; - if (!browser_ppapi_host_->GetRenderFrameIDsForInstance(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, @@ -358,7 +355,9 @@ 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; } @@ -373,8 +372,8 @@ int32_t PepperFileSystemBrowserHost::OnHostMsgReserveQuota( return PP_ERROR_INPROGRESS; reserving_quota_ = true; - int64_t reservation_amount = std::max<int64_t>(kMinimumQuotaReservationSize, - amount); + int64_t reservation_amount = + std::max<int64_t>(kMinimumQuotaReservationSize, amount); file_system_context_->default_file_task_runner()->PostTask( FROM_HERE, base::Bind(&QuotaReservation::ReserveQuota, @@ -385,7 +384,6 @@ int32_t PepperFileSystemBrowserHost::OnHostMsgReserveQuota( weak_factory_.GetWeakPtr(), context->MakeReplyMessageContext()))); - return PP_OK_COMPLETIONPENDING; } @@ -494,10 +492,10 @@ std::string PepperFileSystemBrowserHost::GeneratePluginId( ReplaceFirstSubstringAfterOffset(&output, 0, "/", "_"); // 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/content/browser/renderer_host/pepper/pepper_file_system_browser_host.h b/content/browser/renderer_host/pepper/pepper_file_system_browser_host.h index d31a16d..f6f75fb 100644 --- a/content/browser/renderer_host/pepper/pepper_file_system_browser_host.h +++ b/content/browser/renderer_host/pepper/pepper_file_system_browser_host.h @@ -86,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::File::Error 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, @@ -105,21 +104,18 @@ class CONTENT_EXPORT PepperFileSystemBrowserHost const std::string& fsid, base::File::Error error); - int32_t OnHostMsgOpen( - ppapi::host::HostMessageContext* context, - int64_t expected_size); + int32_t OnHostMsgOpen(ppapi::host::HostMessageContext* context, + int64_t expected_size); int32_t OnHostMsgInitIsolatedFileSystem( 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); + 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, @@ -130,18 +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 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); + 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; @@ -152,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_; diff --git a/content/browser/renderer_host/pepper/pepper_file_system_browser_host_unittest.cc b/content/browser/renderer_host/pepper/pepper_file_system_browser_host_unittest.cc index fa07e39..8aa144c 100644 --- a/content/browser/renderer_host/pepper/pepper_file_system_browser_host_unittest.cc +++ b/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/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc b/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc index 5c746a9..550ede3 100644 --- a/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc @@ -28,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 @@ -60,8 +60,7 @@ PepperFlashFileMessageFilter::PepperFlashFileMessageFilter( } } -PepperFlashFileMessageFilter::~PepperFlashFileMessageFilter() { -} +PepperFlashFileMessageFilter::~PepperFlashFileMessageFilter() {} // static base::FilePath PepperFlashFileMessageFilter::GetDataDirName( @@ -84,24 +83,22 @@ PepperFlashFileMessageFilter::OverrideTaskRunnerForMessage( } int32_t PepperFlashFileMessageFilter::OnResourceMessageReceived( - const IPC::Message& msg, - ppapi::host::HostMessageContext* context) { + const IPC::Message& msg, + ppapi::host::HostMessageContext* context) { IPC_BEGIN_MESSAGE_MAP(PepperFlashFileMessageFilter, msg) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashFile_OpenFile, - OnOpenFile) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashFile_RenameFile, - OnRenameFile) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashFile_DeleteFileOrDir, - OnDeleteFileOrDir) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashFile_CreateDir, - OnCreateDir) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashFile_QueryFile, - OnQueryFile) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashFile_GetDirContents, - OnGetDirContents) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( - PpapiHostMsg_FlashFile_CreateTemporaryFile, - OnCreateTemporaryFile) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashFile_OpenFile, OnOpenFile) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashFile_RenameFile, + OnRenameFile) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashFile_DeleteFileOrDir, + OnDeleteFileOrDir) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashFile_CreateDir, + OnCreateDir) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashFile_QueryFile, + OnQueryFile) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_FlashFile_GetDirContents, + OnGetDirContents) + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( + PpapiHostMsg_FlashFile_CreateTemporaryFile, OnCreateTemporaryFile) IPC_END_MESSAGE_MAP() return PP_ERROR_FAILED; } @@ -111,16 +108,14 @@ 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::FileErrorToPepperError( - base::File::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)) { + if (!ppapi::PepperFileOpenFlagsToPlatformFileFlags(pp_open_flags, + &platform_file_flags)) { return base::File::FILE_ERROR_FAILED; } @@ -134,8 +129,7 @@ int32_t PepperFlashFileMessageFilter::OnOpenFile( base::File::Info info; if (!file.GetInfo(&info) || info.is_directory) { // When in doubt, throw it out. - return ppapi::FileErrorToPepperError( - base::File::FILE_ERROR_ACCESS_DENIED); + return ppapi::FileErrorToPepperError(base::File::FILE_ERROR_ACCESS_DENIED); } IPC::PlatformFileForTransit transit_file = @@ -157,84 +151,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::FileErrorToPepperError( - base::File::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::FileErrorToPepperError(result ? - base::File::FILE_OK : base::File::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::FileErrorToPepperError( - base::File::FILE_ERROR_ACCESS_DENIED); + return ppapi::FileErrorToPepperError(base::File::FILE_ERROR_ACCESS_DENIED); } bool result = base::DeleteFile(full_path, recursive); - return ppapi::FileErrorToPepperError(result ? - base::File::FILE_OK : base::File::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::FileErrorToPepperError( - base::File::FILE_ERROR_ACCESS_DENIED); + return ppapi::FileErrorToPepperError(base::File::FILE_ERROR_ACCESS_DENIED); } bool result = base::CreateDirectory(full_path); - return ppapi::FileErrorToPepperError(result ? - base::File::FILE_OK : base::File::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::FileErrorToPepperError( - base::File::FILE_ERROR_ACCESS_DENIED); + return ppapi::FileErrorToPepperError(base::File::FILE_ERROR_ACCESS_DENIED); } base::File::Info info; bool result = base::GetFileInfo(full_path, &info); context->reply_msg = PpapiPluginMsg_FlashFile_QueryFileReply(info); - return ppapi::FileErrorToPepperError(result ? - base::File::FILE_OK : base::File::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::FileErrorToPepperError( - base::File::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); } @@ -244,21 +231,19 @@ 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::FileErrorToPepperError( - base::File::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::FileErrorToPepperError( - base::File::FILE_ERROR_FAILED); + return ppapi::FileErrorToPepperError(base::File::FILE_ERROR_FAILED); } base::File file(file_path, @@ -293,8 +278,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/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.h b/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.h index f89d7cf..ab21076 100644 --- a/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.h +++ b/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/content/browser/renderer_host/pepper/pepper_gamepad_host.cc b/content/browser/renderer_host/pepper/pepper_gamepad_host.cc index 818bf24..8783e81 100644 --- a/content/browser/renderer_host/pepper/pepper_gamepad_host.cc +++ b/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,8 +33,7 @@ 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_) @@ -46,8 +44,8 @@ int32_t PepperGamepadHost::OnResourceMessageReceived( const IPC::Message& msg, ppapi::host::HostMessageContext* context) { IPC_BEGIN_MESSAGE_MAP(PepperGamepadHost, msg) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_Gamepad_RequestMemory, - OnRequestMemory) + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_Gamepad_RequestMemory, + OnRequestMemory) IPC_END_MESSAGE_MAP() return PP_ERROR_FAILED; } diff --git a/content/browser/renderer_host/pepper/pepper_gamepad_host_unittest.cc b/content/browser/renderer_host/pepper/pepper_gamepad_host_unittest.cc index f7cd51e..f86c944 100644 --- a/content/browser/renderer_host/pepper/pepper_gamepad_host_unittest.cc +++ b/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). @@ -200,8 +194,7 @@ TEST_F(PepperGamepadHostTest, WaitForReply) { // 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/content/browser/renderer_host/pepper/pepper_host_resolver_message_filter.cc b/content/browser/renderer_host/pepper/pepper_host_resolver_message_filter.cc index 422005f..6b05531 100644 --- a/content/browser/renderer_host/pepper/pepper_host_resolver_message_filter.cc +++ b/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; } @@ -90,15 +89,12 @@ PepperHostResolverMessageFilter::PepperHostResolverMessageFilter( DCHECK(host); if (!host->GetRenderFrameIDsForInstance( - instance, - &render_process_id_, - &render_frame_id_)) { + instance, &render_process_id_, &render_frame_id_)) { NOTREACHED(); } } -PepperHostResolverMessageFilter::~PepperHostResolverMessageFilter() { -} +PepperHostResolverMessageFilter::~PepperHostResolverMessageFilter() {} scoped_refptr<base::TaskRunner> PepperHostResolverMessageFilter::OverrideTaskRunnerForMessage( @@ -112,8 +108,8 @@ 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) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_HostResolver_Resolve, + OnMsgResolve) IPC_END_MESSAGE_MAP() return PP_ERROR_FAILED; } @@ -144,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, @@ -208,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/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.cc b/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.cc index 4aba18b..bc7f2b6 100644 --- a/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.cc +++ b/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.cc @@ -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()) @@ -197,8 +197,8 @@ int32_t PepperInternalFileRefBackend::ReadDirectoryEntries( if (!GetFileSystemURL().is_valid()) return PP_ERROR_FAILED; - fileapi::FileSystemOperation::FileEntryList* accumulated_file_list - = new fileapi::FileSystemOperation::FileEntryList; + fileapi::FileSystemOperation::FileEntryList* accumulated_file_list = + new fileapi::FileSystemOperation::FileEntryList; GetFileSystemContext()->operation_runner()->ReadDirectory( GetFileSystemURL(), base::Bind(&PepperInternalFileRefBackend::ReadDirectoryComplete, @@ -214,8 +214,8 @@ void PepperInternalFileRefBackend::ReadDirectoryComplete( base::File::Error error, const fileapi::FileSystemOperation::FileEntryList& file_list, bool has_more) { - accumulated_file_list->insert(accumulated_file_list->end(), - file_list.begin(), file_list.end()); + accumulated_file_list->insert( + accumulated_file_list->end(), file_list.begin(), file_list.end()); if (has_more) return; @@ -230,7 +230,8 @@ void PepperInternalFileRefBackend::ReadDirectoryComplete( for (fileapi::FileSystemOperation::FileEntryList::const_iterator it = accumulated_file_list->begin(); - it != accumulated_file_list->end(); ++it) { + it != accumulated_file_list->end(); + ++it) { if (it->is_directory) file_types.push_back(PP_FILETYPE_DIRECTORY); else @@ -247,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; } @@ -262,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; @@ -273,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; @@ -284,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/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.h b/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.h index a8c95c6..4214de0 100644 --- a/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.h +++ b/content/browser/renderer_host/pepper/pepper_internal_file_ref_backend.h @@ -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; @@ -59,10 +59,9 @@ class PepperInternalFileRefBackend : public PepperFileRefBackend { base::File::Error error); // Operation specific callbacks. - void GetMetadataComplete( - ppapi::host::ReplyMessageContext reply_context, - base::File::Error error, - const base::File::Info& 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, fileapi::FileSystemOperation::FileEntryList* accumulated_file_list, diff --git a/content/browser/renderer_host/pepper/pepper_lookup_request.h b/content/browser/renderer_host/pepper/pepper_lookup_request.h index da116fd..b36bd5e 100644 --- a/content/browser/renderer_host/pepper/pepper_lookup_request.h +++ b/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/content/browser/renderer_host/pepper/pepper_message_filter.cc b/content/browser/renderer_host/pepper/pepper_message_filter.cc index 0668f2a..943d0f9 100644 --- a/content/browser/renderer_host/pepper/pepper_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_message_filter.cc @@ -20,9 +20,9 @@ bool PepperMessageFilter::OnMessageReceived(const IPC::Message& msg, bool* message_was_ok) { bool handled = true; IPC_BEGIN_MESSAGE_MAP_EX(PepperMessageFilter, msg, *message_was_ok) - // X509 certificate messages. - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBX509Certificate_ParseDER, - OnX509CertificateParseDER); + // X509 certificate messages. + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBX509Certificate_ParseDER, + OnX509CertificateParseDER); IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP_EX() @@ -34,7 +34,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/content/browser/renderer_host/pepper/pepper_network_monitor_host.cc b/content/browser/renderer_host/pepper/pepper_network_monitor_host.cc index c62e1de..bc5795b 100644 --- a/content/browser/renderer_host/pepper/pepper_network_monitor_host.cc +++ b/content/browser/renderer_host/pepper/pepper_network_monitor_host.cc @@ -13,7 +13,6 @@ #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/shared_impl/private/net_address_private_impl.h" - namespace content { namespace { @@ -25,9 +24,11 @@ bool CanUseNetworkMonitor(bool external_plugin, SocketPermissionRequest request = SocketPermissionRequest( SocketPermissionRequest::NETWORK_STATE, std::string(), 0); - return pepper_socket_utils::CanUseSocketAPIs( - external_plugin, false /* private_api */, &request, render_process_id, - render_frame_id); + return pepper_socket_utils::CanUseSocketAPIs(external_plugin, + false /* private_api */, + &request, + render_process_id, + render_frame_id); } scoped_ptr<net::NetworkInterfaceList> GetNetworkList() { @@ -38,22 +39,23 @@ scoped_ptr<net::NetworkInterfaceList> GetNetworkList() { } // 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_frame_id; - host->GetRenderFrameIDsForInstance(instance, - &render_process_id, - &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_frame_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) { @@ -83,7 +83,8 @@ void PepperNetworkMonitorHost::GetAndSendNetworkList() { // 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())); diff --git a/content/browser/renderer_host/pepper/pepper_network_monitor_host.h b/content/browser/renderer_host/pepper/pepper_network_monitor_host.h index e27f8a2..12241c5 100644 --- a/content/browser/renderer_host/pepper/pepper_network_monitor_host.h +++ b/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/content/browser/renderer_host/pepper/pepper_network_proxy_host.cc b/content/browser/renderer_host/pepper/pepper_network_proxy_host.cc index 7fdda738..b47c931 100644 --- a/content/browser/renderer_host/pepper/pepper_network_proxy_host.cc +++ b/content/browser/renderer_host/pepper/pepper_network_proxy_host.cc @@ -31,11 +31,11 @@ PepperNetworkProxyHost::PepperNetworkProxyHost(BrowserPpapiHostImpl* host, waiting_for_ui_thread_data_(true), weak_factory_(this) { int render_process_id(0), render_frame_id(0); - host->GetRenderFrameIDsForInstance(instance, - &render_process_id, - &render_frame_id); + 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_frame_id, @@ -55,12 +55,9 @@ PepperNetworkProxyHost::~PepperNetworkProxyHost() { } } -PepperNetworkProxyHost::UIThreadData::UIThreadData() - : is_allowed(false) { -} +PepperNetworkProxyHost::UIThreadData::UIThreadData() : is_allowed(false) {} -PepperNetworkProxyHost::UIThreadData::~UIThreadData() { -} +PepperNetworkProxyHost::UIThreadData::~UIThreadData() {} // static PepperNetworkProxyHost::UIThreadData @@ -72,18 +69,19 @@ PepperNetworkProxyHost::GetUIThreadDataOnUIThread(int render_process_id, 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); } 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); + result.is_allowed = + pepper_socket_utils::CanUseSocketAPIs(is_external_plugin, + false /* is_private_api */, + &request, + render_process_id, + render_frame_id); return result; } @@ -107,8 +105,8 @@ 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) + PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_NetworkProxy_GetProxyForURL, + OnMsgGetProxyForURL) IPC_END_MESSAGE_MAP() return PP_ERROR_FAILED; } @@ -118,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; } @@ -142,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, @@ -184,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/content/browser/renderer_host/pepper/pepper_print_settings_manager.cc b/content/browser/renderer_host/pepper/pepper_print_settings_manager.cc index 14fbc08..de5f5fe 100644 --- a/content/browser/renderer_host/pepper/pepper_print_settings_manager.cc +++ b/content/browser/renderer_host/pepper/pepper_print_settings_manager.cc @@ -17,28 +17,28 @@ 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; } @@ -47,7 +47,7 @@ PepperPrintSettingsManager::Result ComputeDefaultPrintSettings() { // call into platform APIs. 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/content/browser/renderer_host/pepper/pepper_printing_host.cc b/content/browser/renderer_host/pepper/pepper_printing_host.cc index c11939c..7505b44 100644 --- a/content/browser/renderer_host/pepper/pepper_printing_host.cc +++ b/content/browser/renderer_host/pepper/pepper_printing_host.cc @@ -20,19 +20,16 @@ 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_DISPATCH_HOST_RESOURCE_CALL_0( - PpapiHostMsg_Printing_GetDefaultPrintSettings, - OnGetDefaultPrintSettings) + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( + PpapiHostMsg_Printing_GetDefaultPrintSettings, OnGetDefaultPrintSettings) IPC_END_MESSAGE_MAP() return PP_ERROR_FAILED; } @@ -50,9 +47,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/content/browser/renderer_host/pepper/pepper_printing_host.h b/content/browser/renderer_host/pepper/pepper_printing_host.h index 4c302ee..ec95629 100644 --- a/content/browser/renderer_host/pepper/pepper_printing_host.h +++ b/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/content/browser/renderer_host/pepper/pepper_printing_host_unittest.cc b/content/browser/renderer_host/pepper/pepper_printing_host_unittest.cc index a46db10..d9780425 100644 --- a/content/browser/renderer_host/pepper/pepper_printing_host_unittest.cc +++ b/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/content/browser/renderer_host/pepper/pepper_renderer_connection.cc b/content/browser/renderer_host/pepper/pepper_renderer_connection.cc index 1fbf01c6..abe7c9e 100644 --- a/content/browser/renderer_host/pepper/pepper_renderer_connection.cc +++ b/content/browser/renderer_host/pepper/pepper_renderer_connection.cc @@ -25,16 +25,12 @@ namespace content { namespace { -const uint32 kFilteredMessageClasses[] = { - PpapiMsgStart, - ViewMsgStart, -}; +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, @@ -91,8 +87,8 @@ PendingHostCreator::~PendingHostCreator() { } // namespace PepperRendererConnection::PepperRendererConnection(int render_process_id) - : BrowserMessageFilter( - kFilteredMessageClasses, arraysize(kFilteredMessageClasses)), + : 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, @@ -104,8 +100,7 @@ PepperRendererConnection::PepperRendererConnection(int render_process_id) false /* external_plugin */)); } -PepperRendererConnection::~PepperRendererConnection() { -} +PepperRendererConnection::~PepperRendererConnection() {} BrowserPpapiHostImpl* PepperRendererConnection::GetHostForChildProcess( int child_process_id) const { @@ -144,13 +139,13 @@ bool PepperRendererConnection::OnMessageReceived(const IPC::Message& msg, bool handled = true; IPC_BEGIN_MESSAGE_MAP_EX(PepperRendererConnection, msg, *message_was_ok) - IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostsFromHost, - OnMsgCreateResourceHostsFromHost) - IPC_MESSAGE_HANDLER(ViewHostMsg_DidCreateInProcessInstance, - OnMsgDidCreateInProcessInstance) - IPC_MESSAGE_HANDLER(ViewHostMsg_DidDeleteInProcessInstance, - OnMsgDidDeleteInProcessInstance) - IPC_MESSAGE_UNHANDLED(handled = false) + IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostsFromHost, + OnMsgCreateResourceHostsFromHost) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidCreateInProcessInstance, + OnMsgDidCreateInProcessInstance) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidDeleteInProcessInstance, + OnMsgDidDeleteInProcessInstance) + IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP_EX() return handled; @@ -193,21 +188,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/content/browser/renderer_host/pepper/pepper_security_helper.cc b/content/browser/renderer_host/pepper/pepper_security_helper.cc index 4e1306e..ab51628 100644 --- a/content/browser/renderer_host/pepper/pepper_security_helper.cc +++ b/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/content/browser/renderer_host/pepper/pepper_socket_utils.cc b/content/browser/renderer_host/pepper/pepper_socket_utils.cc index c667f31..dda97a1 100644 --- a/content/browser/renderer_host/pepper/pepper_socket_utils.cc +++ b/content/browser/renderer_host/pepper/pepper_socket_utils.cc @@ -26,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); } @@ -73,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/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc b/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc index 517fb99..4f6c2bb 100644 --- a/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.cc @@ -53,9 +53,8 @@ PepperTCPServerSocketMessageFilter::PepperTCPServerSocketMessageFilter( ++g_num_instances; DCHECK(factory_); DCHECK(ppapi_host_); - if (!host->GetRenderFrameIDsForInstance(instance, - &render_process_id_, - &render_frame_id_)) { + if (!host->GetRenderFrameIDsForInstance( + instance, &render_process_id_, &render_frame_id_)) { NOTREACHED(); } } @@ -86,12 +85,12 @@ 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_DISPATCH_HOST_RESOURCE_CALL_0( - PpapiHostMsg_TCPServerSocket_StopListening, OnMsgStopListening) + 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() return PP_ERROR_FAILED; } @@ -115,9 +114,13 @@ int32_t PepperTCPServerSocketMessageFilter::OnMsgListen( } 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; } @@ -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; @@ -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/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.h b/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.h index 3f5e70d..43262fc 100644 --- a/content/browser/renderer_host/pepper/pepper_tcp_server_socket_message_filter.h +++ b/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(); diff --git a/content/browser/renderer_host/pepper/pepper_tcp_socket.cc b/content/browser/renderer_host/pepper/pepper_tcp_socket.cc index c03123a..474a2fd 100644 --- a/content/browser/renderer_host/pepper/pepper_tcp_socket.cc +++ b/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), @@ -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; } @@ -159,9 +157,8 @@ 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); } @@ -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: @@ -283,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)); } @@ -305,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; } @@ -360,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) { @@ -380,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) { @@ -415,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; @@ -440,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); @@ -464,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; @@ -491,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)); } @@ -507,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/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc b/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc index 3778c2f..14e00db 100644 --- a/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.cc @@ -69,9 +69,8 @@ PepperTCPSocketMessageFilter::PepperTCPSocketMessageFilter( pending_accept_(false) { DCHECK(host); ++g_num_instances; - if (!host->GetRenderFrameIDsForInstance(instance, - &render_process_id_, - &render_frame_id_)) { + if (!host->GetRenderFrameIDsForInstance( + instance, &render_process_id_, &render_frame_id_)) { NOTREACHED(); } } @@ -99,9 +98,8 @@ PepperTCPSocketMessageFilter::PepperTCPSocketMessageFilter( DCHECK_NE(version, ppapi::TCP_SOCKET_VERSION_1_0); ++g_num_instances; - if (!host->GetRenderFrameIDsForInstance(instance, - &render_process_id_, - &render_frame_id_)) { + if (!host->GetRenderFrameIDsForInstance( + instance, &render_process_id_, &render_frame_id_)) { NOTREACHED(); } } @@ -143,27 +141,21 @@ 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_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) + 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() return PP_ERROR_FAILED; } @@ -179,18 +171,22 @@ int32_t PepperTCPSocketMessageFilter::OnMsgBind( return PP_ERROR_NOACCESS; } - if (!pepper_socket_utils::CanUseSocketAPIs( - external_plugin_, false /* private_api */, NULL, render_process_id_, - render_frame_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; } @@ -206,12 +202,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_frame_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,11 +220,14 @@ 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; } @@ -239,16 +239,21 @@ int32_t PepperTCPSocketMessageFilter::OnMsgConnectWithNetAddress( 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_, + 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; } @@ -282,9 +287,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 +304,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; @@ -323,18 +331,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); @@ -379,16 +389,20 @@ 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_frame_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; } @@ -408,7 +422,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; @@ -493,8 +508,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; } @@ -514,8 +529,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; @@ -555,14 +570,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); @@ -582,8 +598,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; @@ -611,14 +627,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); @@ -677,7 +695,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); @@ -701,12 +720,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; @@ -778,9 +797,8 @@ void PepperTCPSocketMessageFilter::OnReadCompleted( 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()); @@ -835,9 +853,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; @@ -972,7 +989,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/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.h b/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.h index 35fdabd..5c4e066 100644 --- a/content/browser/renderer_host/pepper/pepper_tcp_socket_message_filter.h +++ b/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); diff --git a/content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc b/content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc index af1717e..60494d1 100644 --- a/content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc +++ b/content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc @@ -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) { @@ -64,12 +62,12 @@ int32_t FontMessageFilter::OnResourceMessageReceived( const IPC::Message& msg, ppapi::host::HostMessageContext* context) { IPC_BEGIN_MESSAGE_MAP(FontMessageFilter, msg) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( - PpapiHostMsg_TrueTypeFontSingleton_GetFontFamilies, - OnHostMsgGetFontFamilies) - PPAPI_DISPATCH_HOST_RESOURCE_CALL( - PpapiHostMsg_TrueTypeFontSingleton_GetFontsInFamily, - OnHostMsgGetFontsInFamily) + PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( + PpapiHostMsg_TrueTypeFontSingleton_GetFontFamilies, + OnHostMsgGetFontFamilies) + PPAPI_DISPATCH_HOST_RESOURCE_CALL( + PpapiHostMsg_TrueTypeFontSingleton_GetFontsInFamily, + OnHostMsgGetFontsInFamily) IPC_END_MESSAGE_MAP() return PP_ERROR_FAILED; } @@ -102,16 +100,14 @@ int32_t FontMessageFilter::OnHostMsgGetFontsInFamily( } // 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/content/browser/renderer_host/pepper/pepper_truetype_font_list_win.cc b/content/browser/renderer_host/pepper/pepper_truetype_font_list_win.cc index c52ee96..8e27590 100644 --- a/content/browser/renderer_host/pepper/pepper_truetype_font_list_win.cc +++ b/content/browser/renderer_host/pepper/pepper_truetype_font_list_win.cc @@ -49,8 +49,7 @@ static int CALLBACK EnumFontsInFamilyProc(ENUMLOGFONTEXW* logical_font, 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, @@ -76,8 +78,11 @@ void GetFontsInFamily_SlowBlocking(const std::string& 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/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.cc b/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.cc index bcaf2ae..fcb6081 100644 --- a/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.cc @@ -53,9 +53,8 @@ PepperUDPSocketMessageFilter::PepperUDPSocketMessageFilter( ++g_num_instances; DCHECK(host); - if (!host->GetRenderFrameIDsForInstance(instance, - &render_process_id_, - &render_frame_id_)) { + if (!host->GetRenderFrameIDsForInstance( + instance, &render_process_id_, &render_frame_id_)) { NOTREACHED(); } } @@ -89,16 +88,13 @@ 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) + 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() return PP_ERROR_FAILED; } @@ -143,13 +139,13 @@ int32_t PepperUDPSocketMessageFilter::OnMsgSetOption( 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; } net_result = socket_->SetSendBufferSize(integer_value); } else { if (integer_value > - ppapi::proxy::UDPSocketResourceBase::kMaxReceiveBufferSize) { + ppapi::proxy::UDPSocketResourceBase::kMaxReceiveBufferSize) { return PP_ERROR_BADARGUMENT; } net_result = socket_->SetReceiveBufferSize(integer_value); @@ -173,17 +169,20 @@ int32_t PepperUDPSocketMessageFilter::OnMsgBind( SocketPermissionRequest request = pepper_socket_utils::CreateSocketPermissionRequest( SocketPermissionRequest::UDP_BIND, addr); - if (!pepper_socket_utils::CanUseSocketAPIs(external_plugin_, private_api_, - &request, render_process_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; } @@ -236,16 +235,21 @@ int32_t PepperUDPSocketMessageFilter::OnMsgSendTo( SocketPermissionRequest request = pepper_socket_utils::CreateSocketPermissionRequest( SocketPermissionRequest::UDP_SEND_TO, addr); - if (!pepper_socket_utils::CanUseSocketAPIs(external_plugin_, private_api_, - &request, render_process_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; } @@ -266,8 +270,8 @@ void PepperUDPSocketMessageFilter::DoBind( 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; @@ -281,8 +285,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; @@ -295,11 +299,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; } @@ -330,7 +332,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); @@ -385,8 +387,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); } @@ -424,8 +426,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( @@ -434,8 +435,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/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.h b/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.h index 64dc32f..8ca7f08 100644 --- a/content/browser/renderer_host/pepper/pepper_udp_socket_message_filter.h +++ b/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, diff --git a/content/browser/renderer_host/pepper/quota_reservation.cc b/content/browser/renderer_host/pepper/quota_reservation.cc index ed572d6..85a404c 100644 --- a/content/browser/renderer_host/pepper/quota_reservation.cc +++ b/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; } @@ -91,10 +89,9 @@ void QuotaReservation::CloseFile(int32_t id, } } -void QuotaReservation::ReserveQuota( - int64_t amount, - const ppapi::FileGrowthMap& file_growths, - const ReserveQuotaCallback& callback) { +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); @@ -108,30 +105,23 @@ void QuotaReservation::ReserveQuota( } quota_reservation_->RefreshReservation( - amount, - base::Bind(&QuotaReservation::GotReservedQuota, - this, - callback)); + amount, base::Bind(&QuotaReservation::GotReservedQuota, this, callback)); } -void QuotaReservation::OnClientCrash() { - quota_reservation_->OnClientCrash(); -} +void QuotaReservation::OnClientCrash() { quota_reservation_->OnClientCrash(); } -void QuotaReservation::GotReservedQuota( - const ReserveQuotaCallback& callback, - base::File::Error error) { +void QuotaReservation::GotReservedQuota(const ReserveQuotaCallback& callback, + base::File::Error error) { ppapi::FileSizeMap file_sizes; - for (FileMap::iterator it = files_.begin(); it != files_.end(); ++ it) + 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(), - file_sizes)); + base::Bind( + callback, quota_reservation_->remaining_quota(), file_sizes)); } else { // Unit testing code path. callback.Run(quota_reservation_->remaining_quota(), file_sizes); @@ -139,12 +129,10 @@ void QuotaReservation::GotReservedQuota( } 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/content/browser/renderer_host/pepper/quota_reservation.h b/content/browser/renderer_host/pepper/quota_reservation.h index ddc5e29..f003f94 100644 --- a/content/browser/renderer_host/pepper/quota_reservation.h +++ b/content/browser/renderer_host/pepper/quota_reservation.h @@ -72,10 +72,9 @@ 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(); diff --git a/content/browser/renderer_host/pepper/quota_reservation_unittest.cc b/content/browser/renderer_host/pepper/quota_reservation_unittest.cc index 8428364..05eb4bf 100644 --- a/content/browser/renderer_host/pepper/quota_reservation_unittest.cc +++ b/content/browser/renderer_host/pepper/quota_reservation_unittest.cc @@ -48,13 +48,11 @@ class FakeBackend : public QuotaReservationManager::QuotaBackend { virtual void ReleaseReservedQuota(const GURL& origin, FileSystemType type, - int64 size) OVERRIDE { - } + int64 size) OVERRIDE {} virtual void CommitQuotaUsage(const GURL& origin, FileSystemType type, - int64 delta) OVERRIDE { - } + int64 delta) OVERRIDE {} virtual void IncrementDirtyCount(const GURL& origin, FileSystemType type) OVERRIDE {} @@ -122,29 +120,27 @@ class QuotaReservationTest : public testing::Test { DISALLOW_COPY_AND_ASSIGN(QuotaReservationTest); }; -void GotReservedQuota( - int64* reserved_quota_ptr, - ppapi::FileGrowthMap* file_growths_ptr, - int64 reserved_quota, - const ppapi::FileSizeMap& 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; file_growths_ptr->clear(); for (ppapi::FileSizeMap::const_iterator it = maximum_written_offsets.begin(); - it != maximum_written_offsets.end(); ++it) + 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, - ppapi::FileGrowthMap* file_growths) { - quota_reservation->ReserveQuota(amount, - *file_growths, - base::Bind(&GotReservedQuota, - reserved_quota, - file_growths)); +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(); } @@ -156,7 +152,7 @@ TEST_F(QuotaReservationTest, ReserveQuota) { 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); @@ -171,8 +167,8 @@ TEST_F(QuotaReservationTest, ReserveQuota) { // 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); file_growths[kFile1ID] = ppapi::FileGrowth(file_size, 0); // 1 file open. @@ -197,25 +193,25 @@ TEST_F(QuotaReservationTest, MultipleFiles) { 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. diff --git a/content/browser/renderer_host/pepper/ssl_context_helper.cc b/content/browser/renderer_host/pepper/ssl_context_helper.cc index 3b92e6d..a5ab3c8 100644 --- a/content/browser/renderer_host/pepper/ssl_context_helper.cc +++ b/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_) |