diff options
Diffstat (limited to 'chromium/ppapi')
70 files changed, 470 insertions, 384 deletions
diff --git a/chromium/ppapi/c/documentation/doxy_cleanup.py b/chromium/ppapi/c/documentation/doxy_cleanup.py index be94342d4b6..4988c24f10c 100755 --- a/chromium/ppapi/c/documentation/doxy_cleanup.py +++ b/chromium/ppapi/c/documentation/doxy_cleanup.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be diff --git a/chromium/ppapi/host/resource_message_filter.h b/chromium/ppapi/host/resource_message_filter.h index c2333a0db85..578fc6f7af7 100644 --- a/chromium/ppapi/host/resource_message_filter.h +++ b/chromium/ppapi/host/resource_message_filter.h @@ -52,8 +52,7 @@ struct PPAPI_HOST_EXPORT ResourceMessageFilterDeleteTraits { // scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage( // const IPC::Message& message) override { // if (message.type() == MyMessage::ID) { -// return base::CreateSingleThreadTaskRunner( -// {BrowserThread::UI}); +// return content::GetUIThreadTaskRunner({}); // } // return NULL; // } diff --git a/chromium/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_component_crx_gen.py b/chromium/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_component_crx_gen.py index 9d2257c4be2..ae50e1f730a 100755 --- a/chromium/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_component_crx_gen.py +++ b/chromium/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_component_crx_gen.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/chromium/ppapi/native_client/tools/browser_tester/browser_tester.py b/chromium/ppapi/native_client/tools/browser_tester/browser_tester.py index c9b7ce6604e..565546e5b11 100755 --- a/chromium/ppapi/native_client/tools/browser_tester/browser_tester.py +++ b/chromium/ppapi/native_client/tools/browser_tester/browser_tester.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserlauncher.py b/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserlauncher.py index dd94434a15c..0720000de3a 100755 --- a/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserlauncher.py +++ b/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserlauncher.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserprocess.py b/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserprocess.py index d012eb213d1..7e8fa9b8b02 100755 --- a/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserprocess.py +++ b/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserprocess.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/chromium/ppapi/native_client/tools/browser_tester/browsertester/rpclistener.py b/chromium/ppapi/native_client/tools/browser_tester/browsertester/rpclistener.py index 5003f1f0cec..1337b55e50d 100755 --- a/chromium/ppapi/native_client/tools/browser_tester/browsertester/rpclistener.py +++ b/chromium/ppapi/native_client/tools/browser_tester/browsertester/rpclistener.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/chromium/ppapi/proxy/BUILD.gn b/chromium/ppapi/proxy/BUILD.gn index 000c50dd352..90c2049a4e4 100644 --- a/chromium/ppapi/proxy/BUILD.gn +++ b/chromium/ppapi/proxy/BUILD.gn @@ -107,8 +107,6 @@ component("proxy") { "ppb_message_loop_proxy.h", "ppb_testing_proxy.cc", "ppb_testing_proxy.h", - "ppb_x509_certificate_private_proxy.cc", - "ppb_x509_certificate_private_proxy.h", "ppp_class_proxy.cc", "ppp_class_proxy.h", "ppp_find_proxy.cc", @@ -221,6 +219,8 @@ component("proxy") { "ppb_var_deprecated_proxy.h", "ppb_video_decoder_proxy.cc", "ppb_video_decoder_proxy.h", + "ppb_x509_certificate_private_proxy.cc", + "ppb_x509_certificate_private_proxy.h", "ppp_instance_private_proxy.cc", "ppp_instance_private_proxy.h", "ppp_video_decoder_proxy.cc", diff --git a/chromium/ppapi/proxy/audio_encoder_resource.cc b/chromium/ppapi/proxy/audio_encoder_resource.cc index 155cf85ff18..839b8bd484e 100644 --- a/chromium/ppapi/proxy/audio_encoder_resource.cc +++ b/chromium/ppapi/proxy/audio_encoder_resource.cc @@ -45,8 +45,9 @@ int32_t AudioEncoderResource::GetSupportedProfiles( get_supported_profiles_callback_ = callback; Call<PpapiPluginMsg_AudioEncoder_GetSupportedProfilesReply>( RENDERER, PpapiHostMsg_AudioEncoder_GetSupportedProfiles(), - base::Bind(&AudioEncoderResource::OnPluginMsgGetSupportedProfilesReply, - this, output)); + base::BindOnce( + &AudioEncoderResource::OnPluginMsgGetSupportedProfilesReply, this, + output)); return PP_OK_COMPLETIONPENDING; } @@ -75,7 +76,7 @@ int32_t AudioEncoderResource::Initialize( Call<PpapiPluginMsg_AudioEncoder_InitializeReply>( RENDERER, PpapiHostMsg_AudioEncoder_Initialize(parameters), - base::Bind(&AudioEncoderResource::OnPluginMsgInitializeReply, this)); + base::BindOnce(&AudioEncoderResource::OnPluginMsgInitializeReply, this)); return PP_OK_COMPLETIONPENDING; } diff --git a/chromium/ppapi/proxy/audio_input_resource.cc b/chromium/ppapi/proxy/audio_input_resource.cc index 6f84d001fcd..40aa644cd74 100644 --- a/chromium/ppapi/proxy/audio_input_resource.cc +++ b/chromium/ppapi/proxy/audio_input_resource.cc @@ -4,6 +4,7 @@ #include "ppapi/proxy/audio_input_resource.h" +#include <memory> #include <string> #include "base/bind.h" @@ -183,7 +184,7 @@ void AudioInputResource::OnPluginMsgOpenReply( void AudioInputResource::SetStreamInfo( base::ReadOnlySharedMemoryRegion shared_memory_region, base::SyncSocket::Handle socket_handle) { - socket_.reset(new base::CancelableSyncSocket(socket_handle)); + socket_ = std::make_unique<base::CancelableSyncSocket>(socket_handle); DCHECK(!shared_memory_mapping_.IsValid()); // Ensure that the allocated memory is enough for the audio bus and buffer @@ -232,8 +233,8 @@ void AudioInputResource::StartThread() { return; } DCHECK(!audio_input_thread_.get()); - audio_input_thread_.reset(new base::DelegateSimpleThread( - this, "plugin_audio_input_thread")); + audio_input_thread_ = std::make_unique<base::DelegateSimpleThread>( + this, "plugin_audio_input_thread"); audio_input_thread_->Start(); } @@ -349,8 +350,8 @@ int32_t AudioInputResource::CommonOpen( enter_config.object()->GetSampleFrameCount()); Call<PpapiPluginMsg_AudioInput_OpenReply>( RENDERER, msg, - base::Bind(&AudioInputResource::OnPluginMsgOpenReply, - base::Unretained(this))); + base::BindOnce(&AudioInputResource::OnPluginMsgOpenReply, + base::Unretained(this))); return PP_OK_COMPLETIONPENDING; } } // namespace proxy diff --git a/chromium/ppapi/proxy/audio_output_resource.cc b/chromium/ppapi/proxy/audio_output_resource.cc index 188541360f7..0daf3f6beed 100644 --- a/chromium/ppapi/proxy/audio_output_resource.cc +++ b/chromium/ppapi/proxy/audio_output_resource.cc @@ -4,6 +4,8 @@ #include "ppapi/proxy/audio_output_resource.h" +#include <memory> + #include "base/bind.h" #include "base/check_op.h" #include "base/numerics/safe_conversions.h" @@ -167,7 +169,7 @@ void AudioOutputResource::OnPluginMsgOpenReply( void AudioOutputResource::SetStreamInfo( base::UnsafeSharedMemoryRegion shared_memory_region, base::SyncSocket::Handle socket_handle) { - socket_.reset(new base::CancelableSyncSocket(socket_handle)); + socket_ = std::make_unique<base::CancelableSyncSocket>(socket_handle); // Ensure that the allocated memory is enough for the audio bus and buffer // parameters. Note that there might be slightly more allocated memory as @@ -209,8 +211,8 @@ void AudioOutputResource::StartThread() { memset(client_buffer_.get(), 0, client_buffer_size_bytes_); DCHECK(!audio_output_thread_.get()); - audio_output_thread_.reset( - new base::DelegateSimpleThread(this, "plugin_audio_output_thread")); + audio_output_thread_ = std::make_unique<base::DelegateSimpleThread>( + this, "plugin_audio_output_thread"); audio_output_thread_->Start(); } @@ -313,8 +315,8 @@ int32_t AudioOutputResource::CommonOpen( enter_config.object()->GetSampleFrameCount()); Call<PpapiPluginMsg_AudioOutput_OpenReply>( RENDERER, msg, - base::Bind(&AudioOutputResource::OnPluginMsgOpenReply, - base::Unretained(this))); + base::BindOnce(&AudioOutputResource::OnPluginMsgOpenReply, + base::Unretained(this))); return PP_OK_COMPLETIONPENDING; } } // namespace proxy diff --git a/chromium/ppapi/proxy/camera_device_resource.cc b/chromium/ppapi/proxy/camera_device_resource.cc index bd29ea9acdb..7d2dab040fc 100644 --- a/chromium/ppapi/proxy/camera_device_resource.cc +++ b/chromium/ppapi/proxy/camera_device_resource.cc @@ -40,8 +40,8 @@ int32_t CameraDeviceResource::Open( Call<PpapiPluginMsg_CameraDevice_OpenReply>( RENDERER, PpapiHostMsg_CameraDevice_Open(source_string_var->value()), - base::Bind(&CameraDeviceResource::OnPluginMsgOpenReply, - base::Unretained(this))); + base::BindOnce(&CameraDeviceResource::OnPluginMsgOpenReply, + base::Unretained(this))); return PP_OK_COMPLETIONPENDING; } @@ -81,8 +81,9 @@ int32_t CameraDeviceResource::GetCameraCapabilities( get_capabilities_callback_ = callback; Call<PpapiPluginMsg_CameraDevice_GetSupportedVideoCaptureFormatsReply>( RENDERER, PpapiHostMsg_CameraDevice_GetSupportedVideoCaptureFormats(), - base::Bind(&CameraDeviceResource::OnPluginMsgGetVideoCaptureFormatsReply, - base::Unretained(this), capabilities)); + base::BindOnce( + &CameraDeviceResource::OnPluginMsgGetVideoCaptureFormatsReply, + base::Unretained(this), capabilities)); return PP_OK_COMPLETIONPENDING; } diff --git a/chromium/ppapi/proxy/device_enumeration_resource_helper.cc b/chromium/ppapi/proxy/device_enumeration_resource_helper.cc index 0c84af1b029..9121313db74 100644 --- a/chromium/ppapi/proxy/device_enumeration_resource_helper.cc +++ b/chromium/ppapi/proxy/device_enumeration_resource_helper.cc @@ -49,7 +49,7 @@ int32_t DeviceEnumerationResourceHelper::EnumerateDevices( PpapiHostMsg_DeviceEnumeration_EnumerateDevices msg; owner_->Call<PpapiPluginMsg_DeviceEnumeration_EnumerateDevicesReply>( PluginResource::RENDERER, msg, - base::Bind( + base::BindOnce( &DeviceEnumerationResourceHelper::OnPluginMsgEnumerateDevicesReply, AsWeakPtr(), output, callback)); return PP_OK_COMPLETIONPENDING; diff --git a/chromium/ppapi/proxy/dispatch_reply_message.h b/chromium/ppapi/proxy/dispatch_reply_message.h index 21eaac60b72..2f4c53e21df 100644 --- a/chromium/ppapi/proxy/dispatch_reply_message.h +++ b/chromium/ppapi/proxy/dispatch_reply_message.h @@ -74,7 +74,7 @@ inline void DispatchResourceReply(CallbackType&& callback, // Used to dispatch resource replies. In most cases, you should not call this // function to dispatch a resource reply manually, but instead use // |PluginResource::CallBrowser|/|PluginResource::CallRenderer| with a -// |base::Callback| which will be called when a reply message is received +// |base::OnceCallback| which will be called when a reply message is received // (see plugin_resource.h). // // This function will call your callback with the nested reply message's diff --git a/chromium/ppapi/proxy/file_chooser_resource.cc b/chromium/ppapi/proxy/file_chooser_resource.cc index dc70cbde55a..fe2ab05c29a 100644 --- a/chromium/ppapi/proxy/file_chooser_resource.cc +++ b/chromium/ppapi/proxy/file_chooser_resource.cc @@ -147,8 +147,9 @@ int32_t FileChooserResource::ShowInternal( mode_ == PP_FILECHOOSERMODE_OPENMULTIPLE, sugg_str ? sugg_str->value() : std::string(), accept_types_); - Call<PpapiPluginMsg_FileChooser_ShowReply>(RENDERER, msg, - base::Bind(&FileChooserResource::OnPluginMsgShowReply, this)); + Call<PpapiPluginMsg_FileChooser_ShowReply>( + RENDERER, msg, + base::BindOnce(&FileChooserResource::OnPluginMsgShowReply, this)); return PP_OK_COMPLETIONPENDING; } diff --git a/chromium/ppapi/proxy/file_io_resource.cc b/chromium/ppapi/proxy/file_io_resource.cc index 84f2ecdea9d..f95ce833dfb 100644 --- a/chromium/ppapi/proxy/file_io_resource.cc +++ b/chromium/ppapi/proxy/file_io_resource.cc @@ -159,12 +159,10 @@ int32_t FileIOResource::Open(PP_Resource file_ref, // don't want the plugin destroying it during the Open operation. file_ref_ = enter_file_ref.resource(); - Call<PpapiPluginMsg_FileIO_OpenReply>(BROWSER, - PpapiHostMsg_FileIO_Open( - file_ref, - open_flags), - base::Bind(&FileIOResource::OnPluginMsgOpenFileComplete, this, - callback)); + Call<PpapiPluginMsg_FileIO_OpenReply>( + BROWSER, PpapiHostMsg_FileIO_Open(file_ref, open_flags), + base::BindOnce(&FileIOResource::OnPluginMsgOpenFileComplete, this, + callback)); state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE); return PP_OK_COMPLETIONPENDING; @@ -227,10 +225,10 @@ int32_t FileIOResource::Touch(PP_Time last_access_time, if (rv != PP_OK) return rv; - Call<PpapiPluginMsg_FileIO_GeneralReply>(BROWSER, - PpapiHostMsg_FileIO_Touch(last_access_time, last_modified_time), - base::Bind(&FileIOResource::OnPluginMsgGeneralComplete, this, - callback)); + Call<PpapiPluginMsg_FileIO_GeneralReply>( + BROWSER, PpapiHostMsg_FileIO_Touch(last_access_time, last_modified_time), + base::BindOnce(&FileIOResource::OnPluginMsgGeneralComplete, this, + callback)); state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE); return PP_OK_COMPLETIONPENDING; @@ -358,10 +356,10 @@ int32_t FileIOResource::Flush(scoped_refptr<TrackedCallback> callback) { if (rv != PP_OK) return rv; - Call<PpapiPluginMsg_FileIO_GeneralReply>(BROWSER, - PpapiHostMsg_FileIO_Flush(), - base::Bind(&FileIOResource::OnPluginMsgGeneralComplete, this, - callback)); + Call<PpapiPluginMsg_FileIO_GeneralReply>( + BROWSER, PpapiHostMsg_FileIO_Flush(), + base::BindOnce(&FileIOResource::OnPluginMsgGeneralComplete, this, + callback)); state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE); return PP_OK_COMPLETIONPENDING; @@ -410,10 +408,10 @@ int32_t FileIOResource::RequestOSFileHandle( if (rv != PP_OK) return rv; - Call<PpapiPluginMsg_FileIO_RequestOSFileHandleReply>(BROWSER, - PpapiHostMsg_FileIO_RequestOSFileHandle(), - base::Bind(&FileIOResource::OnPluginMsgRequestOSFileHandleComplete, this, - callback, handle)); + Call<PpapiPluginMsg_FileIO_RequestOSFileHandleReply>( + BROWSER, PpapiHostMsg_FileIO_RequestOSFileHandle(), + base::BindOnce(&FileIOResource::OnPluginMsgRequestOSFileHandleComplete, + this, callback, handle)); state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE); return PP_OK_COMPLETIONPENDING; @@ -525,10 +523,10 @@ int32_t FileIOResource::WriteValidated( void FileIOResource::SetLengthValidated( int64_t length, scoped_refptr<TrackedCallback> callback) { - Call<PpapiPluginMsg_FileIO_GeneralReply>(BROWSER, - PpapiHostMsg_FileIO_SetLength(length), - base::Bind(&FileIOResource::OnPluginMsgGeneralComplete, this, - callback)); + Call<PpapiPluginMsg_FileIO_GeneralReply>( + BROWSER, PpapiHostMsg_FileIO_SetLength(length), + base::BindOnce(&FileIOResource::OnPluginMsgGeneralComplete, this, + callback)); // On the browser side we grow |max_written_offset_| monotonically, due to the // unpredictable ordering of plugin side Write and SetLength calls. Match that diff --git a/chromium/ppapi/proxy/file_ref_resource.cc b/chromium/ppapi/proxy/file_ref_resource.cc index c9296835903..69eb9fe9a39 100644 --- a/chromium/ppapi/proxy/file_ref_resource.cc +++ b/chromium/ppapi/proxy/file_ref_resource.cc @@ -138,9 +138,8 @@ int32_t FileRefResource::MakeDirectory( int32_t make_directory_flags, scoped_refptr<TrackedCallback> callback) { Call<PpapiPluginMsg_FileRef_MakeDirectoryReply>( - BROWSER, - PpapiHostMsg_FileRef_MakeDirectory(make_directory_flags), - base::Bind(&FileRefResource::RunTrackedCallback, this, callback)); + BROWSER, PpapiHostMsg_FileRef_MakeDirectory(make_directory_flags), + base::BindOnce(&FileRefResource::RunTrackedCallback, this, callback)); return PP_OK_COMPLETIONPENDING; } @@ -148,27 +147,23 @@ int32_t FileRefResource::Touch(PP_Time last_access_time, PP_Time last_modified_time, scoped_refptr<TrackedCallback> callback) { Call<PpapiPluginMsg_FileRef_TouchReply>( - BROWSER, - PpapiHostMsg_FileRef_Touch(last_access_time, - last_modified_time), - base::Bind(&FileRefResource::RunTrackedCallback, this, callback)); + BROWSER, PpapiHostMsg_FileRef_Touch(last_access_time, last_modified_time), + base::BindOnce(&FileRefResource::RunTrackedCallback, this, callback)); return PP_OK_COMPLETIONPENDING; } int32_t FileRefResource::Delete(scoped_refptr<TrackedCallback> callback) { Call<PpapiPluginMsg_FileRef_DeleteReply>( - BROWSER, - PpapiHostMsg_FileRef_Delete(), - base::Bind(&FileRefResource::RunTrackedCallback, this, callback)); + BROWSER, PpapiHostMsg_FileRef_Delete(), + base::BindOnce(&FileRefResource::RunTrackedCallback, this, callback)); return PP_OK_COMPLETIONPENDING; } int32_t FileRefResource::Rename(PP_Resource new_file_ref, scoped_refptr<TrackedCallback> callback) { Call<PpapiPluginMsg_FileRef_RenameReply>( - BROWSER, - PpapiHostMsg_FileRef_Rename(new_file_ref), - base::Bind(&FileRefResource::RunTrackedCallback, this, callback)); + BROWSER, PpapiHostMsg_FileRef_Rename(new_file_ref), + base::BindOnce(&FileRefResource::RunTrackedCallback, this, callback)); return PP_OK_COMPLETIONPENDING; } @@ -178,9 +173,8 @@ int32_t FileRefResource::Query(PP_FileInfo* info, return PP_ERROR_BADARGUMENT; Call<PpapiPluginMsg_FileRef_QueryReply>( - BROWSER, - PpapiHostMsg_FileRef_Query(), - base::Bind(&FileRefResource::OnQueryReply, this, info, callback)); + BROWSER, PpapiHostMsg_FileRef_Query(), + base::BindOnce(&FileRefResource::OnQueryReply, this, info, callback)); return PP_OK_COMPLETIONPENDING; } @@ -188,10 +182,9 @@ int32_t FileRefResource::ReadDirectoryEntries( const PP_ArrayOutput& output, scoped_refptr<TrackedCallback> callback) { Call<PpapiPluginMsg_FileRef_ReadDirectoryEntriesReply>( - BROWSER, - PpapiHostMsg_FileRef_ReadDirectoryEntries(), - base::Bind(&FileRefResource::OnDirectoryEntriesReply, - this, output, callback)); + BROWSER, PpapiHostMsg_FileRef_ReadDirectoryEntries(), + base::BindOnce(&FileRefResource::OnDirectoryEntriesReply, this, output, + callback)); return PP_OK_COMPLETIONPENDING; } diff --git a/chromium/ppapi/proxy/file_system_resource.cc b/chromium/ppapi/proxy/file_system_resource.cc index f1e17d213c7..5bb5e2a709d 100644 --- a/chromium/ppapi/proxy/file_system_resource.cc +++ b/chromium/ppapi/proxy/file_system_resource.cc @@ -4,6 +4,7 @@ #include "ppapi/proxy/file_system_resource.h" +#include "base/barrier_closure.h" #include "base/bind.h" #include "base/stl_util.h" #include "ipc/ipc_message.h" @@ -79,16 +80,12 @@ int32_t FileSystemResource::Open(int64_t expected_size, return PP_ERROR_FAILED; called_open_ = true; - Call<PpapiPluginMsg_FileSystem_OpenReply>(RENDERER, - PpapiHostMsg_FileSystem_Open(expected_size), - base::Bind(&FileSystemResource::OpenComplete, - this, - callback)); - Call<PpapiPluginMsg_FileSystem_OpenReply>(BROWSER, - PpapiHostMsg_FileSystem_Open(expected_size), - base::Bind(&FileSystemResource::OpenComplete, - this, - callback)); + Call<PpapiPluginMsg_FileSystem_OpenReply>( + RENDERER, PpapiHostMsg_FileSystem_Open(expected_size), + base::BindOnce(&FileSystemResource::OpenComplete, this, callback)); + Call<PpapiPluginMsg_FileSystem_OpenReply>( + BROWSER, PpapiHostMsg_FileSystem_Open(expected_size), + base::BindOnce(&FileSystemResource::OpenComplete, this, callback)); return PP_OK_COMPLETIONPENDING; } @@ -127,7 +124,7 @@ int64_t FileSystemResource::RequestQuota(int64_t amount, int32_t FileSystemResource::InitIsolatedFileSystem( const std::string& fsid, PP_IsolatedFileSystemType_Private type, - const base::Callback<void(int32_t)>& callback) { + base::OnceCallback<void(int32_t)> callback) { // This call is mutually exclusive with Open() above, so we can reuse the // called_open state. DCHECK(type_ == PP_FILESYSTEMTYPE_ISOLATED); @@ -135,16 +132,18 @@ int32_t FileSystemResource::InitIsolatedFileSystem( return PP_ERROR_FAILED; called_open_ = true; - Call<PpapiPluginMsg_FileSystem_InitIsolatedFileSystemReply>(RENDERER, - PpapiHostMsg_FileSystem_InitIsolatedFileSystem(fsid, type), - base::Bind(&FileSystemResource::InitIsolatedFileSystemComplete, - this, - callback)); - Call<PpapiPluginMsg_FileSystem_InitIsolatedFileSystemReply>(BROWSER, - PpapiHostMsg_FileSystem_InitIsolatedFileSystem(fsid, type), - base::Bind(&FileSystemResource::InitIsolatedFileSystemComplete, - this, - callback)); + base::RepeatingClosure ipc_callback = base::BarrierClosure( + 2, base::BindOnce(&FileSystemResource::InitIsolatedFileSystemComplete, + this, std::move(callback))); + + Call<PpapiPluginMsg_FileSystem_InitIsolatedFileSystemReply>( + RENDERER, PpapiHostMsg_FileSystem_InitIsolatedFileSystem(fsid, type), + base::BindOnce(&FileSystemResource::InitIsolatedFileSystemReply, this, + ipc_callback)); + Call<PpapiPluginMsg_FileSystem_InitIsolatedFileSystemReply>( + BROWSER, PpapiHostMsg_FileSystem_InitIsolatedFileSystem(fsid, type), + base::BindOnce(&FileSystemResource::InitIsolatedFileSystemReply, this, + ipc_callback)); return PP_OK_COMPLETIONPENDING; } @@ -160,16 +159,19 @@ void FileSystemResource::OpenComplete( callback->Run(callback_result_); } -void FileSystemResource::InitIsolatedFileSystemComplete( - const base::Callback<void(int32_t)>& callback, +void FileSystemResource::InitIsolatedFileSystemReply( + base::OnceClosure callback, const ResourceMessageReplyParams& params) { - ++callback_count_; // Prioritize worse result since only one status can be returned. if (params.result() != PP_OK) callback_result_ = params.result(); // Received callback from browser and renderer. - if (callback_count_ == 2) - callback.Run(callback_result_); + std::move(callback).Run(); +} + +void FileSystemResource::InitIsolatedFileSystemComplete( + base::OnceCallback<void(int32_t)> callback) { + std::move(callback).Run(callback_result_); } void FileSystemResource::ReserveQuota(int64_t amount) { @@ -189,10 +191,9 @@ void FileSystemResource::ReserveQuota(int64_t amount) { file_io_api->GetMaxWrittenOffset(), file_io_api->GetAppendModeWriteAmount()); } - Call<PpapiPluginMsg_FileSystem_ReserveQuotaReply>(BROWSER, - PpapiHostMsg_FileSystem_ReserveQuota(amount, file_growths), - base::Bind(&FileSystemResource::ReserveQuotaComplete, - this)); + Call<PpapiPluginMsg_FileSystem_ReserveQuotaReply>( + BROWSER, PpapiHostMsg_FileSystem_ReserveQuota(amount, file_growths), + base::BindOnce(&FileSystemResource::ReserveQuotaComplete, this)); } void FileSystemResource::ReserveQuotaComplete( diff --git a/chromium/ppapi/proxy/file_system_resource.h b/chromium/ppapi/proxy/file_system_resource.h index e25812ab43b..ba53b5616c7 100644 --- a/chromium/ppapi/proxy/file_system_resource.h +++ b/chromium/ppapi/proxy/file_system_resource.h @@ -61,7 +61,8 @@ class PPAPI_PROXY_EXPORT FileSystemResource : public PluginResource, int32_t InitIsolatedFileSystem(const std::string& fsid, PP_IsolatedFileSystemType_Private type, - const base::Callback<void(int32_t)>& callback); + base::OnceCallback<void(int32_t)> callback); + private: struct QuotaRequest { QuotaRequest(int64_t amount, @@ -79,9 +80,10 @@ class PPAPI_PROXY_EXPORT FileSystemResource : public PluginResource, const ResourceMessageReplyParams& params); // Called when the host has responded to our InitIsolatedFileSystem request. + void InitIsolatedFileSystemReply(base::OnceClosure callback, + const ResourceMessageReplyParams& params); void InitIsolatedFileSystemComplete( - const base::Callback<void(int32_t)>& callback, - const ResourceMessageReplyParams& params); + base::OnceCallback<void(int32_t)> callback); void ReserveQuota(int64_t amount); typedef std::map<int32_t, int64_t> OffsetMap; diff --git a/chromium/ppapi/proxy/gamepad_resource.cc b/chromium/ppapi/proxy/gamepad_resource.cc index 6489d4e4ef8..2b72ca52297 100644 --- a/chromium/ppapi/proxy/gamepad_resource.cc +++ b/chromium/ppapi/proxy/gamepad_resource.cc @@ -24,9 +24,8 @@ GamepadResource::GamepadResource(Connection connection, PP_Instance instance) SendCreate(BROWSER, PpapiHostMsg_Gamepad_Create()); Call<PpapiPluginMsg_Gamepad_SendMemory>( - BROWSER, - PpapiHostMsg_Gamepad_RequestMemory(), - base::Bind(&GamepadResource::OnPluginMsgSendMemory, this)); + BROWSER, PpapiHostMsg_Gamepad_RequestMemory(), + base::BindOnce(&GamepadResource::OnPluginMsgSendMemory, this)); } GamepadResource::~GamepadResource() { diff --git a/chromium/ppapi/proxy/graphics_2d_resource.cc b/chromium/ppapi/proxy/graphics_2d_resource.cc index 371ec92c8d1..2f102048183 100644 --- a/chromium/ppapi/proxy/graphics_2d_resource.cc +++ b/chromium/ppapi/proxy/graphics_2d_resource.cc @@ -139,9 +139,8 @@ int32_t Graphics2DResource::Flush(scoped_refptr<TrackedCallback> callback) { current_flush_callback_ = callback; Call<PpapiPluginMsg_Graphics2D_FlushAck>( - RENDERER, - PpapiHostMsg_Graphics2D_Flush(), - base::Bind(&Graphics2DResource::OnPluginMsgFlushACK, this)); + RENDERER, PpapiHostMsg_Graphics2D_Flush(), + base::BindOnce(&Graphics2DResource::OnPluginMsgFlushACK, this)); return PP_OK_COMPLETIONPENDING; } diff --git a/chromium/ppapi/proxy/host_resolver_resource_base.cc b/chromium/ppapi/proxy/host_resolver_resource_base.cc index d552b76a578..80366286541 100644 --- a/chromium/ppapi/proxy/host_resolver_resource_base.cc +++ b/chromium/ppapi/proxy/host_resolver_resource_base.cc @@ -101,10 +101,9 @@ void HostResolverResourceBase::SendResolve( const PP_HostResolver_Private_Hint* hint) { PpapiHostMsg_HostResolver_Resolve msg(host_port, *hint); Call<PpapiPluginMsg_HostResolver_ResolveReply>( - BROWSER, - msg, - base::Bind(&HostResolverResourceBase::OnPluginMsgResolveReply, - base::Unretained(this))); + BROWSER, msg, + base::BindOnce(&HostResolverResourceBase::OnPluginMsgResolveReply, + base::Unretained(this))); } bool HostResolverResourceBase::ResolveInProgress() const { diff --git a/chromium/ppapi/proxy/interface_list.cc b/chromium/ppapi/proxy/interface_list.cc index 0f9265fc810..afbb3abfdc7 100644 --- a/chromium/ppapi/proxy/interface_list.cc +++ b/chromium/ppapi/proxy/interface_list.cc @@ -10,6 +10,7 @@ #include "base/hash/hash.h" #include "base/lazy_instance.h" #include "base/memory/singleton.h" +#include "base/metrics/histogram_functions.h" #include "build/build_config.h" #include "ppapi/c/dev/ppb_audio_input_dev.h" #include "ppapi/c/dev/ppb_audio_output_dev.h" @@ -177,11 +178,11 @@ InterfaceList::InterfaceList() { Permission current_required_permission = PERMISSION_DEV; #include "ppapi/thunk/interfaces_ppb_public_dev.h" } +#if !defined(OS_NACL) { Permission current_required_permission = PERMISSION_PRIVATE; #include "ppapi/thunk/interfaces_ppb_private.h" } -#if !defined(OS_NACL) { Permission current_required_permission = PERMISSION_FLASH; #include "ppapi/thunk/interfaces_ppb_private_flash.h" @@ -331,8 +332,7 @@ const void* InterfaceList::GetInterfaceForPPB(const std::string& name) { if (g_process_global_permissions.Get().HasPermission( found->second->required_permission())) { // Only log interface use once per plugin. - found->second->LogWithUmaOnce( - PluginGlobals::Get()->GetBrowserSender(), name); + found->second->LogWithUmaOnce(name); return found->second->iface(); } return nullptr; @@ -345,8 +345,7 @@ const void* InterfaceList::GetInterfaceForPPP(const std::string& name) const { return found->second->iface(); } -void InterfaceList::InterfaceInfo::LogWithUmaOnce( - IPC::Sender* sender, const std::string& name) { +void InterfaceList::InterfaceInfo::LogWithUmaOnce(const std::string& name) { { base::AutoLock acquire(sent_to_uma_lock_); if (sent_to_uma_) @@ -354,8 +353,7 @@ void InterfaceList::InterfaceInfo::LogWithUmaOnce( sent_to_uma_ = true; } int hash = InterfaceList::HashInterfaceName(name); - PluginGlobals::Get()->GetBrowserSender()->Send( - new PpapiHostMsg_LogInterfaceUsage(hash)); + base::UmaHistogramSparse("Pepper.InterfaceUsed", hash); } void InterfaceList::AddProxy(ApiID id, diff --git a/chromium/ppapi/proxy/interface_list.h b/chromium/ppapi/proxy/interface_list.h index eed12630b85..070c6f375d7 100644 --- a/chromium/ppapi/proxy/interface_list.h +++ b/chromium/ppapi/proxy/interface_list.h @@ -68,7 +68,8 @@ class PPAPI_PROXY_EXPORT InterfaceList { // Call this any time the interface is requested. It will log a UMA count // only the first time. This is safe to call from any thread, regardless of // whether the proxy lock is held. - void LogWithUmaOnce(IPC::Sender* sender, const std::string& name); + void LogWithUmaOnce(const std::string& name); + private: DISALLOW_COPY_AND_ASSIGN(InterfaceInfo); diff --git a/chromium/ppapi/proxy/isolated_file_system_private_resource.cc b/chromium/ppapi/proxy/isolated_file_system_private_resource.cc index 0e8da4a47fa..8653efcc87a 100644 --- a/chromium/ppapi/proxy/isolated_file_system_private_resource.cc +++ b/chromium/ppapi/proxy/isolated_file_system_private_resource.cc @@ -46,10 +46,10 @@ int32_t IsolatedFileSystemPrivateResource::Open( if (!file_system_resource) return PP_ERROR_BADARGUMENT; - Call<PpapiPluginMsg_IsolatedFileSystem_BrowserOpenReply>(BROWSER, - PpapiHostMsg_IsolatedFileSystem_BrowserOpen(type), - base::Bind(&IsolatedFileSystemPrivateResource::OnBrowserOpenComplete, - this, type, file_system_resource, callback)); + Call<PpapiPluginMsg_IsolatedFileSystem_BrowserOpenReply>( + BROWSER, PpapiHostMsg_IsolatedFileSystem_BrowserOpen(type), + base::BindOnce(&IsolatedFileSystemPrivateResource::OnBrowserOpenComplete, + this, type, file_system_resource, callback)); return PP_OK_COMPLETIONPENDING; } @@ -72,8 +72,8 @@ void IsolatedFileSystemPrivateResource::OnBrowserOpenComplete( *file_system_resource = fs->GetReference(); if (*file_system_resource == 0) callback->Run(PP_ERROR_FAILED); - fs->InitIsolatedFileSystem( - fsid, type, base::Bind(&RunTrackedCallback, callback)); + fs->InitIsolatedFileSystem(fsid, type, + base::BindOnce(&RunTrackedCallback, callback)); } } // namespace proxy diff --git a/chromium/ppapi/proxy/media_stream_audio_track_resource.cc b/chromium/ppapi/proxy/media_stream_audio_track_resource.cc index 22610be91f9..865448436b8 100644 --- a/chromium/ppapi/proxy/media_stream_audio_track_resource.cc +++ b/chromium/ppapi/proxy/media_stream_audio_track_resource.cc @@ -80,10 +80,9 @@ int32_t MediaStreamAudioTrackResource::Configure( configure_callback_ = callback; Call<PpapiPluginMsg_MediaStreamAudioTrack_ConfigureReply>( - RENDERER, - PpapiHostMsg_MediaStreamAudioTrack_Configure(attributes), - base::Bind(&MediaStreamAudioTrackResource::OnPluginMsgConfigureReply, - base::Unretained(this)), + RENDERER, PpapiHostMsg_MediaStreamAudioTrack_Configure(attributes), + base::BindOnce(&MediaStreamAudioTrackResource::OnPluginMsgConfigureReply, + base::Unretained(this)), callback); return PP_OK_COMPLETIONPENDING; } diff --git a/chromium/ppapi/proxy/media_stream_video_track_resource.cc b/chromium/ppapi/proxy/media_stream_video_track_resource.cc index 4bc36da4f67..43ba7d4b80d 100644 --- a/chromium/ppapi/proxy/media_stream_video_track_resource.cc +++ b/chromium/ppapi/proxy/media_stream_video_track_resource.cc @@ -91,10 +91,9 @@ int32_t MediaStreamVideoTrackResource::Configure( configure_callback_ = callback; Call<PpapiPluginMsg_MediaStreamVideoTrack_ConfigureReply>( - RENDERER, - PpapiHostMsg_MediaStreamVideoTrack_Configure(attributes), - base::Bind(&MediaStreamVideoTrackResource::OnPluginMsgConfigureReply, - base::Unretained(this)), + RENDERER, PpapiHostMsg_MediaStreamVideoTrack_Configure(attributes), + base::BindOnce(&MediaStreamVideoTrackResource::OnPluginMsgConfigureReply, + base::Unretained(this)), callback); return PP_OK_COMPLETIONPENDING; } diff --git a/chromium/ppapi/proxy/nacl_message_scanner.cc b/chromium/ppapi/proxy/nacl_message_scanner.cc index 9e1e6865ce9..5b48060d2b4 100644 --- a/chromium/ppapi/proxy/nacl_message_scanner.cc +++ b/chromium/ppapi/proxy/nacl_message_scanner.cc @@ -6,6 +6,7 @@ #include <stddef.h> +#include <memory> #include <tuple> #include <utility> #include <vector> @@ -50,7 +51,8 @@ struct ScanningResults { // so when we audit the nested message, we know which resource it is for. PP_Resource pp_resource; // Callback to receive the nested message in a resource message or reply. - base::Callback<void(PP_Resource, const IPC::Message&, SerializedHandle*)> + base::RepeatingCallback< + void(PP_Resource, const IPC::Message&, SerializedHandle*)> nested_msg_callback; }; @@ -105,8 +107,9 @@ void HandleWriter(int* handle_index, void ScanParam(SerializedVar&& var, ScanningResults* results) { // Rewrite the message and then copy any handles. if (results->new_msg) - var.WriteDataToMessage(results->new_msg.get(), - base::Bind(&HandleWriter, &results->handle_index)); + var.WriteDataToMessage( + results->new_msg.get(), + base::BindRepeating(&HandleWriter, &results->handle_index)); for (SerializedHandle* var_handle : var.GetHandles()) results->handles.push_back(std::move(*var_handle)); } @@ -364,9 +367,8 @@ bool NaClMessageScanner::ScanMessage( // that there are no handles, we can cancel the rewriting by clearing the // results.new_msg pointer. ScanningResults results; - results.nested_msg_callback = - base::Bind(&NaClMessageScanner::AuditNestedMessage, - base::Unretained(this)); + results.nested_msg_callback = base::BindRepeating( + &NaClMessageScanner::AuditNestedMessage, base::Unretained(this)); switch (type) { CASE_FOR_MESSAGE(PpapiMsg_PPBAudio_NotifyAudioStreamCreated) CASE_FOR_MESSAGE(PpapiMsg_PPPMessaging_HandleMessage) @@ -426,11 +428,9 @@ void NaClMessageScanner::ScanUntrustedMessage( // If the plugin is under-reporting, rewrite the message with the // trusted value. if (trusted_max_written_offset > file_growth.max_written_offset) { - new_msg_ptr->reset( - new PpapiHostMsg_ResourceCall( - params, - PpapiHostMsg_FileIO_Close( - FileGrowth(trusted_max_written_offset, 0)))); + *new_msg_ptr = std::make_unique<PpapiHostMsg_ResourceCall>( + params, PpapiHostMsg_FileIO_Close( + FileGrowth(trusted_max_written_offset, 0))); } break; } @@ -454,10 +454,8 @@ void NaClMessageScanner::ScanUntrustedMessage( if (increase <= 0) return; if (!it->second->Grow(increase)) { - new_msg_ptr->reset( - new PpapiHostMsg_ResourceCall( - params, - PpapiHostMsg_FileIO_SetLength(-1))); + *new_msg_ptr = std::make_unique<PpapiHostMsg_ResourceCall>( + params, PpapiHostMsg_FileIO_SetLength(-1)); } break; } @@ -488,11 +486,9 @@ void NaClMessageScanner::ScanUntrustedMessage( } } if (audit_failed) { - new_msg_ptr->reset( - new PpapiHostMsg_ResourceCall( - params, - PpapiHostMsg_FileSystem_ReserveQuota( - amount, file_growths))); + *new_msg_ptr = std::make_unique<PpapiHostMsg_ResourceCall>( + params, + PpapiHostMsg_FileSystem_ReserveQuota(amount, file_growths)); } break; } diff --git a/chromium/ppapi/proxy/network_proxy_resource.cc b/chromium/ppapi/proxy/network_proxy_resource.cc index b004130f018..08e4b1985e2 100644 --- a/chromium/ppapi/proxy/network_proxy_resource.cc +++ b/chromium/ppapi/proxy/network_proxy_resource.cc @@ -35,12 +35,10 @@ int32_t NetworkProxyResource::GetProxyForURL( if (!string_url) return PP_ERROR_BADARGUMENT; Call<PpapiPluginMsg_NetworkProxy_GetProxyForURLReply>( - BROWSER, - PpapiHostMsg_NetworkProxy_GetProxyForURL(string_url->value()), - base::Bind(&NetworkProxyResource::OnPluginMsgGetProxyForURLReply, - base::Unretained(this), - base::Unretained(proxy_string), - callback)); + BROWSER, PpapiHostMsg_NetworkProxy_GetProxyForURL(string_url->value()), + base::BindOnce(&NetworkProxyResource::OnPluginMsgGetProxyForURLReply, + base::Unretained(this), base::Unretained(proxy_string), + callback)); return PP_OK_COMPLETIONPENDING; } diff --git a/chromium/ppapi/proxy/pdf_resource_unittest.cc b/chromium/ppapi/proxy/pdf_resource_unittest.cc index e1fc80bfc73..f70149e84f4 100644 --- a/chromium/ppapi/proxy/pdf_resource_unittest.cc +++ b/chromium/ppapi/proxy/pdf_resource_unittest.cc @@ -34,8 +34,8 @@ TEST_F(PDFResourceTest, SearchString) { Connection(&sink(), &sink(), 0), pp_instance()); pdf_resource->SetLocaleForTest("en-US@collation=search"); - base::string16 input; - base::string16 term; + std::u16string input; + std::u16string term; base::UTF8ToUTF16("abcdefabcdef", 12, &input); base::UTF8ToUTF16("bc", 2, &term); diff --git a/chromium/ppapi/proxy/plugin_globals.cc b/chromium/ppapi/proxy/plugin_globals.cc index efe957b2a54..0ebefb957f7 100644 --- a/chromium/ppapi/proxy/plugin_globals.cc +++ b/chromium/ppapi/proxy/plugin_globals.cc @@ -4,6 +4,8 @@ #include "ppapi/proxy/plugin_globals.h" +#include <memory> + #include "base/macros.h" #include "base/message_loop/message_pump_type.h" #include "base/single_thread_task_runner.h" @@ -162,7 +164,7 @@ MessageLoopShared* PluginGlobals::GetCurrentMessageLoop() { base::TaskRunner* PluginGlobals::GetFileTaskRunner() { if (!file_thread_.get()) { - file_thread_.reset(new base::Thread("Plugin::File")); + file_thread_ = std::make_unique<base::Thread>("Plugin::File"); base::Thread::Options options; options.message_pump_type = base::MessagePumpType::IO; file_thread_->StartWithOptions(options); @@ -201,8 +203,8 @@ PP_Resource PluginGlobals::CreateBrowserFont( void PluginGlobals::SetPluginProxyDelegate(PluginProxyDelegate* delegate) { DCHECK(delegate && !plugin_proxy_delegate_); plugin_proxy_delegate_ = delegate; - browser_sender_.reset( - new BrowserSender(plugin_proxy_delegate_->GetBrowserSender())); + browser_sender_ = std::make_unique<BrowserSender>( + plugin_proxy_delegate_->GetBrowserSender()); } void PluginGlobals::ResetPluginProxyDelegate() { diff --git a/chromium/ppapi/proxy/plugin_resource.cc b/chromium/ppapi/proxy/plugin_resource.cc index 7ab0463a5dd..7ebb2c43b61 100644 --- a/chromium/ppapi/proxy/plugin_resource.cc +++ b/chromium/ppapi/proxy/plugin_resource.cc @@ -57,7 +57,8 @@ void PluginResource::OnReplyReceived( if (it == callbacks_.end()) { DCHECK(false) << "Callback does not exist for an expected sequence number."; } else { - scoped_refptr<PluginResourceCallbackBase> callback = it->second; + std::unique_ptr<PluginResourceCallbackBase> callback = + std::move(it->second); callbacks_.erase(it); callback->Run(params, msg); } diff --git a/chromium/ppapi/proxy/plugin_resource.h b/chromium/ppapi/proxy/plugin_resource.h index 7f42c01a90a..19c725f0b8b 100644 --- a/chromium/ppapi/proxy/plugin_resource.h +++ b/chromium/ppapi/proxy/plugin_resource.h @@ -73,15 +73,16 @@ class PPAPI_PROXY_EXPORT PluginResource : public Resource { // corresponding to this resource object and does not expect a reply. void Post(Destination dest, const IPC::Message& msg); - // Like Post() but expects a response. |callback| is a |base::Callback| that - // will be run when a reply message with a sequence number matching that of - // the call is received. |ReplyMsgClass| is the type of the reply message that - // is expected. An example of usage: + // Like Post() but expects a response. |callback| is a |base::OnceCallback| + // that will be run when a reply message with a sequence number matching that + // of the call is received. |ReplyMsgClass| is the type of the reply message + // that is expected. An example of usage: // // Call<PpapiPluginMsg_MyResourceType_MyReplyMessage>( // BROWSER, // PpapiHostMsg_MyResourceType_MyRequestMessage(), - // base::Bind(&MyPluginResource::ReplyHandler, base::Unretained(this))); + // base::BindOnce(&MyPluginResource::ReplyHandler, + // base::Unretained(this))); // // If a reply message to this call is received whose type does not match // |ReplyMsgClass| (for example, in the case of an error), the callback will @@ -99,10 +100,10 @@ class PPAPI_PROXY_EXPORT PluginResource : public Resource { // live forever if we fail to clean up the callback. It is safe to // use base::Unretained(this) or a weak pointer, because this object // will outlive the callback. - template<typename ReplyMsgClass, typename CallbackType> + template <typename ReplyMsgClass, typename CallbackType> int32_t Call(Destination dest, const IPC::Message& msg, - const CallbackType& callback); + CallbackType callback); // Comparing with the previous Call() method, this method takes // |reply_thread_hint| as a hint to determine which thread to handle the reply @@ -115,10 +116,10 @@ class PPAPI_PROXY_EXPORT PluginResource : public Resource { // If handling a reply message will cause a TrackedCallback to be run, it is // recommended to use this version of Call(). It eliminates unnecessary // thread switching and therefore has better performance. - template<typename ReplyMsgClass, typename CallbackType> + template <typename ReplyMsgClass, typename CallbackType> int32_t Call(Destination dest, const IPC::Message& msg, - const CallbackType& callback, + CallbackType callback, scoped_refptr<TrackedCallback> reply_thread_hint); // Calls the browser/renderer with sync messages. Returns the pepper error @@ -177,7 +178,7 @@ class PPAPI_PROXY_EXPORT PluginResource : public Resource { bool sent_create_to_browser_; bool sent_create_to_renderer_; - typedef std::map<int32_t, scoped_refptr<PluginResourceCallbackBase> > + typedef std::map<int32_t, std::unique_ptr<PluginResourceCallbackBase>> CallbackMap; CallbackMap callbacks_; @@ -186,28 +187,29 @@ class PPAPI_PROXY_EXPORT PluginResource : public Resource { DISALLOW_COPY_AND_ASSIGN(PluginResource); }; -template<typename ReplyMsgClass, typename CallbackType> +template <typename ReplyMsgClass, typename CallbackType> int32_t PluginResource::Call(Destination dest, const IPC::Message& msg, - const CallbackType& callback) { - return Call<ReplyMsgClass>(dest, msg, callback, nullptr); + CallbackType callback) { + return Call<ReplyMsgClass>(dest, msg, std::move(callback), nullptr); } -template<typename ReplyMsgClass, typename CallbackType> -int32_t PluginResource::Call( - Destination dest, - const IPC::Message& msg, - const CallbackType& callback, - scoped_refptr<TrackedCallback> reply_thread_hint) { +template <typename ReplyMsgClass, typename CallbackType> +int32_t PluginResource::Call(Destination dest, + const IPC::Message& msg, + CallbackType callback, + scoped_refptr<TrackedCallback> reply_thread_hint) { TRACE_EVENT2("ppapi_proxy", "PluginResource::Call", "Class", IPC_MESSAGE_ID_CLASS(msg.type()), "Line", IPC_MESSAGE_ID_LINE(msg.type())); ResourceMessageCallParams params(pp_resource(), next_sequence_number_++); // Stash the |callback| in |callbacks_| identified by the sequence number of // the call. - scoped_refptr<PluginResourceCallbackBase> plugin_callback( - new PluginResourceCallback<ReplyMsgClass, CallbackType>(callback)); - callbacks_.insert(std::make_pair(params.sequence(), plugin_callback)); + std::unique_ptr<PluginResourceCallbackBase> plugin_callback( + new PluginResourceCallback<ReplyMsgClass, CallbackType>( + std::move(callback))); + callbacks_.insert( + std::make_pair(params.sequence(), std::move(plugin_callback))); params.set_has_callback(); if (resource_reply_thread_registrar_.get()) { diff --git a/chromium/ppapi/proxy/plugin_resource_callback.h b/chromium/ppapi/proxy/plugin_resource_callback.h index 0e67b73bdda..c25ffc8ea89 100644 --- a/chromium/ppapi/proxy/plugin_resource_callback.h +++ b/chromium/ppapi/proxy/plugin_resource_callback.h @@ -5,7 +5,6 @@ #ifndef PPAPI_PROXY_PLUGIN_RESOURCE_CALLBACK_H_ #define PPAPI_PROXY_PLUGIN_RESOURCE_CALLBACK_H_ -#include "base/memory/ref_counted.h" #include "ipc/ipc_message.h" #include "ppapi/proxy/dispatch_reply_message.h" #include "ppapi/proxy/resource_message_params.h" @@ -13,31 +12,30 @@ namespace ppapi { namespace proxy { -// |PluginResourceCallback| wraps a |base::Callback| on the plugin side which -// will be triggered in response to a particular message type being received. -// |MsgClass| is the reply message type that the callback will be called with -// and |CallbackType| is the type of the |base::Callback| that will be called. -class PluginResourceCallbackBase - : public base::RefCounted<PluginResourceCallbackBase> { +// |PluginResourceCallback| wraps a |base::OnceCallback| on the plugin side +// which will be triggered in response to a particular message type being +// received. |MsgClass| is the reply message type that the callback will be +// called with and |CallbackType| is the type of the |base::OnceCallback| that +// will be called. +class PluginResourceCallbackBase { public: + virtual ~PluginResourceCallbackBase() = default; + virtual void Run(const ResourceMessageReplyParams& params, const IPC::Message& msg) = 0; - protected: - friend class base::RefCounted<PluginResourceCallbackBase>; - virtual ~PluginResourceCallbackBase() {} }; template<typename MsgClass, typename CallbackType> class PluginResourceCallback : public PluginResourceCallbackBase { public: - explicit PluginResourceCallback(const CallbackType& callback) - : callback_(callback) {} + explicit PluginResourceCallback(CallbackType callback) + : callback_(std::move(callback)) {} void Run( const ResourceMessageReplyParams& reply_params, const IPC::Message& msg) override { - DispatchResourceReplyOrDefaultParams<MsgClass>(callback_, reply_params, - msg); + DispatchResourceReplyOrDefaultParams<MsgClass>( + std::forward<CallbackType>(callback_), reply_params, msg); } private: diff --git a/chromium/ppapi/proxy/ppapi_messages.h b/chromium/ppapi/proxy/ppapi_messages.h index 4335858b043..845e0429d00 100644 --- a/chromium/ppapi/proxy/ppapi_messages.h +++ b/chromium/ppapi/proxy/ppapi_messages.h @@ -22,7 +22,6 @@ #include "base/files/file_path.h" #include "base/process/process.h" -#include "base/strings/string16.h" #include "build/build_config.h" #include "gpu/command_buffer/common/command_buffer.h" #include "gpu/command_buffer/common/command_buffer_id.h" @@ -633,9 +632,6 @@ IPC_SYNC_MESSAGE_CONTROL1_1(PpapiMsg_SupportsInterface, std::string /* interface_name */, bool /* result */) -IPC_MESSAGE_CONTROL1(PpapiHostMsg_LogInterfaceUsage, - int /* interface_hash */) - #if !defined(OS_NACL) && !defined(NACL_WIN64) // Network state notification from the browser for implementing // PPP_NetworkState_Dev. @@ -1281,12 +1277,6 @@ IPC_MESSAGE_ROUTED2(PpapiMsg_PPPVideoDecoder_NotifyError, PP_VideoDecodeError_Dev /* error */) #endif // !defined(OS_NACL) && !defined(NACL_WIN64) -// PPB_X509Certificate_Private -IPC_SYNC_MESSAGE_CONTROL1_2(PpapiHostMsg_PPBX509Certificate_ParseDER, - std::vector<char> /* der */, - bool /* succeeded */, - ppapi::PPB_X509Certificate_Fields /* result */) - //----------------------------------------------------------------------------- // Resource call/reply messages. // @@ -2120,7 +2110,7 @@ IPC_MESSAGE_CONTROL0(PpapiHostMsg_PDF_SaveAs) // Called by the plugin when its selection changes. IPC_MESSAGE_CONTROL1(PpapiHostMsg_PDF_SetSelectedText, - base::string16 /* selected_text */) + std::u16string /* selected_text */) // Called by the plugin to set the link under the cursor. IPC_MESSAGE_CONTROL1(PpapiHostMsg_PDF_SetLinkUnderCursor, diff --git a/chromium/ppapi/proxy/ppapi_proxy_test.cc b/chromium/ppapi/proxy/ppapi_proxy_test.cc index 87b6bf94b7d..9f9ba4ca602 100644 --- a/chromium/ppapi/proxy/ppapi_proxy_test.cc +++ b/chromium/ppapi/proxy/ppapi_proxy_test.cc @@ -4,6 +4,7 @@ #include "ppapi/proxy/ppapi_proxy_test.h" +#include <memory> #include <tuple> #include "base/bind.h" @@ -171,10 +172,8 @@ void PluginProxyTestHarness::SetUpHarness() { resource_tracker().DidCreateInstance(pp_instance()); - plugin_dispatcher_.reset(new PluginDispatcher( - &MockGetInterface, - PpapiPermissions(), - false)); + plugin_dispatcher_ = std::make_unique<PluginDispatcher>( + &MockGetInterface, PpapiPermissions(), false); plugin_dispatcher_->InitWithTestSink(&sink()); // The plugin proxy delegate is needed for // |PluginProxyDelegate::GetBrowserSender| which is used @@ -199,10 +198,8 @@ void PluginProxyTestHarness::SetUpHarnessWithChannel( resource_tracker().DidCreateInstance(pp_instance()); plugin_delegate_mock_.Init(ipc_task_runner, shutdown_event); - plugin_dispatcher_.reset(new PluginDispatcher( - &MockGetInterface, - PpapiPermissions(), - false)); + plugin_dispatcher_ = std::make_unique<PluginDispatcher>( + &MockGetInterface, PpapiPermissions(), false); plugin_dispatcher_->InitPluginWithChannel(&plugin_delegate_mock_, base::kNullProcessId, channel_handle, @@ -228,11 +225,11 @@ void PluginProxyTestHarness::TearDownHarness() { void PluginProxyTestHarness::CreatePluginGlobals( const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) { if (globals_config_ == PER_THREAD_GLOBALS) { - plugin_globals_.reset(new PluginGlobals(PpapiGlobals::PerThreadForTest(), - ipc_task_runner)); + plugin_globals_ = std::make_unique<PluginGlobals>( + PpapiGlobals::PerThreadForTest(), ipc_task_runner); PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); } else { - plugin_globals_.reset(new PluginGlobals(ipc_task_runner)); + plugin_globals_ = std::make_unique<PluginGlobals>(ipc_task_runner); } } @@ -330,10 +327,10 @@ void PluginProxyMultiThreadTest::RunTest() { main_thread_task_runner_ = PpapiGlobals::Get()->GetMainThreadMessageLoop(); ASSERT_EQ(main_thread_task_runner_.get(), base::ThreadTaskRunnerHandle::Get().get()); - nested_main_thread_message_loop_.reset(new base::RunLoop()); + nested_main_thread_message_loop_ = std::make_unique<base::RunLoop>(); - secondary_thread_.reset(new base::DelegateSimpleThread( - this, "PluginProxyMultiThreadTest")); + secondary_thread_ = std::make_unique<base::DelegateSimpleThread>( + this, "PluginProxyMultiThreadTest"); { ProxyAutoLock auto_lock; @@ -432,10 +429,8 @@ void HostProxyTestHarness::SetUpHarness() { // These must be first since the dispatcher set-up uses them. CreateHostGlobals(); - host_dispatcher_.reset(new HostDispatcher( - pp_module(), - &MockGetInterface, - PpapiPermissions::AllPermissions())); + host_dispatcher_ = std::make_unique<HostDispatcher>( + pp_module(), &MockGetInterface, PpapiPermissions::AllPermissions()); host_dispatcher_->InitWithTestSink(&sink()); HostDispatcher::SetForInstance(pp_instance(), host_dispatcher_.get()); } @@ -450,10 +445,8 @@ void HostProxyTestHarness::SetUpHarnessWithChannel( delegate_mock_.Init(ipc_task_runner, shutdown_event); - host_dispatcher_.reset(new HostDispatcher( - pp_module(), - &MockGetInterface, - PpapiPermissions::AllPermissions())); + host_dispatcher_ = std::make_unique<HostDispatcher>( + pp_module(), &MockGetInterface, PpapiPermissions::AllPermissions()); ppapi::Preferences preferences; host_dispatcher_->InitHostWithChannel(&delegate_mock_, base::kNullProcessId, channel_handle, is_client, preferences, @@ -468,12 +461,13 @@ void HostProxyTestHarness::TearDownHarness() { } void HostProxyTestHarness::CreateHostGlobals() { - disable_locking_.reset(new ProxyLock::LockingDisablerForTest); + disable_locking_ = std::make_unique<ProxyLock::LockingDisablerForTest>(); if (globals_config_ == PER_THREAD_GLOBALS) { - host_globals_.reset(new TestGlobals(PpapiGlobals::PerThreadForTest())); + host_globals_ = + std::make_unique<TestGlobals>(PpapiGlobals::PerThreadForTest()); PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); } else { - host_globals_.reset(new TestGlobals()); + host_globals_ = std::make_unique<TestGlobals>(); } } diff --git a/chromium/ppapi/proxy/ppb_graphics_3d_proxy.cc b/chromium/ppapi/proxy/ppb_graphics_3d_proxy.cc index 5d04041e4e5..8b138ef848a 100644 --- a/chromium/ppapi/proxy/ppb_graphics_3d_proxy.cc +++ b/chromium/ppapi/proxy/ppb_graphics_3d_proxy.cc @@ -4,6 +4,8 @@ #include "ppapi/proxy/ppb_graphics_3d_proxy.h" +#include <memory> + #include "base/numerics/safe_conversions.h" #include "build/build_config.h" #include "gpu/command_buffer/client/gles2_implementation.h" @@ -64,9 +66,9 @@ bool Graphics3D::Init(gpu::gles2::GLES2Implementation* share_gles2, InstanceData* data = dispatcher->GetInstanceData(host_resource().instance()); DCHECK(data); - command_buffer_.reset(new PpapiCommandBufferProxy( + command_buffer_ = std::make_unique<PpapiCommandBufferProxy>( host_resource(), &data->flush_info, dispatcher, capabilities, - std::move(shared_state), command_buffer_id)); + std::move(shared_state), command_buffer_id); return CreateGLES2Impl(share_gles2); } diff --git a/chromium/ppapi/proxy/ppb_message_loop_proxy.cc b/chromium/ppapi/proxy/ppb_message_loop_proxy.cc index 0cf27d91346..9b9b95a4798 100644 --- a/chromium/ppapi/proxy/ppb_message_loop_proxy.cc +++ b/chromium/ppapi/proxy/ppb_message_loop_proxy.cc @@ -6,6 +6,7 @@ #include <stddef.h> +#include <memory> #include <vector> #include "base/bind.h" @@ -91,7 +92,8 @@ int32_t MessageLoopResource::AttachToCurrentThread() { AddRef(); slot->Set(this); - single_thread_task_executor_.reset(new base::SingleThreadTaskExecutor); + single_thread_task_executor_ = + std::make_unique<base::SingleThreadTaskExecutor>(); task_runner_ = base::ThreadTaskRunnerHandle::Get(); // Post all pending work to the task executor. diff --git a/chromium/ppapi/proxy/ppb_x509_certificate_private_proxy.cc b/chromium/ppapi/proxy/ppb_x509_certificate_private_proxy.cc index 8ed49d6f17c..c742d89b674 100644 --- a/chromium/ppapi/proxy/ppb_x509_certificate_private_proxy.cc +++ b/chromium/ppapi/proxy/ppb_x509_certificate_private_proxy.cc @@ -9,6 +9,7 @@ #include "ppapi/proxy/plugin_globals.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/shared_impl/private/ppb_x509_certificate_private_shared.h" +#include "ppapi/shared_impl/private/ppb_x509_util_shared.h" namespace ppapi { namespace proxy { @@ -38,10 +39,8 @@ X509CertificatePrivate::~X509CertificatePrivate() { bool X509CertificatePrivate::ParseDER(const std::vector<char>& der, PPB_X509Certificate_Fields* result) { - bool succeeded = false; - SendToBrowser( - new PpapiHostMsg_PPBX509Certificate_ParseDER(der, &succeeded, result)); - return succeeded; + return PPB_X509Util_Shared::GetCertificateFields(der.data(), der.size(), + result); } void X509CertificatePrivate::SendToBrowser(IPC::Message* msg) { diff --git a/chromium/ppapi/proxy/printing_resource.cc b/chromium/ppapi/proxy/printing_resource.cc index d9be3b74301..bfa4f382dc1 100644 --- a/chromium/ppapi/proxy/printing_resource.cc +++ b/chromium/ppapi/proxy/printing_resource.cc @@ -34,10 +34,9 @@ int32_t PrintingResource::GetDefaultPrintSettings( SendCreate(BROWSER, PpapiHostMsg_Printing_Create()); Call<PpapiPluginMsg_Printing_GetDefaultPrintSettingsReply>( - BROWSER, - PpapiHostMsg_Printing_GetDefaultPrintSettings(), - base::Bind(&PrintingResource::OnPluginMsgGetDefaultPrintSettingsReply, - this, print_settings, callback)); + BROWSER, PpapiHostMsg_Printing_GetDefaultPrintSettings(), + base::BindOnce(&PrintingResource::OnPluginMsgGetDefaultPrintSettingsReply, + this, print_settings, callback)); return PP_OK_COMPLETIONPENDING; } diff --git a/chromium/ppapi/proxy/raw_var_data.cc b/chromium/ppapi/proxy/raw_var_data.cc index ee87df2ee19..d3be699a0c5 100644 --- a/chromium/ppapi/proxy/raw_var_data.cc +++ b/chromium/ppapi/proxy/raw_var_data.cc @@ -4,6 +4,8 @@ #include "ppapi/proxy/raw_var_data.h" +#include <memory> + #include "base/containers/stack.h" #include "base/logging.h" #include "base/memory/ptr_util.h" @@ -685,7 +687,7 @@ bool ResourceRawVarData::Init(const PP_Var& var, PP_Instance /*instance*/) { pp_resource_ = resource_var->GetPPResource(); const IPC::Message* message = resource_var->GetCreationMessage(); if (message) - creation_message_.reset(new IPC::Message(*message)); + creation_message_ = std::make_unique<IPC::Message>(*message); else creation_message_.reset(); pending_renderer_host_id_ = resource_var->GetPendingRendererHostId(); @@ -738,7 +740,7 @@ bool ResourceRawVarData::Read(PP_VarType type, if (!iter->ReadBool(&has_creation_message)) return false; if (has_creation_message) { - creation_message_.reset(new IPC::Message()); + creation_message_ = std::make_unique<IPC::Message>(); if (!IPC::ReadParam(m, iter, creation_message_.get())) return false; } else { diff --git a/chromium/ppapi/proxy/raw_var_data.h b/chromium/ppapi/proxy/raw_var_data.h index 530023fd652..4309ac63ce7 100644 --- a/chromium/ppapi/proxy/raw_var_data.h +++ b/chromium/ppapi/proxy/raw_var_data.h @@ -33,7 +33,7 @@ namespace proxy { class RawVarData; -typedef base::Callback<void(base::Pickle*, const SerializedHandle&)> +typedef base::RepeatingCallback<void(base::Pickle*, const SerializedHandle&)> HandleWriter; // Contains the data associated with a graph of connected PP_Vars. Useful for diff --git a/chromium/ppapi/proxy/raw_var_data_unittest.cc b/chromium/ppapi/proxy/raw_var_data_unittest.cc index 19065b5aaae..daeab007b4c 100644 --- a/chromium/ppapi/proxy/raw_var_data_unittest.cc +++ b/chromium/ppapi/proxy/raw_var_data_unittest.cc @@ -63,7 +63,7 @@ bool WriteAndRead(const PP_Var& var, PP_Var* result) { if (!expected_data) return false; IPC::Message m; - expected_data->Write(&m, base::Bind(&DefaultHandleWriter)); + expected_data->Write(&m, base::BindRepeating(&DefaultHandleWriter)); base::PickleIterator iter(m); std::unique_ptr<RawVarDataGraph> actual_data( RawVarDataGraph::Read(&m, &iter)); diff --git a/chromium/ppapi/proxy/resource_creation_proxy.cc b/chromium/ppapi/proxy/resource_creation_proxy.cc index f216904a3f8..aed077b8162 100644 --- a/chromium/ppapi/proxy/resource_creation_proxy.cc +++ b/chromium/ppapi/proxy/resource_creation_proxy.cc @@ -375,12 +375,12 @@ PP_Resource ResourceCreationProxy::CreateWebSocket(PP_Instance instance) { return (new WebSocketResource(GetConnection(), instance))->GetReference(); } +#if !defined(OS_NACL) PP_Resource ResourceCreationProxy::CreateX509CertificatePrivate( PP_Instance instance) { return PPB_X509Certificate_Private_Proxy::CreateProxyResource(instance); } -#if !defined(OS_NACL) PP_Resource ResourceCreationProxy::CreateAudioInput( PP_Instance instance) { return (new AudioInputResource(GetConnection(), instance))->GetReference(); diff --git a/chromium/ppapi/proxy/resource_creation_proxy.h b/chromium/ppapi/proxy/resource_creation_proxy.h index 4ed2cc97f9a..5f7377327ae 100644 --- a/chromium/ppapi/proxy/resource_creation_proxy.h +++ b/chromium/ppapi/proxy/resource_creation_proxy.h @@ -152,8 +152,8 @@ class ResourceCreationProxy : public InterfaceProxy, PP_Resource CreateVideoEncoder(PP_Instance instance) override; PP_Resource CreateVpnProvider(PP_Instance instance) override; PP_Resource CreateWebSocket(PP_Instance instance) override; - PP_Resource CreateX509CertificatePrivate(PP_Instance instance) override; #if !defined(OS_NACL) + PP_Resource CreateX509CertificatePrivate(PP_Instance instance) override; PP_Resource CreateAudioInput(PP_Instance instance) override; PP_Resource CreateAudioOutput(PP_Instance instance) override; PP_Resource CreateBrowserFont( diff --git a/chromium/ppapi/proxy/serialized_var.cc b/chromium/ppapi/proxy/serialized_var.cc index a28836ef911..41342e9989e 100644 --- a/chromium/ppapi/proxy/serialized_var.cc +++ b/chromium/ppapi/proxy/serialized_var.cc @@ -120,7 +120,7 @@ void SerializedVar::Inner::WriteToMessage(base::Pickle* m) const { RawVarDataGraph::Create(var_, instance_); if (data) { m->WriteBool(true); // Success. - data->Write(m, base::Bind(&DefaultHandleWriter)); + data->Write(m, base::BindRepeating(&DefaultHandleWriter)); } else { m->WriteBool(false); // Failure. } diff --git a/chromium/ppapi/proxy/tcp_server_socket_private_resource.cc b/chromium/ppapi/proxy/tcp_server_socket_private_resource.cc index b23b6dfead5..0f49f957cbb 100644 --- a/chromium/ppapi/proxy/tcp_server_socket_private_resource.cc +++ b/chromium/ppapi/proxy/tcp_server_socket_private_resource.cc @@ -43,10 +43,9 @@ int32_t TCPServerSocketPrivateResource::Listen( // Send the request, the browser will call us back via ListenACK Call<PpapiPluginMsg_TCPServerSocket_ListenReply>( - BROWSER, - PpapiHostMsg_TCPServerSocket_Listen(*addr, backlog), - base::Bind(&TCPServerSocketPrivateResource::OnPluginMsgListenReply, - base::Unretained(this))); + BROWSER, PpapiHostMsg_TCPServerSocket_Listen(*addr, backlog), + base::BindOnce(&TCPServerSocketPrivateResource::OnPluginMsgListenReply, + base::Unretained(this))); return PP_OK_COMPLETIONPENDING; } @@ -63,10 +62,9 @@ int32_t TCPServerSocketPrivateResource::Accept( accept_callback_ = callback; Call<PpapiPluginMsg_TCPServerSocket_AcceptReply>( - BROWSER, - PpapiHostMsg_TCPServerSocket_Accept(), - base::Bind(&TCPServerSocketPrivateResource::OnPluginMsgAcceptReply, - base::Unretained(this), tcp_socket)); + BROWSER, PpapiHostMsg_TCPServerSocket_Accept(), + base::BindOnce(&TCPServerSocketPrivateResource::OnPluginMsgAcceptReply, + base::Unretained(this), tcp_socket)); return PP_OK_COMPLETIONPENDING; } diff --git a/chromium/ppapi/proxy/tcp_socket_resource_base.cc b/chromium/ppapi/proxy/tcp_socket_resource_base.cc index 2297a6e49bb..be3ba247ace 100644 --- a/chromium/ppapi/proxy/tcp_socket_resource_base.cc +++ b/chromium/ppapi/proxy/tcp_socket_resource_base.cc @@ -77,10 +77,9 @@ int32_t TCPSocketResourceBase::BindImpl( state_.SetPendingTransition(TCPSocketState::BIND); Call<PpapiPluginMsg_TCPSocket_BindReply>( - BROWSER, - PpapiHostMsg_TCPSocket_Bind(*addr), - base::Bind(&TCPSocketResourceBase::OnPluginMsgBindReply, - base::Unretained(this)), + BROWSER, PpapiHostMsg_TCPSocket_Bind(*addr), + base::BindOnce(&TCPSocketResourceBase::OnPluginMsgBindReply, + base::Unretained(this)), callback); return PP_OK_COMPLETIONPENDING; } @@ -100,10 +99,9 @@ int32_t TCPSocketResourceBase::ConnectImpl( state_.SetPendingTransition(TCPSocketState::CONNECT); Call<PpapiPluginMsg_TCPSocket_ConnectReply>( - BROWSER, - PpapiHostMsg_TCPSocket_Connect(host, port), - base::Bind(&TCPSocketResourceBase::OnPluginMsgConnectReply, - base::Unretained(this)), + BROWSER, PpapiHostMsg_TCPSocket_Connect(host, port), + base::BindOnce(&TCPSocketResourceBase::OnPluginMsgConnectReply, + base::Unretained(this)), callback); return PP_OK_COMPLETIONPENDING; } @@ -122,10 +120,9 @@ int32_t TCPSocketResourceBase::ConnectWithNetAddressImpl( state_.SetPendingTransition(TCPSocketState::CONNECT); Call<PpapiPluginMsg_TCPSocket_ConnectReply>( - BROWSER, - PpapiHostMsg_TCPSocket_ConnectWithNetAddress(*addr), - base::Bind(&TCPSocketResourceBase::OnPluginMsgConnectReply, - base::Unretained(this)), + BROWSER, PpapiHostMsg_TCPSocket_ConnectWithNetAddress(*addr), + base::BindOnce(&TCPSocketResourceBase::OnPluginMsgConnectReply, + base::Unretained(this)), callback); return PP_OK_COMPLETIONPENDING; } @@ -166,12 +163,11 @@ int32_t TCPSocketResourceBase::SSLHandshakeImpl( Call<PpapiPluginMsg_TCPSocket_SSLHandshakeReply>( BROWSER, - PpapiHostMsg_TCPSocket_SSLHandshake(server_name, - server_port, + PpapiHostMsg_TCPSocket_SSLHandshake(server_name, server_port, trusted_certificates_, untrusted_certificates_), - base::Bind(&TCPSocketResourceBase::OnPluginMsgSSLHandshakeReply, - base::Unretained(this)), + base::BindOnce(&TCPSocketResourceBase::OnPluginMsgSSLHandshakeReply, + base::Unretained(this)), callback); return PP_OK_COMPLETIONPENDING; } @@ -213,10 +209,9 @@ int32_t TCPSocketResourceBase::ReadImpl( read_callback_ = callback; Call<PpapiPluginMsg_TCPSocket_ReadReply>( - BROWSER, - PpapiHostMsg_TCPSocket_Read(bytes_to_read_), - base::Bind(&TCPSocketResourceBase::OnPluginMsgReadReply, - base::Unretained(this)), + BROWSER, PpapiHostMsg_TCPSocket_Read(bytes_to_read_), + base::BindOnce(&TCPSocketResourceBase::OnPluginMsgReadReply, + base::Unretained(this)), callback); return PP_OK_COMPLETIONPENDING; } @@ -242,8 +237,8 @@ int32_t TCPSocketResourceBase::WriteImpl( Call<PpapiPluginMsg_TCPSocket_WriteReply>( BROWSER, PpapiHostMsg_TCPSocket_Write(std::string(buffer, bytes_to_write)), - base::Bind(&TCPSocketResourceBase::OnPluginMsgWriteReply, - base::Unretained(this)), + base::BindOnce(&TCPSocketResourceBase::OnPluginMsgWriteReply, + base::Unretained(this)), callback); return PP_OK_COMPLETIONPENDING; } @@ -262,10 +257,9 @@ int32_t TCPSocketResourceBase::ListenImpl( state_.SetPendingTransition(TCPSocketState::LISTEN); Call<PpapiPluginMsg_TCPSocket_ListenReply>( - BROWSER, - PpapiHostMsg_TCPSocket_Listen(backlog), - base::Bind(&TCPSocketResourceBase::OnPluginMsgListenReply, - base::Unretained(this)), + BROWSER, PpapiHostMsg_TCPSocket_Listen(backlog), + base::BindOnce(&TCPSocketResourceBase::OnPluginMsgListenReply, + base::Unretained(this)), callback); return PP_OK_COMPLETIONPENDING; } @@ -284,10 +278,9 @@ int32_t TCPSocketResourceBase::AcceptImpl( accepted_tcp_socket_ = accepted_tcp_socket; Call<PpapiPluginMsg_TCPSocket_AcceptReply>( - BROWSER, - PpapiHostMsg_TCPSocket_Accept(), - base::Bind(&TCPSocketResourceBase::OnPluginMsgAcceptReply, - base::Unretained(this)), + BROWSER, PpapiHostMsg_TCPSocket_Accept(), + base::BindOnce(&TCPSocketResourceBase::OnPluginMsgAcceptReply, + base::Unretained(this)), callback); return PP_OK_COMPLETIONPENDING; } @@ -348,10 +341,9 @@ int32_t TCPSocketResourceBase::SetOptionImpl( set_option_callbacks_.push(callback); Call<PpapiPluginMsg_TCPSocket_SetOptionReply>( - BROWSER, - PpapiHostMsg_TCPSocket_SetOption(name, option_data), - base::Bind(&TCPSocketResourceBase::OnPluginMsgSetOptionReply, - base::Unretained(this)), + BROWSER, PpapiHostMsg_TCPSocket_SetOption(name, option_data), + base::BindOnce(&TCPSocketResourceBase::OnPluginMsgSetOptionReply, + base::Unretained(this)), callback); return PP_OK_COMPLETIONPENDING; } diff --git a/chromium/ppapi/proxy/udp_socket_filter.cc b/chromium/ppapi/proxy/udp_socket_filter.cc index aef5672a6cb..c5461e54779 100644 --- a/chromium/ppapi/proxy/udp_socket_filter.cc +++ b/chromium/ppapi/proxy/udp_socket_filter.cc @@ -64,12 +64,12 @@ void UDPSocketFilter::AddUDPResource( PP_Instance instance, PP_Resource resource, bool private_api, - const base::Closure& slot_available_callback) { + base::RepeatingClosure slot_available_callback) { ProxyLock::AssertAcquired(); base::AutoLock acquire(lock_); DCHECK(queues_.find(resource) == queues_.end()); - queues_[resource] = std::make_unique<RecvQueue>(instance, private_api, - slot_available_callback); + queues_[resource] = std::make_unique<RecvQueue>( + instance, private_api, std::move(slot_available_callback)); } void UDPSocketFilter::RemoveUDPResource(PP_Resource resource) { @@ -134,15 +134,14 @@ void UDPSocketFilter::OnPluginMsgPushRecvResult( UDPSocketFilter::RecvQueue::RecvQueue( PP_Instance pp_instance, bool private_api, - const base::Closure& slot_available_callback) + base::RepeatingClosure slot_available_callback) : pp_instance_(pp_instance), read_buffer_(nullptr), bytes_to_read_(0), recvfrom_addr_resource_(nullptr), last_recvfrom_addr_(), private_api_(private_api), - slot_available_callback_(slot_available_callback) { -} + slot_available_callback_(std::move(slot_available_callback)) {} UDPSocketFilter::RecvQueue::~RecvQueue() { if (TrackedCallback::IsPending(recvfrom_callback_)) diff --git a/chromium/ppapi/proxy/udp_socket_filter.h b/chromium/ppapi/proxy/udp_socket_filter.h index ab45e8f9d10..e847c893bbb 100644 --- a/chromium/ppapi/proxy/udp_socket_filter.h +++ b/chromium/ppapi/proxy/udp_socket_filter.h @@ -41,7 +41,7 @@ class PPAPI_PROXY_EXPORT UDPSocketFilter : public ResourceMessageFilter { void AddUDPResource(PP_Instance instance, PP_Resource resource, bool private_api, - const base::Closure& slot_available_callback); + base::RepeatingClosure slot_available_callback); void RemoveUDPResource(PP_Resource resource); // Note, the slot_available_callback that was provided to AddUDPResource may // be invoked during the RequestData call; this gives the client the @@ -77,7 +77,7 @@ class PPAPI_PROXY_EXPORT UDPSocketFilter : public ResourceMessageFilter { public: explicit RecvQueue(PP_Instance instance, bool private_api, - const base::Closure& slot_available_callback); + base::RepeatingClosure slot_available_callback); ~RecvQueue(); // Called on the IO thread when data is received. It will post |callback_| @@ -114,7 +114,7 @@ class PPAPI_PROXY_EXPORT UDPSocketFilter : public ResourceMessageFilter { PP_NetAddress_Private last_recvfrom_addr_; bool private_api_; // Callback to invoke when a UDP receive slot is available. - base::Closure slot_available_callback_; + base::RepeatingClosure slot_available_callback_; }; private: diff --git a/chromium/ppapi/proxy/udp_socket_resource_base.cc b/chromium/ppapi/proxy/udp_socket_resource_base.cc index 48f04c27643..5386cfa6d56 100644 --- a/chromium/ppapi/proxy/udp_socket_resource_base.cc +++ b/chromium/ppapi/proxy/udp_socket_resource_base.cc @@ -48,7 +48,8 @@ UDPSocketResourceBase::UDPSocketResourceBase(Connection connection, bound_addr_() { recv_filter_->AddUDPResource( pp_instance(), pp_resource(), private_api, - base::Bind(&UDPSocketResourceBase::SlotBecameAvailable, pp_resource())); + base::BindRepeating(&UDPSocketResourceBase::SlotBecameAvailable, + pp_resource())); if (private_api) SendCreate(BROWSER, PpapiHostMsg_UDPSocket_CreatePrivate()); else @@ -122,11 +123,9 @@ int32_t UDPSocketResourceBase::SetOptionImpl( } Call<PpapiPluginMsg_UDPSocket_SetOptionReply>( - BROWSER, - PpapiHostMsg_UDPSocket_SetOption(name, option_data), - base::Bind(&UDPSocketResourceBase::OnPluginMsgGeneralReply, - base::Unretained(this), - callback), + BROWSER, PpapiHostMsg_UDPSocket_SetOption(name, option_data), + base::BindOnce(&UDPSocketResourceBase::OnPluginMsgGeneralReply, + base::Unretained(this), callback), callback); return PP_OK_COMPLETIONPENDING; } @@ -146,10 +145,9 @@ int32_t UDPSocketResourceBase::BindImpl( // Send the request, the browser will call us back via BindReply. Call<PpapiPluginMsg_UDPSocket_BindReply>( - BROWSER, - PpapiHostMsg_UDPSocket_Bind(*addr), - base::Bind(&UDPSocketResourceBase::OnPluginMsgBindReply, - base::Unretained(this)), + BROWSER, PpapiHostMsg_UDPSocket_Bind(*addr), + base::BindOnce(&UDPSocketResourceBase::OnPluginMsgBindReply, + base::Unretained(this)), callback); return PP_OK_COMPLETIONPENDING; } @@ -204,8 +202,8 @@ int32_t UDPSocketResourceBase::SendToImpl( Call<PpapiPluginMsg_UDPSocket_SendToReply>( BROWSER, PpapiHostMsg_UDPSocket_SendTo(std::string(buffer, num_bytes), *addr), - base::Bind(&UDPSocketResourceBase::OnPluginMsgSendToReply, - base::Unretained(this)), + base::BindOnce(&UDPSocketResourceBase::OnPluginMsgSendToReply, + base::Unretained(this)), callback); return PP_OK_COMPLETIONPENDING; } @@ -234,11 +232,9 @@ int32_t UDPSocketResourceBase::JoinGroupImpl( DCHECK(group); Call<PpapiPluginMsg_UDPSocket_JoinGroupReply>( - BROWSER, - PpapiHostMsg_UDPSocket_JoinGroup(*group), - base::Bind(&UDPSocketResourceBase::OnPluginMsgGeneralReply, - base::Unretained(this), - callback), + BROWSER, PpapiHostMsg_UDPSocket_JoinGroup(*group), + base::BindOnce(&UDPSocketResourceBase::OnPluginMsgGeneralReply, + base::Unretained(this), callback), callback); return PP_OK_COMPLETIONPENDING; } @@ -249,11 +245,9 @@ int32_t UDPSocketResourceBase::LeaveGroupImpl( DCHECK(group); Call<PpapiPluginMsg_UDPSocket_LeaveGroupReply>( - BROWSER, - PpapiHostMsg_UDPSocket_LeaveGroup(*group), - base::Bind(&UDPSocketResourceBase::OnPluginMsgGeneralReply, - base::Unretained(this), - callback), + BROWSER, PpapiHostMsg_UDPSocket_LeaveGroup(*group), + base::BindOnce(&UDPSocketResourceBase::OnPluginMsgGeneralReply, + base::Unretained(this), callback), callback); return PP_OK_COMPLETIONPENDING; } diff --git a/chromium/ppapi/proxy/uma_private_resource.cc b/chromium/ppapi/proxy/uma_private_resource.cc index 3006fe8737e..c8c277b5f79 100644 --- a/chromium/ppapi/proxy/uma_private_resource.cc +++ b/chromium/ppapi/proxy/uma_private_resource.cc @@ -91,10 +91,9 @@ int32_t UMAPrivateResource::IsCrashReportingEnabled( return PP_ERROR_INPROGRESS; pending_callback_ = callback; Call<PpapiPluginMsg_UMA_IsCrashReportingEnabledReply>( - RENDERER, - PpapiHostMsg_UMA_IsCrashReportingEnabled(), - base::Bind(&UMAPrivateResource::OnPluginMsgIsCrashReportingEnabled, - this)); + RENDERER, PpapiHostMsg_UMA_IsCrashReportingEnabled(), + base::BindOnce(&UMAPrivateResource::OnPluginMsgIsCrashReportingEnabled, + this)); return PP_OK_COMPLETIONPENDING; } diff --git a/chromium/ppapi/proxy/video_capture_resource.cc b/chromium/ppapi/proxy/video_capture_resource.cc index 7e586faad90..2879c3b7789 100644 --- a/chromium/ppapi/proxy/video_capture_resource.cc +++ b/chromium/ppapi/proxy/video_capture_resource.cc @@ -93,7 +93,7 @@ int32_t VideoCaptureResource::Open( Call<PpapiPluginMsg_VideoCapture_OpenReply>( RENDERER, PpapiHostMsg_VideoCapture_Open(device_id, requested_info, buffer_count), - base::Bind(&VideoCaptureResource::OnPluginMsgOpenReply, this)); + base::BindOnce(&VideoCaptureResource::OnPluginMsgOpenReply, this)); return PP_OK_COMPLETIONPENDING; } diff --git a/chromium/ppapi/proxy/video_decoder_resource.cc b/chromium/ppapi/proxy/video_decoder_resource.cc index 60020b5a692..264e15d08f7 100644 --- a/chromium/ppapi/proxy/video_decoder_resource.cc +++ b/chromium/ppapi/proxy/video_decoder_resource.cc @@ -164,9 +164,10 @@ int32_t VideoDecoderResource::Initialize( Call<PpapiPluginMsg_VideoDecoder_InitializeReply>( RENDERER, - PpapiHostMsg_VideoDecoder_Initialize( - host_resource, profile, acceleration, min_picture_count), - base::Bind(&VideoDecoderResource::OnPluginMsgInitializeComplete, this)); + PpapiHostMsg_VideoDecoder_Initialize(host_resource, profile, acceleration, + min_picture_count), + base::BindOnce(&VideoDecoderResource::OnPluginMsgInitializeComplete, + this)); return PP_OK_COMPLETIONPENDING; } @@ -252,9 +253,8 @@ int32_t VideoDecoderResource::Decode(uint32_t decode_id, memcpy(shm_buffer->addr, buffer, size); Call<PpapiPluginMsg_VideoDecoder_DecodeReply>( - RENDERER, - PpapiHostMsg_VideoDecoder_Decode(shm_buffer->shm_id, size, uid), - base::Bind(&VideoDecoderResource::OnPluginMsgDecodeComplete, this)); + RENDERER, PpapiHostMsg_VideoDecoder_Decode(shm_buffer->shm_id, size, uid), + base::BindOnce(&VideoDecoderResource::OnPluginMsgDecodeComplete, this)); // If we have another free buffer, or we can still create new buffers, let // the plugin call Decode again. @@ -315,9 +315,8 @@ int32_t VideoDecoderResource::Flush(scoped_refptr<TrackedCallback> callback) { flush_callback_ = callback; Call<PpapiPluginMsg_VideoDecoder_FlushReply>( - RENDERER, - PpapiHostMsg_VideoDecoder_Flush(), - base::Bind(&VideoDecoderResource::OnPluginMsgFlushComplete, this)); + RENDERER, PpapiHostMsg_VideoDecoder_Flush(), + base::BindOnce(&VideoDecoderResource::OnPluginMsgFlushComplete, this)); return PP_OK_COMPLETIONPENDING; } @@ -340,9 +339,8 @@ int32_t VideoDecoderResource::Reset(scoped_refptr<TrackedCallback> callback) { get_picture_callback_->PostAbort(); get_picture_callback_.reset(); Call<PpapiPluginMsg_VideoDecoder_ResetReply>( - RENDERER, - PpapiHostMsg_VideoDecoder_Reset(), - base::Bind(&VideoDecoderResource::OnPluginMsgResetComplete, this)); + RENDERER, PpapiHostMsg_VideoDecoder_Reset(), + base::BindOnce(&VideoDecoderResource::OnPluginMsgResetComplete, this)); return PP_OK_COMPLETIONPENDING; } diff --git a/chromium/ppapi/proxy/video_encoder_resource.cc b/chromium/ppapi/proxy/video_encoder_resource.cc index 04ceb9bf392..12f12dc3bd9 100644 --- a/chromium/ppapi/proxy/video_encoder_resource.cc +++ b/chromium/ppapi/proxy/video_encoder_resource.cc @@ -103,8 +103,9 @@ int32_t VideoEncoderResource::GetSupportedProfiles( get_supported_profiles_callback_ = callback; Call<PpapiPluginMsg_VideoEncoder_GetSupportedProfilesReply>( RENDERER, PpapiHostMsg_VideoEncoder_GetSupportedProfiles(), - base::Bind(&VideoEncoderResource::OnPluginMsgGetSupportedProfilesReply, - this, output, false)); + base::BindOnce( + &VideoEncoderResource::OnPluginMsgGetSupportedProfilesReply, this, + output, false)); return PP_OK_COMPLETIONPENDING; } @@ -117,8 +118,9 @@ int32_t VideoEncoderResource::GetSupportedProfiles0_1( get_supported_profiles_callback_ = callback; Call<PpapiPluginMsg_VideoEncoder_GetSupportedProfilesReply>( RENDERER, PpapiHostMsg_VideoEncoder_GetSupportedProfiles(), - base::Bind(&VideoEncoderResource::OnPluginMsgGetSupportedProfilesReply, - this, output, true)); + base::BindOnce( + &VideoEncoderResource::OnPluginMsgGetSupportedProfilesReply, this, + output, true)); return PP_OK_COMPLETIONPENDING; } @@ -149,10 +151,11 @@ int32_t VideoEncoderResource::Initialize( initialize_callback_ = callback; Call<PpapiPluginMsg_VideoEncoder_InitializeReply>( - RENDERER, PpapiHostMsg_VideoEncoder_Initialize( - input_format, *input_visible_size, output_profile, - initial_bitrate, acceleration), - base::Bind(&VideoEncoderResource::OnPluginMsgInitializeReply, this)); + RENDERER, + PpapiHostMsg_VideoEncoder_Initialize(input_format, *input_visible_size, + output_profile, initial_bitrate, + acceleration), + base::BindOnce(&VideoEncoderResource::OnPluginMsgInitializeReply, this)); return PP_OK_COMPLETIONPENDING; } @@ -172,8 +175,8 @@ int32_t VideoEncoderResource::GetVideoFrame( if (buffer_manager_.number_of_buffers() == 0) { Call<PpapiPluginMsg_VideoEncoder_GetVideoFramesReply>( RENDERER, PpapiHostMsg_VideoEncoder_GetVideoFrames(), - base::Bind(&VideoEncoderResource::OnPluginMsgGetVideoFramesReply, - this)); + base::BindOnce(&VideoEncoderResource::OnPluginMsgGetVideoFramesReply, + this)); } else { TryWriteVideoFrame(); } @@ -201,8 +204,8 @@ int32_t VideoEncoderResource::Encode( RENDERER, PpapiHostMsg_VideoEncoder_Encode(frame_resource->GetBufferIndex(), PP_ToBool(force_keyframe)), - base::Bind(&VideoEncoderResource::OnPluginMsgEncodeReply, this, - video_frame)); + base::BindOnce(&VideoEncoderResource::OnPluginMsgEncodeReply, this, + video_frame)); // Invalidate the frame to prevent the plugin from modifying it. it->second->Invalidate(); diff --git a/chromium/ppapi/proxy/vpn_provider_resource.cc b/chromium/ppapi/proxy/vpn_provider_resource.cc index b6c529e8388..ba0b0c1daeb 100644 --- a/chromium/ppapi/proxy/vpn_provider_resource.cc +++ b/chromium/ppapi/proxy/vpn_provider_resource.cc @@ -66,9 +66,10 @@ int32_t VpnProviderResource::Bind( bind_callback_ = callback; Call<PpapiPluginMsg_VpnProvider_BindReply>( - BROWSER, PpapiHostMsg_VpnProvider_Bind(configuration_id_var->value(), - configuration_name_var->value()), - base::Bind(&VpnProviderResource::OnPluginMsgBindReply, this)); + BROWSER, + PpapiHostMsg_VpnProvider_Bind(configuration_id_var->value(), + configuration_name_var->value()), + base::BindOnce(&VpnProviderResource::OnPluginMsgBindReply, this)); return PP_OK_COMPLETIONPENDING; } @@ -115,7 +116,7 @@ int32_t VpnProviderResource::DoSendPacket(const PP_Var& packet, uint32_t id) { Call<PpapiPluginMsg_VpnProvider_SendPacketReply>( BROWSER, PpapiHostMsg_VpnProvider_SendPacket(packet_size, id), - base::Bind(&VpnProviderResource::OnPluginMsgSendPacketReply, this)); + base::BindOnce(&VpnProviderResource::OnPluginMsgSendPacketReply, this)); return PP_OK; } diff --git a/chromium/ppapi/proxy/websocket_resource.cc b/chromium/ppapi/proxy/websocket_resource.cc index dfc4829aa0d..442a063190a 100644 --- a/chromium/ppapi/proxy/websocket_resource.cc +++ b/chromium/ppapi/proxy/websocket_resource.cc @@ -122,8 +122,9 @@ int32_t WebSocketResource::Connect( state_ = PP_WEBSOCKETREADYSTATE_CONNECTING; SendCreate(RENDERER, PpapiHostMsg_WebSocket_Create()); PpapiHostMsg_WebSocket_Connect msg(url_->value(), protocol_strings); - Call<PpapiPluginMsg_WebSocket_ConnectReply>(RENDERER, msg, - base::Bind(&WebSocketResource::OnPluginMsgConnectReply, this)); + Call<PpapiPluginMsg_WebSocket_ConnectReply>( + RENDERER, msg, + base::BindOnce(&WebSocketResource::OnPluginMsgConnectReply, this)); return PP_OK_COMPLETIONPENDING; } @@ -192,8 +193,9 @@ int32_t WebSocketResource::Close(uint16_t code, state_ = PP_WEBSOCKETREADYSTATE_CLOSING; PpapiHostMsg_WebSocket_Close msg(static_cast<int32_t>(code), reason_string); - Call<PpapiPluginMsg_WebSocket_CloseReply>(RENDERER, msg, - base::Bind(&WebSocketResource::OnPluginMsgCloseReply, this)); + Call<PpapiPluginMsg_WebSocket_CloseReply>( + RENDERER, msg, + base::BindOnce(&WebSocketResource::OnPluginMsgCloseReply, this)); return PP_OK_COMPLETIONPENDING; } diff --git a/chromium/ppapi/shared_impl/BUILD.gn b/chromium/ppapi/shared_impl/BUILD.gn index 39b72b22446..4118baa5c61 100644 --- a/chromium/ppapi/shared_impl/BUILD.gn +++ b/chromium/ppapi/shared_impl/BUILD.gn @@ -136,6 +136,8 @@ component("shared_impl") { "ppb_video_decoder_shared.h", "private/ppb_char_set_shared.cc", "private/ppb_char_set_shared.h", + "private/ppb_x509_util_shared.cc", + "private/ppb_x509_util_shared.h", ] } diff --git a/chromium/ppapi/shared_impl/ppapi_preferences.h b/chromium/ppapi/shared_impl/ppapi_preferences.h index 261216d0b91..df20662ad6c 100644 --- a/chromium/ppapi/shared_impl/ppapi_preferences.h +++ b/chromium/ppapi/shared_impl/ppapi_preferences.h @@ -8,14 +8,13 @@ #include <map> #include <string> -#include "base/strings/string16.h" #include "ppapi/shared_impl/ppapi_shared_export.h" namespace ppapi { struct PPAPI_SHARED_EXPORT Preferences { public: - typedef std::map<std::string, base::string16> ScriptFontFamilyMap; + typedef std::map<std::string, std::u16string> ScriptFontFamilyMap; Preferences(); ~Preferences(); diff --git a/chromium/ppapi/shared_impl/ppb_audio_shared.cc b/chromium/ppapi/shared_impl/ppb_audio_shared.cc index 9fc5175e758..78e64a89408 100644 --- a/chromium/ppapi/shared_impl/ppb_audio_shared.cc +++ b/chromium/ppapi/shared_impl/ppb_audio_shared.cc @@ -4,6 +4,7 @@ #include "ppapi/shared_impl/ppb_audio_shared.h" +#include <memory> #include <utility> #include "base/bind.h" @@ -101,7 +102,8 @@ void PPB_Audio_Shared::SetStreamInfo( base::SyncSocket::ScopedHandle socket_handle, PP_AudioSampleRate sample_rate, int sample_frame_count) { - socket_.reset(new base::CancelableSyncSocket(std::move(socket_handle))); + socket_ = + std::make_unique<base::CancelableSyncSocket>(std::move(socket_handle)); shared_memory_size_ = media::ComputeAudioOutputBufferSize( kAudioOutputChannels, sample_frame_count); DCHECK_GE(shared_memory_region.GetSize(), shared_memory_size_); @@ -155,8 +157,8 @@ void PPB_Audio_Shared::StartThread() { nacl_thread_active_ = true; } else { DCHECK(!audio_thread_.get()); - audio_thread_.reset( - new base::DelegateSimpleThread(this, "plugin_audio_thread")); + audio_thread_ = std::make_unique<base::DelegateSimpleThread>( + this, "plugin_audio_thread"); audio_thread_->Start(); } } diff --git a/chromium/ppapi/shared_impl/private/DEPS b/chromium/ppapi/shared_impl/private/DEPS index 6a2f02e2180..9af98f9abae 100644 --- a/chromium/ppapi/shared_impl/private/DEPS +++ b/chromium/ppapi/shared_impl/private/DEPS @@ -1,3 +1,4 @@ include_rules = [ "+net/base", + "+net/cert", ] diff --git a/chromium/ppapi/shared_impl/private/ppb_char_set_shared.cc b/chromium/ppapi/shared_impl/private/ppb_char_set_shared.cc index e203c6f9c62..ec96febeb3c 100644 --- a/chromium/ppapi/shared_impl/private/ppb_char_set_shared.cc +++ b/chromium/ppapi/shared_impl/private/ppb_char_set_shared.cc @@ -222,7 +222,7 @@ PP_Bool PPB_CharSet_Shared::CharSetToUTF16( // We can convert this call to the implementation in base to avoid code // duplication, although this does introduce an extra copy of the data. - base::string16 output; + std::u16string output; if (!base::CodepageToUTF16(std::string(input, input_len), input_char_set, base_on_error, &output)) { *output_utf16_length = 0; diff --git a/chromium/ppapi/shared_impl/private/ppb_x509_util_shared.cc b/chromium/ppapi/shared_impl/private/ppb_x509_util_shared.cc new file mode 100644 index 00000000000..1ae372c4550 --- /dev/null +++ b/chromium/ppapi/shared_impl/private/ppb_x509_util_shared.cc @@ -0,0 +1,78 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/shared_impl/private/ppb_x509_util_shared.h" + +#include "base/strings/string_util.h" +#include "net/cert/x509_certificate.h" +#include "net/cert/x509_util.h" + +namespace ppapi { + +bool PPB_X509Util_Shared::GetCertificateFields( + const net::X509Certificate& cert, + ppapi::PPB_X509Certificate_Fields* fields) { + const net::CertPrincipal& issuer = cert.issuer(); + fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_COMMON_NAME, + std::make_unique<base::Value>(issuer.common_name)); + fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_LOCALITY_NAME, + std::make_unique<base::Value>(issuer.locality_name)); + fields->SetField( + PP_X509CERTIFICATE_PRIVATE_ISSUER_STATE_OR_PROVINCE_NAME, + std::make_unique<base::Value>(issuer.state_or_province_name)); + fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_COUNTRY_NAME, + std::make_unique<base::Value>(issuer.country_name)); + fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_NAME, + std::make_unique<base::Value>( + base::JoinString(issuer.organization_names, "\n"))); + fields->SetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_ORGANIZATION_UNIT_NAME, + std::make_unique<base::Value>( + base::JoinString(issuer.organization_unit_names, "\n"))); + + const net::CertPrincipal& subject = cert.subject(); + fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_COMMON_NAME, + std::make_unique<base::Value>(subject.common_name)); + fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_LOCALITY_NAME, + std::make_unique<base::Value>(subject.locality_name)); + fields->SetField( + PP_X509CERTIFICATE_PRIVATE_SUBJECT_STATE_OR_PROVINCE_NAME, + std::make_unique<base::Value>(subject.state_or_province_name)); + fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_COUNTRY_NAME, + std::make_unique<base::Value>(subject.country_name)); + fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_NAME, + std::make_unique<base::Value>( + base::JoinString(subject.organization_names, "\n"))); + fields->SetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_ORGANIZATION_UNIT_NAME, + std::make_unique<base::Value>(base::JoinString( + subject.organization_unit_names, "\n"))); + + fields->SetField(PP_X509CERTIFICATE_PRIVATE_SERIAL_NUMBER, + base::Value::ToUniquePtrValue(base::Value( + base::as_bytes(base::make_span(cert.serial_number()))))); + fields->SetField( + PP_X509CERTIFICATE_PRIVATE_VALIDITY_NOT_BEFORE, + std::make_unique<base::Value>(cert.valid_start().ToDoubleT())); + fields->SetField( + PP_X509CERTIFICATE_PRIVATE_VALIDITY_NOT_AFTER, + std::make_unique<base::Value>(cert.valid_expiry().ToDoubleT())); + base::StringPiece cert_der = + net::x509_util::CryptoBufferAsStringPiece(cert.cert_buffer()); + fields->SetField(PP_X509CERTIFICATE_PRIVATE_RAW, + base::Value::ToUniquePtrValue( + base::Value(base::as_bytes(base::make_span(cert_der))))); + return true; +} + +bool PPB_X509Util_Shared::GetCertificateFields( + const char* der, + size_t length, + ppapi::PPB_X509Certificate_Fields* fields) { + scoped_refptr<net::X509Certificate> cert = + net::X509Certificate::CreateFromBytes(der, length); + if (!cert) + return false; + return GetCertificateFields(*cert, fields); +} + +} // namespace ppapi diff --git a/chromium/ppapi/shared_impl/private/ppb_x509_util_shared.h b/chromium/ppapi/shared_impl/private/ppb_x509_util_shared.h new file mode 100644 index 00000000000..42c61839147 --- /dev/null +++ b/chromium/ppapi/shared_impl/private/ppb_x509_util_shared.h @@ -0,0 +1,34 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_SHARED_IMPL_PRIVATE_PPB_X509_UTIL_SHARED_H_ +#define PPAPI_SHARED_IMPL_PRIVATE_PPB_X509_UTIL_SHARED_H_ + +#include "ppapi/shared_impl/private/ppb_x509_certificate_private_shared.h" + +namespace net { +class X509Certificate; +} + +namespace ppapi { + +// Contains X509 parsing utilities that are shared between the proxy and the +// browser. +class PPAPI_SHARED_EXPORT PPB_X509Util_Shared { + public: + // Extracts the certificate field data from a net::X509Certificate into + // PPB_X509Certificate_Fields. + static bool GetCertificateFields(const net::X509Certificate& cert, + ppapi::PPB_X509Certificate_Fields* fields); + + // Extracts the certificate field data from the DER representation of a + // certificate into PPB_X509Certificate_Fields. + static bool GetCertificateFields(const char* der, + size_t length, + ppapi::PPB_X509Certificate_Fields* fields); +}; + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_PRIVATE_PPB_X509_UTIL_SHARED_H_ diff --git a/chromium/ppapi/shared_impl/resource_tracker.cc b/chromium/ppapi/shared_impl/resource_tracker.cc index c8b127c65db..989cb8d8d66 100644 --- a/chromium/ppapi/shared_impl/resource_tracker.cc +++ b/chromium/ppapi/shared_impl/resource_tracker.cc @@ -4,6 +4,8 @@ #include "ppapi/shared_impl/resource_tracker.h" +#include <memory> + #include "base/bind.h" #include "base/compiler_specific.h" #include "base/logging.h" @@ -19,7 +21,7 @@ namespace ppapi { ResourceTracker::ResourceTracker(ThreadMode thread_mode) : last_resource_value_(0) { if (thread_mode == SINGLE_THREADED) - thread_checker_.reset(new base::ThreadChecker); + thread_checker_ = std::make_unique<base::ThreadChecker>(); } ResourceTracker::~ResourceTracker() {} diff --git a/chromium/ppapi/shared_impl/tracked_callback.cc b/chromium/ppapi/shared_impl/tracked_callback.cc index 91e4c5a9ba2..9984dbbf663 100644 --- a/chromium/ppapi/shared_impl/tracked_callback.cc +++ b/chromium/ppapi/shared_impl/tracked_callback.cc @@ -4,6 +4,8 @@ #include "ppapi/shared_impl/tracked_callback.h" +#include <memory> + #include "base/bind.h" #include "base/check.h" #include "base/compiler_specific.h" @@ -74,7 +76,8 @@ TrackedCallback::TrackedCallback(Resource* resource, if (is_blocking()) { // This is a blocking completion callback, so we will need a condition // variable for blocking & signalling the calling thread. - operation_completed_condvar_.reset(new base::ConditionVariable(&lock_)); + operation_completed_condvar_ = + std::make_unique<base::ConditionVariable>(&lock_); } else { // It's a non-blocking callback, so we should have a MessageLoopResource // to dispatch to. Note that we don't error check here, though. Later, diff --git a/chromium/ppapi/shared_impl/var_tracker.cc b/chromium/ppapi/shared_impl/var_tracker.cc index 40156b4895f..aa9e6be11b6 100644 --- a/chromium/ppapi/shared_impl/var_tracker.cc +++ b/chromium/ppapi/shared_impl/var_tracker.cc @@ -7,6 +7,7 @@ #include <string.h> #include <limits> +#include <memory> #include "base/logging.h" #include "base/memory/unsafe_shared_memory_region.h" @@ -26,7 +27,7 @@ VarTracker::VarInfo::VarInfo(Var* v, int input_ref_count) VarTracker::VarTracker(ThreadMode thread_mode) : last_var_id_(0) { if (thread_mode == SINGLE_THREADED) - thread_checker_.reset(new base::ThreadChecker); + thread_checker_ = std::make_unique<base::ThreadChecker>(); } VarTracker::~VarTracker() {} diff --git a/chromium/ppapi/thunk/BUILD.gn b/chromium/ppapi/thunk/BUILD.gn index ae80cd126b9..b353f806560 100644 --- a/chromium/ppapi/thunk/BUILD.gn +++ b/chromium/ppapi/thunk/BUILD.gn @@ -132,8 +132,6 @@ source_set("thunk") { "ppb_vpn_provider_thunk.cc", "ppb_websocket_api.h", "ppb_websocket_thunk.cc", - "ppb_x509_certificate_private_api.h", - "ppb_x509_certificate_private_thunk.cc", "resource_creation_api.h", "thunk.h", ] @@ -151,6 +149,8 @@ source_set("thunk") { "ppb_url_util_thunk.cc", "ppb_video_capture_thunk.cc", "ppb_video_decoder_dev_thunk.cc", + "ppb_x509_certificate_private_api.h", + "ppb_x509_certificate_private_thunk.cc", ] } diff --git a/chromium/ppapi/thunk/interfaces_ppb_private.h b/chromium/ppapi/thunk/interfaces_ppb_private.h index fe2b67d8176..49827d5c4ef 100644 --- a/chromium/ppapi/thunk/interfaces_ppb_private.h +++ b/chromium/ppapi/thunk/interfaces_ppb_private.h @@ -7,16 +7,16 @@ // no-include-guard-because-multiply-included +#include "build/build_config.h" #include "ppapi/thunk/interfaces_preamble.h" // See interfaces_ppb_private_no_permissions.h for other private interfaces. PROXIED_API(PPB_X509Certificate_Private) +#if !defined(OS_NACL) PROXIED_IFACE(PPB_X509CERTIFICATE_PRIVATE_INTERFACE_0_1, PPB_X509Certificate_Private_0_1) - -#if !defined(OS_NACL) PROXIED_IFACE(PPB_BROWSERFONT_TRUSTED_INTERFACE_1_0, PPB_BrowserFont_Trusted_1_0) PROXIED_IFACE(PPB_CHARSET_TRUSTED_INTERFACE_1_0, diff --git a/chromium/ppapi/thunk/resource_creation_api.h b/chromium/ppapi/thunk/resource_creation_api.h index 3c53a8d0683..eeef46e59e4 100644 --- a/chromium/ppapi/thunk/resource_creation_api.h +++ b/chromium/ppapi/thunk/resource_creation_api.h @@ -175,8 +175,8 @@ class ResourceCreationAPI { virtual PP_Resource CreateVideoEncoder(PP_Instance instance) = 0; virtual PP_Resource CreateVpnProvider(PP_Instance instance) = 0; virtual PP_Resource CreateWebSocket(PP_Instance instance) = 0; - virtual PP_Resource CreateX509CertificatePrivate(PP_Instance instance) = 0; #if !defined(OS_NACL) + virtual PP_Resource CreateX509CertificatePrivate(PP_Instance instance) = 0; virtual PP_Resource CreateAudioInput(PP_Instance instance) = 0; virtual PP_Resource CreateAudioOutput(PP_Instance instance) = 0; virtual PP_Resource CreateBrowserFont( |