diff options
Diffstat (limited to 'chromium/content/renderer/pepper')
41 files changed, 163 insertions, 771 deletions
diff --git a/chromium/content/renderer/pepper/content_renderer_pepper_host_factory.cc b/chromium/content/renderer/pepper/content_renderer_pepper_host_factory.cc index 2c396ffb834..401e48c605d 100644 --- a/chromium/content/renderer/pepper/content_renderer_pepper_host_factory.cc +++ b/chromium/content/renderer/pepper/content_renderer_pepper_host_factory.cc @@ -27,9 +27,7 @@ #include "content/renderer/pepper/pepper_url_loader_host.h" #include "content/renderer/pepper/pepper_video_capture_host.h" #include "content/renderer/pepper/pepper_video_decoder_host.h" -#include "content/renderer/pepper/pepper_video_destination_host.h" #include "content/renderer/pepper/pepper_video_encoder_host.h" -#include "content/renderer/pepper/pepper_video_source_host.h" #include "content/renderer/pepper/pepper_websocket_host.h" #include "content/renderer/pepper/ppb_image_data_impl.h" #include "content/renderer/pepper/renderer_ppapi_host_impl.h" @@ -55,18 +53,6 @@ namespace content { namespace { -bool CanUseMediaStreamAPI(const RendererPpapiHost* host, PP_Instance instance) { - blink::WebPluginContainer* container = - host->GetContainerForInstance(instance); - if (!container) - return false; - - GURL document_url = container->GetDocument().Url(); - ContentRendererClient* content_renderer_client = - GetContentClient()->renderer(); - return content_renderer_client->AllowPepperMediaStreamAPI(document_url); -} - static bool CanUseCameraDeviceAPI(const RendererPpapiHost* host, PP_Instance instance) { blink::WebPluginContainer* container = @@ -187,19 +173,6 @@ ContentRendererPepperHostFactory::CreateResourceHost( case PpapiHostMsg_MediaStreamVideoTrack_Create::ID: return std::make_unique<PepperMediaStreamVideoTrackHost>(host_, instance, resource); - // These private MediaStream interfaces are exposed as if they were public - // so they can be used by NaCl plugins. However, they are available only - // for whitelisted apps. - case PpapiHostMsg_VideoDestination_Create::ID: - if (CanUseMediaStreamAPI(host_, instance)) - return std::make_unique<PepperVideoDestinationHost>(host_, instance, - resource); - return nullptr; - case PpapiHostMsg_VideoSource_Create::ID: - if (CanUseMediaStreamAPI(host_, instance)) - return std::make_unique<PepperVideoSourceHost>(host_, instance, - resource); - return nullptr; } // Dev interfaces. diff --git a/chromium/content/renderer/pepper/host_globals.cc b/chromium/content/renderer/pepper/host_globals.cc index 5ef70b58473..4a43be09fa7 100644 --- a/chromium/content/renderer/pepper/host_globals.cc +++ b/chromium/content/renderer/pepper/host_globals.cc @@ -43,9 +43,7 @@ typedef std::set<WebPluginContainer*> ContainerSet; // Adds all WebPluginContainers associated with the given module to the set. void GetAllContainersForModule(PluginModule* module, ContainerSet* containers) { const PluginModule::PluginInstanceSet& instances = module->GetAllInstances(); - for (PluginModule::PluginInstanceSet::const_iterator i = instances.begin(); - i != instances.end(); - ++i) { + for (auto i = instances.begin(); i != instances.end(); ++i) { WebPluginContainer* container = (*i)->container(); // If "Delete" is called on an instance, the instance sets its container to // NULL, but the instance may actually outlive its container. Callers of @@ -107,7 +105,7 @@ ppapi::VarTracker* HostGlobals::GetVarTracker() { return &host_var_tracker_; } ppapi::CallbackTracker* HostGlobals::GetCallbackTrackerForInstance( PP_Instance instance) { - InstanceMap::iterator found = instance_map_.find(instance); + auto found = instance_map_.find(instance); if (found == instance_map_.end()) return nullptr; return found->second->module()->GetCallbackTracker().get(); @@ -182,8 +180,7 @@ void HostGlobals::BroadcastLogWithSource(PP_Module pp_module, } WebConsoleMessage message = MakeLogMessage(level, source, value); - for (ContainerSet::iterator i = containers.begin(); i != containers.end(); - ++i) { + for (auto i = containers.begin(); i != containers.end(); ++i) { WebLocalFrame* frame = (*i)->GetDocument().GetFrame(); if (frame) frame->AddMessageToConsole(message); @@ -222,7 +219,7 @@ PP_Module HostGlobals::AddModule(PluginModule* module) { void HostGlobals::ModuleDeleted(PP_Module module) { DLOG_IF(ERROR, !CheckIdType(module, ppapi::PP_ID_TYPE_MODULE)) << module << " is not a PP_Module."; - ModuleMap::iterator found = module_map_.find(module); + auto found = module_map_.find(module); if (found == module_map_.end()) { NOTREACHED(); return; @@ -233,7 +230,7 @@ void HostGlobals::ModuleDeleted(PP_Module module) { PluginModule* HostGlobals::GetModule(PP_Module module) { DLOG_IF(ERROR, !CheckIdType(module, ppapi::PP_ID_TYPE_MODULE)) << module << " is not a PP_Module."; - ModuleMap::iterator found = module_map_.find(module); + auto found = module_map_.find(module); if (found == module_map_.end()) return nullptr; return found->second; @@ -274,7 +271,7 @@ void HostGlobals::InstanceCrashed(PP_Instance instance) { PepperPluginInstanceImpl* HostGlobals::GetInstance(PP_Instance instance) { DLOG_IF(ERROR, !CheckIdType(instance, ppapi::PP_ID_TYPE_INSTANCE)) << instance << " is not a PP_Instance."; - InstanceMap::iterator found = instance_map_.find(instance); + auto found = instance_map_.find(instance); if (found == instance_map_.end()) return nullptr; return found->second; diff --git a/chromium/content/renderer/pepper/host_var_tracker.cc b/chromium/content/renderer/pepper/host_var_tracker.cc index b058576d61e..0424b3d736c 100644 --- a/chromium/content/renderer/pepper/host_var_tracker.cc +++ b/chromium/content/renderer/pepper/host_var_tracker.cc @@ -63,8 +63,8 @@ void HostVarTracker::AddV8ObjectVar(V8ObjectVar* object_var) { void HostVarTracker::RemoveV8ObjectVar(V8ObjectVar* object_var) { CheckThreadingPreconditions(); v8::HandleScope handle_scope(object_var->instance()->GetIsolate()); - ObjectMap::iterator it = GetForV8Object( - object_var->instance()->pp_instance(), object_var->GetHandle()); + auto it = GetForV8Object(object_var->instance()->pp_instance(), + object_var->GetHandle()); DCHECK(it != object_map_.end()); object_map_.erase(it); } @@ -120,7 +120,7 @@ void HostVarTracker::DidDeleteInstance(PP_Instance pp_instance) { // Use a key with an empty handle to find the v8 object var in the map with // the given instance and the lowest hash. V8ObjectVarKey key(pp_instance, v8::Local<v8::Object>()); - ObjectMap::iterator it = object_map_.lower_bound(key); + auto it = object_map_.lower_bound(key); while (it != object_map_.end() && it->first.instance == pp_instance) { ForceReleaseV8Object(it->second); object_map_.erase(it++); @@ -129,7 +129,7 @@ void HostVarTracker::DidDeleteInstance(PP_Instance pp_instance) { void HostVarTracker::ForceReleaseV8Object(ppapi::V8ObjectVar* object_var) { object_var->InstanceDeleted(); - VarMap::iterator iter = live_vars_.find(object_var->GetExistingVarID()); + auto iter = live_vars_.find(object_var->GetExistingVarID()); if (iter == live_vars_.end()) { NOTREACHED(); return; @@ -145,7 +145,7 @@ HostVarTracker::ObjectMap::iterator HostVarTracker::GetForV8Object( std::pair<ObjectMap::iterator, ObjectMap::iterator> range = object_map_.equal_range(V8ObjectVarKey(instance, object)); - for (ObjectMap::iterator it = range.first; it != range.second; ++it) { + for (auto it = range.first; it != range.second; ++it) { if (object == it->second->GetHandle()) return it; } @@ -174,7 +174,7 @@ bool HostVarTracker::StopTrackingSharedMemoryHandle( PP_Instance instance, base::SharedMemoryHandle* handle, uint32_t* size_in_bytes) { - SharedMemoryMap::iterator it = shared_memory_map_.find(id); + auto it = shared_memory_map_.find(id); if (it == shared_memory_map_.end()) return false; if (it->second.instance != instance) diff --git a/chromium/content/renderer/pepper/message_channel.cc b/chromium/content/renderer/pepper/message_channel.cc index 219a0c76744..738d86028ba 100644 --- a/chromium/content/renderer/pepper/message_channel.cc +++ b/chromium/content/renderer/pepper/message_channel.cc @@ -211,13 +211,17 @@ v8::Local<v8::Value> MessageChannel::GetNamedProperty( PepperTryCatchV8 try_catch(instance_, &var_converter_, isolate); if (identifier == kPostMessage) { + v8::Local<v8::Context> context = isolate->GetCurrentContext(); return GetFunctionTemplate(isolate, identifier, &MessageChannel::PostMessageToNative) - ->GetFunction(); + ->GetFunction(context) + .ToLocalChecked(); } else if (identifier == kPostMessageAndAwaitResponse) { + v8::Local<v8::Context> context = isolate->GetCurrentContext(); return GetFunctionTemplate(isolate, identifier, &MessageChannel::PostBlockingMessageToNative) - ->GetFunction(); + ->GetFunction(context) + .ToLocalChecked(); } std::map<std::string, ScopedPPVar>::const_iterator it = diff --git a/chromium/content/renderer/pepper/pepper_broker.cc b/chromium/content/renderer/pepper/pepper_broker.cc index 1f5cd9fd35a..4d75b47da77 100644 --- a/chromium/content/renderer/pepper/pepper_broker.cc +++ b/chromium/content/renderer/pepper/pepper_broker.cc @@ -156,8 +156,7 @@ void PepperBroker::OnBrokerChannelConnected( dispatcher_.reset(dispatcher.release()); // Process all pending channel requests from the plugins. - for (ClientMap::iterator i = pending_connects_.begin(); - i != pending_connects_.end();) { + for (auto i = pending_connects_.begin(); i != pending_connects_.end();) { base::WeakPtr<PPB_Broker_Impl>& weak_ptr = i->second.client; if (!i->second.is_authorized) { ++i; @@ -173,7 +172,7 @@ void PepperBroker::OnBrokerChannelConnected( void PepperBroker::OnBrokerPermissionResult(PPB_Broker_Impl* client, bool result) { - ClientMap::iterator entry = pending_connects_.find(client); + auto entry = pending_connects_.find(client); if (entry == pending_connects_.end()) return; @@ -213,9 +212,7 @@ PepperBroker::PendingConnection::~PendingConnection() {} void PepperBroker::ReportFailureToClients(int error_code) { DCHECK_NE(PP_OK, error_code); - for (ClientMap::iterator i = pending_connects_.begin(); - i != pending_connects_.end(); - ++i) { + for (auto i = pending_connects_.begin(); i != pending_connects_.end(); ++i) { base::WeakPtr<PPB_Broker_Impl>& weak_ptr = i->second.client; if (weak_ptr.get()) { weak_ptr->BrokerConnected( diff --git a/chromium/content/renderer/pepper/pepper_browser_connection.cc b/chromium/content/renderer/pepper/pepper_browser_connection.cc index 19ba1cc7a35..71b3e6c01a9 100644 --- a/chromium/content/renderer/pepper/pepper_browser_connection.cc +++ b/chromium/content/renderer/pepper/pepper_browser_connection.cc @@ -74,8 +74,7 @@ void PepperBrowserConnection::OnMsgCreateResourceHostsFromHostReply( const std::vector<int>& pending_resource_host_ids) { // Check that the message is destined for the plugin this object is associated // with. - std::map<int32_t, PendingResourceIDCallback>::iterator it = - pending_create_map_.find(sequence_number); + auto it = pending_create_map_.find(sequence_number); if (it != pending_create_map_.end()) { it->second.Run(pending_resource_host_ids); pending_create_map_.erase(it); diff --git a/chromium/content/renderer/pepper/pepper_device_enumeration_host_helper_unittest.cc b/chromium/content/renderer/pepper/pepper_device_enumeration_host_helper_unittest.cc index 6c2d52e1309..8e20a934c21 100644 --- a/chromium/content/renderer/pepper/pepper_device_enumeration_host_helper_unittest.cc +++ b/chromium/content/renderer/pepper/pepper_device_enumeration_host_helper_unittest.cc @@ -11,8 +11,8 @@ #include "base/logging.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop.h" #include "base/run_loop.h" +#include "base/test/scoped_task_environment.h" #include "content/renderer/pepper/pepper_device_enumeration_host_helper.h" #include "ppapi/c/pp_errors.h" #include "ppapi/host/host_message_context.h" @@ -146,7 +146,8 @@ class PepperDeviceEnumerationHostHelperTest : public testing::Test { ppapi::host::PpapiHost ppapi_host_; ppapi::host::ResourceHost resource_host_; PepperDeviceEnumerationHostHelper device_enumeration_; - base::MessageLoop message_loop_; // required for async calls to work. + base::test::ScopedTaskEnvironment + task_environment_; // required for async calls to work. private: DISALLOW_COPY_AND_ASSIGN(PepperDeviceEnumerationHostHelperTest); diff --git a/chromium/content/renderer/pepper/pepper_file_chooser_host.cc b/chromium/content/renderer/pepper/pepper_file_chooser_host.cc index 9c93b39c851..62feee1c4c2 100644 --- a/chromium/content/renderer/pepper/pepper_file_chooser_host.cc +++ b/chromium/content/renderer/pepper/pepper_file_chooser_host.cc @@ -9,7 +9,6 @@ #include "base/files/file_path.h" #include "base/macros.h" #include "base/strings/utf_string_conversions.h" -#include "content/public/common/file_chooser_params.h" #include "content/public/renderer/renderer_ppapi_host.h" #include "content/renderer/pepper/pepper_file_ref_renderer_host.h" #include "content/renderer/render_view_impl.h" @@ -17,12 +16,16 @@ #include "ppapi/host/dispatch_host_message.h" #include "ppapi/host/ppapi_host.h" #include "ppapi/proxy/ppapi_messages.h" +#include "third_party/blink/public/mojom/choosers/file_chooser.mojom.h" +#include "third_party/blink/public/platform/file_path_conversion.h" #include "third_party/blink/public/platform/web_string.h" #include "third_party/blink/public/platform/web_vector.h" #include "third_party/blink/public/web/web_file_chooser_completion.h" namespace content { +using blink::mojom::FileChooserParams; + class PepperFileChooserHost::CompletionHandler : public blink::WebFileChooserCompletion { public: @@ -37,7 +40,7 @@ class PepperFileChooserHost::CompletionHandler std::vector<PepperFileChooserHost::ChosenFileInfo> files; for (size_t i = 0; i < file_names.size(); i++) { files.push_back(PepperFileChooserHost::ChosenFileInfo( - file_names[i].Utf8(), std::string())); + blink::WebStringToFilePath(file_names[i]), std::string())); } host_->StoreChosenFiles(files); } @@ -51,7 +54,7 @@ class PepperFileChooserHost::CompletionHandler std::vector<PepperFileChooserHost::ChosenFileInfo> files; for (size_t i = 0; i < file_names.size(); i++) { files.push_back(PepperFileChooserHost::ChosenFileInfo( - file_names[i].path.Utf8(), file_names[i].display_name.Utf8())); + file_names[i].file_path, file_names[i].display_name.Utf8())); } host_->StoreChosenFiles(files); } @@ -67,9 +70,9 @@ class PepperFileChooserHost::CompletionHandler }; PepperFileChooserHost::ChosenFileInfo::ChosenFileInfo( - const std::string& path, + const base::FilePath& file_path, const std::string& display_name) - : path(path), display_name(display_name) {} + : file_path(file_path), display_name(display_name) {} PepperFileChooserHost::PepperFileChooserHost(RendererPpapiHost* host, PP_Instance instance, @@ -96,7 +99,7 @@ void PepperFileChooserHost::StoreChosenFiles( std::vector<base::FilePath> file_paths; std::vector<std::string> display_names; for (size_t i = 0; i < files.size(); i++) { - base::FilePath file_path = base::FilePath::FromUTF8Unsafe(files[i].path); + base::FilePath file_path = files[i].file_path; file_paths.push_back(file_path); create_msgs.push_back(PpapiHostMsg_FileRef_CreateForRawFS(file_path)); display_names.push_back(files[i].display_name); @@ -137,12 +140,12 @@ int32_t PepperFileChooserHost::OnShow( FileChooserParams params; if (save_as) { - params.mode = FileChooserParams::Save; + params.mode = FileChooserParams::Mode::kSave; params.default_file_name = base::FilePath::FromUTF8Unsafe(suggested_file_name).BaseName(); } else { - params.mode = open_multiple ? FileChooserParams::OpenMultiple - : FileChooserParams::Open; + params.mode = open_multiple ? FileChooserParams::Mode::kOpenMultiple + : FileChooserParams::Mode::kOpen; } params.accept_types.reserve(accept_mime_types.size()); for (const auto& mime_type : accept_mime_types) diff --git a/chromium/content/renderer/pepper/pepper_file_chooser_host.h b/chromium/content/renderer/pepper/pepper_file_chooser_host.h index 3032da07407..c37930e566a 100644 --- a/chromium/content/renderer/pepper/pepper_file_chooser_host.h +++ b/chromium/content/renderer/pepper/pepper_file_chooser_host.h @@ -27,8 +27,9 @@ class CONTENT_EXPORT PepperFileChooserHost public: // Structure to store the information about chosen files. struct ChosenFileInfo { - ChosenFileInfo(const std::string& path, const std::string& display_name); - std::string path; + ChosenFileInfo(const base::FilePath& file_path, + const std::string& display_name); + base::FilePath file_path; std::string display_name; // May be empty. }; diff --git a/chromium/content/renderer/pepper/pepper_file_chooser_host_unittest.cc b/chromium/content/renderer/pepper/pepper_file_chooser_host_unittest.cc index d610636955d..4299de315c5 100644 --- a/chromium/content/renderer/pepper/pepper_file_chooser_host_unittest.cc +++ b/chromium/content/renderer/pepper/pepper_file_chooser_host_unittest.cc @@ -10,8 +10,6 @@ #include "build/build_config.h" #include "content/common/frame_messages.h" #include "content/common/view_messages.h" -#include "content/public/common/file_chooser_file_info.h" -#include "content/public/common/file_chooser_params.h" #include "content/public/test/render_view_test.h" #include "content/renderer/pepper/mock_renderer_ppapi_host.h" #include "content/renderer/pepper/pepper_file_chooser_host.h" @@ -61,15 +59,6 @@ class PepperFileChooserHostTest : public RenderViewTest { TestContentClient client_; }; -// For testing to convert our hardcoded file paths to 8-bit. -std::string FilePathToUTF8(const base::FilePath::StringType& path) { -#if defined(OS_WIN) - return base::UTF16ToUTF8(path); -#else - return path; -#endif -} - } // namespace TEST_F(PepperFileChooserHostTest, Show) { @@ -97,20 +86,22 @@ TEST_F(PepperFileChooserHostTest, Show) { ASSERT_TRUE(msg); FrameHostMsg_RunFileChooser::Schema::Param call_msg_param; ASSERT_TRUE(FrameHostMsg_RunFileChooser::Read(msg, &call_msg_param)); - const FileChooserParams& chooser_params = std::get<0>(call_msg_param); + const blink::mojom::FileChooserParams& chooser_params = + std::get<0>(call_msg_param); // Basic validation of request. - EXPECT_EQ(FileChooserParams::Open, chooser_params.mode); + EXPECT_EQ(blink::mojom::FileChooserParams::Mode::kOpen, chooser_params.mode); ASSERT_EQ(1u, chooser_params.accept_types.size()); EXPECT_EQ(accept[0], base::UTF16ToUTF8(chooser_params.accept_types[0])); // Send a chooser reply to the render view. Note our reply path has to have a // path separator so we include both a Unix and a Windows one. - content::FileChooserFileInfo selected_info; - selected_info.display_name = FILE_PATH_LITERAL("Hello, world"); - selected_info.file_path = base::FilePath(FILE_PATH_LITERAL("myp\\ath/foo")); - std::vector<content::FileChooserFileInfo> selected_info_vector; - selected_info_vector.push_back(selected_info); + std::vector<blink::mojom::FileChooserFileInfoPtr> selected_info_vector; + selected_info_vector.push_back( + blink::mojom::FileChooserFileInfo::NewNativeFile( + blink::mojom::NativeFileInfo::New( + base::FilePath(FILE_PATH_LITERAL("myp\\ath/foo")), + base::ASCIIToUTF16("Hello, world")))); RenderFrameImpl* frame_impl = static_cast<RenderFrameImpl*>(view_->GetMainRenderFrame()); FrameMsg_RunFileChooserResponse response(frame_impl->GetRoutingID(), @@ -132,7 +123,8 @@ TEST_F(PepperFileChooserHostTest, Show) { const std::vector<ppapi::FileRefCreateInfo>& chooser_results = std::get<0>(reply_msg_param); ASSERT_EQ(1u, chooser_results.size()); - EXPECT_EQ(FilePathToUTF8(selected_info.display_name), + EXPECT_EQ(base::UTF16ToUTF8( + selected_info_vector[0]->get_native_file()->display_name), chooser_results[0].display_name); } diff --git a/chromium/content/renderer/pepper/pepper_file_system_host.cc b/chromium/content/renderer/pepper/pepper_file_system_host.cc index 53915dfd0d7..26224903006 100644 --- a/chromium/content/renderer/pepper/pepper_file_system_host.cc +++ b/chromium/content/renderer/pepper/pepper_file_system_host.cc @@ -10,7 +10,6 @@ #include "content/public/common/service_names.mojom.h" #include "content/public/renderer/render_view.h" #include "content/public/renderer/renderer_ppapi_host.h" -#include "content/renderer/fileapi/file_system_dispatcher.h" #include "content/renderer/pepper/pepper_plugin_instance_impl.h" #include "content/renderer/render_thread_impl.h" #include "ppapi/c/pp_errors.h" diff --git a/chromium/content/renderer/pepper/pepper_graphics_2d_host_unittest.cc b/chromium/content/renderer/pepper/pepper_graphics_2d_host_unittest.cc index 5b24e209631..c2d365aa581 100644 --- a/chromium/content/renderer/pepper/pepper_graphics_2d_host_unittest.cc +++ b/chromium/content/renderer/pepper/pepper_graphics_2d_host_unittest.cc @@ -7,7 +7,7 @@ #include <stddef.h> #include "base/macros.h" -#include "base/message_loop/message_loop.h" +#include "base/test/scoped_task_environment.h" #include "content/renderer/pepper/gfx_conversion.h" #include "content/renderer/pepper/mock_renderer_ppapi_host.h" #include "content/renderer/pepper/ppb_image_data_impl.h" @@ -82,7 +82,7 @@ class PepperGraphics2DHostTest : public testing::Test { private: ppapi::ViewData renderer_view_data_; std::unique_ptr<PepperGraphics2DHost> host_; - base::MessageLoop message_loop_; + base::test::ScopedTaskEnvironment task_environment_; MockRendererPpapiHost renderer_ppapi_host_; ppapi::TestGlobals test_globals_; }; diff --git a/chromium/content/renderer/pepper/pepper_media_device_manager.cc b/chromium/content/renderer/pepper/pepper_media_device_manager.cc index 606cec34a66..7e09fcc6cd5 100644 --- a/chromium/content/renderer/pepper/pepper_media_device_manager.cc +++ b/chromium/content/renderer/pepper/pepper_media_device_manager.cc @@ -232,7 +232,7 @@ void PepperMediaDeviceManager::OnDeviceOpened(int request_id, bool success, const std::string& label, const MediaStreamDevice& device) { - OpenCallbackMap::iterator iter = open_callbacks_.find(request_id); + auto iter = open_callbacks_.find(request_id); if (iter == open_callbacks_.end()) { // The callback may have been unregistered. return; diff --git a/chromium/content/renderer/pepper/pepper_plugin_instance_impl.cc b/chromium/content/renderer/pepper/pepper_plugin_instance_impl.cc index 6cde87d05de..fa9f391cd08 100644 --- a/chromium/content/renderer/pepper/pepper_plugin_instance_impl.cc +++ b/chromium/content/renderer/pepper/pepper_plugin_instance_impl.cc @@ -194,9 +194,11 @@ namespace content { namespace { +#ifndef STATIC_ASSERT_ENUM #define STATIC_ASSERT_ENUM(a, b) \ static_assert(static_cast<int>(a) == static_cast<int>(b), \ "mismatching enums: " #a) +#endif // Check PP_TextInput_Type and ui::TextInputType are kept in sync. STATIC_ASSERT_ENUM(ui::TEXT_INPUT_TYPE_NONE, PP_TEXTINPUT_TYPE_NONE); @@ -438,8 +440,7 @@ PepperPluginInstanceImpl::ExternalDocumentLoader::~ExternalDocumentLoader() {} void PepperPluginInstanceImpl::ExternalDocumentLoader::ReplayReceivedData( WebAssociatedURLLoaderClient* document_loader) { - for (std::list<std::string>::iterator it = data_.begin(); it != data_.end(); - ++it) { + for (auto it = data_.begin(); it != data_.end(); ++it) { document_loader->DidReceiveData(it->c_str(), it->length()); } if (finished_loading_) { @@ -591,8 +592,7 @@ PepperPluginInstanceImpl::~PepperPluginInstanceImpl() { // unregister themselves inside the delete call). PluginObjectSet plugin_object_copy; live_plugin_objects_.swap(plugin_object_copy); - for (PluginObjectSet::iterator i = plugin_object_copy.begin(); - i != plugin_object_copy.end(); + for (auto i = plugin_object_copy.begin(); i != plugin_object_copy.end(); ++i) { (*i)->InstanceDeleted(); } @@ -1020,10 +1020,9 @@ bool PepperPluginInstanceImpl:: for (size_t i = 0; i < ime_text_spans.size(); ++i) { if (ime_text_spans[i].thickness == ws::mojom::ImeTextSpanThickness::kThick) { - std::vector<uint32_t>::iterator it = - std::find(event.composition_segment_offsets.begin(), - event.composition_segment_offsets.end(), - utf8_offsets[2 * i + 2]); + auto it = std::find(event.composition_segment_offsets.begin(), + event.composition_segment_offsets.end(), + utf8_offsets[2 * i + 2]); if (it != event.composition_segment_offsets.end()) { event.composition_target_segment = it - event.composition_segment_offsets.begin(); @@ -2370,9 +2369,7 @@ void PepperPluginInstanceImpl::SimulateInputEvent( CreateSimulatedWebInputEvents( input_event, view_data_.rect.point.x + view_data_.rect.size.width / 2, view_data_.rect.point.y + view_data_.rect.size.height / 2); - for (std::vector<std::unique_ptr<WebInputEvent>>::iterator it = - events.begin(); - it != events.end(); ++it) { + for (auto it = events.begin(); it != events.end(); ++it) { widget->HandleInputEvent(blink::WebCoalescedInputEvent(*it->get())); } if (input_event.event_type == PP_INPUTEVENT_TYPE_TOUCHSTART || @@ -3103,7 +3100,7 @@ PP_Resource PepperPluginInstanceImpl::CreateImage(gfx::ImageSkia* source_image, SkCanvas* canvas = image_data->GetCanvas(); // Note: Do not SkBitmap::copyTo the canvas bitmap directly because it will // ignore the allocated pixels in shared memory and re-allocate a new buffer. - canvas->writePixels(image_skia_rep.sk_bitmap(), 0, 0); + canvas->writePixels(image_skia_rep.GetBitmap(), 0, 0); return image_data->GetReference(); } diff --git a/chromium/content/renderer/pepper/pepper_plugin_registry.cc b/chromium/content/renderer/pepper/pepper_plugin_registry.cc index 73ddbac0b5b..0f875975979 100644 --- a/chromium/content/renderer/pepper/pepper_plugin_registry.cc +++ b/chromium/content/renderer/pepper/pepper_plugin_registry.cc @@ -48,8 +48,7 @@ const PepperPluginInfo* PepperPluginRegistry::GetInfoForPlugin( PluginModule* PepperPluginRegistry::GetLiveModule( const base::FilePath& path, const base::Optional<url::Origin>& origin_lock) { - NonOwningModuleMap::iterator module_iter = - live_modules_.find({path, origin_lock}); + auto module_iter = live_modules_.find({path, origin_lock}); if (module_iter == live_modules_.end()) return nullptr; @@ -64,8 +63,7 @@ PluginModule* PepperPluginRegistry::GetLiveModule( if (instance_set.empty()) return module_iter->second; - PluginModule::PluginInstanceSet::const_iterator instance_iter = - instance_set.begin(); + auto instance_iter = instance_set.begin(); while (instance_iter != instance_set.end()) { if (!(*instance_iter)->is_deleted()) return module_iter->second; @@ -88,9 +86,7 @@ void PepperPluginRegistry::PluginModuleDead(PluginModule* dead_module) { // Modules aren't destroyed very often and there are normally at most a // couple of them. So for now we just do a brute-force search. - for (NonOwningModuleMap::iterator i = live_modules_.begin(); - i != live_modules_.end(); - ++i) { + for (auto i = live_modules_.begin(); i != live_modules_.end(); ++i) { if (i->second == dead_module) { live_modules_.erase(i); return; diff --git a/chromium/content/renderer/pepper/pepper_url_loader_host.cc b/chromium/content/renderer/pepper/pepper_url_loader_host.cc index b4a262c9203..43807f48531 100644 --- a/chromium/content/renderer/pepper/pepper_url_loader_host.cc +++ b/chromium/content/renderer/pepper/pepper_url_loader_host.cc @@ -252,7 +252,7 @@ int32_t PepperURLLoaderHost::InternalOnHostMsgOpen( return PP_ERROR_FAILED; } - web_request.SetRequestContext(WebURLRequest::kRequestContextPlugin); + web_request.SetRequestContext(blink::mojom::RequestContextType::PLUGIN); web_request.SetPluginChildID(renderer_ppapi_host_->GetPluginChildId()); // Requests from plug-ins must skip service workers, see the comment in diff --git a/chromium/content/renderer/pepper/pepper_video_decoder_host.cc b/chromium/content/renderer/pepper/pepper_video_decoder_host.cc index 5201b8dc049..ae99e9285fd 100644 --- a/chromium/content/renderer/pepper/pepper_video_decoder_host.cc +++ b/chromium/content/renderer/pepper/pepper_video_decoder_host.cc @@ -319,7 +319,7 @@ int32_t PepperVideoDecoderHost::OnHostMsgRecyclePicture( return PP_ERROR_FAILED; DCHECK(decoder_); - PictureBufferMap::iterator it = picture_buffer_map_.find(texture_id); + auto it = picture_buffer_map_.find(texture_id); if (it == picture_buffer_map_.end()) return PP_ERROR_BADARGUMENT; @@ -388,8 +388,7 @@ void PepperVideoDecoderHost::ProvidePictureBuffers( } void PepperVideoDecoderHost::PictureReady(const media::Picture& picture) { - PictureBufferMap::iterator it = - picture_buffer_map_.find(picture.picture_buffer_id()); + auto it = picture_buffer_map_.find(picture.picture_buffer_id()); DCHECK(it != picture_buffer_map_.end()); DCHECK(it->second == PictureBufferState::ASSIGNED); it->second = PictureBufferState::IN_USE; @@ -404,7 +403,7 @@ void PepperVideoDecoderHost::PictureReady(const media::Picture& picture) { } void PepperVideoDecoderHost::DismissPictureBuffer(int32_t picture_buffer_id) { - PictureBufferMap::iterator it = picture_buffer_map_.find(picture_buffer_id); + auto it = picture_buffer_map_.find(picture_buffer_id); DCHECK(it != picture_buffer_map_.end()); // If the texture is still used by the plugin keep it until the plugin @@ -423,7 +422,7 @@ void PepperVideoDecoderHost::DismissPictureBuffer(int32_t picture_buffer_id) { void PepperVideoDecoderHost::NotifyEndOfBitstreamBuffer( int32_t bitstream_buffer_id) { - PendingDecodeList::iterator it = GetPendingDecodeById(bitstream_buffer_id); + auto it = GetPendingDecodeById(bitstream_buffer_id); if (it == pending_decodes_.end()) { NOTREACHED(); return; diff --git a/chromium/content/renderer/pepper/pepper_video_destination_host.cc b/chromium/content/renderer/pepper/pepper_video_destination_host.cc deleted file mode 100644 index aa3567d20c6..00000000000 --- a/chromium/content/renderer/pepper/pepper_video_destination_host.cc +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) 2013 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 "content/renderer/pepper/pepper_video_destination_host.h" - -#include "base/time/time.h" -#include "content/public/renderer/renderer_ppapi_host.h" -#include "content/renderer/pepper/ppb_image_data_impl.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/host/dispatch_host_message.h" -#include "ppapi/host/host_message_context.h" -#include "ppapi/host/ppapi_host.h" -#include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/thunk/enter.h" -#include "ppapi/thunk/ppb_image_data_api.h" - -using ppapi::host::HostMessageContext; -using ppapi::host::ReplyMessageContext; - -namespace content { - -PepperVideoDestinationHost::PepperVideoDestinationHost(RendererPpapiHost* host, - PP_Instance instance, - PP_Resource resource) - : ResourceHost(host->GetPpapiHost(), instance, resource), -#if DCHECK_IS_ON() - has_received_frame_(false), -#endif - weak_factory_(this) {} - -PepperVideoDestinationHost::~PepperVideoDestinationHost() {} - -int32_t PepperVideoDestinationHost::OnResourceMessageReceived( - const IPC::Message& msg, - HostMessageContext* context) { - PPAPI_BEGIN_MESSAGE_MAP(PepperVideoDestinationHost, msg) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoDestination_Open, - OnHostMsgOpen) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoDestination_PutFrame, - OnHostMsgPutFrame) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoDestination_Close, - OnHostMsgClose) - PPAPI_END_MESSAGE_MAP() - return PP_ERROR_FAILED; -} - -int32_t PepperVideoDestinationHost::OnHostMsgOpen( - HostMessageContext* context, - const std::string& stream_url) { - GURL gurl(stream_url); - if (!gurl.is_valid()) - return PP_ERROR_BADARGUMENT; - - FrameWriterInterface* frame_writer = nullptr; - if (!PepperToVideoTrackAdapter::Open(nullptr /* registry */, gurl.spec(), - &frame_writer)) - return PP_ERROR_FAILED; - frame_writer_.reset(frame_writer); - - ReplyMessageContext reply_context = context->MakeReplyMessageContext(); - reply_context.params.set_result(PP_OK); - host()->SendReply(reply_context, PpapiPluginMsg_VideoDestination_OpenReply()); - return PP_OK_COMPLETIONPENDING; -} - -int32_t PepperVideoDestinationHost::OnHostMsgPutFrame( - HostMessageContext* context, - const ppapi::HostResource& image_data_resource, - PP_TimeTicks timestamp) { - ppapi::thunk::EnterResourceNoLock<ppapi::thunk::PPB_ImageData_API> enter( - image_data_resource.host_resource(), true); - if (enter.failed()) - return PP_ERROR_BADRESOURCE; - PPB_ImageData_Impl* image_data_impl = - static_cast<PPB_ImageData_Impl*>(enter.object()); - - if (!PPB_ImageData_Impl::IsImageDataFormatSupported( - image_data_impl->format())) - return PP_ERROR_BADARGUMENT; - - if (!frame_writer_.get()) - return PP_ERROR_FAILED; - - // Convert PP_TimeTicks (a double, in seconds) to a video timestamp (int64_t, - // nanoseconds). - const int64_t timestamp_ns = - static_cast<int64_t>(timestamp * base::Time::kNanosecondsPerSecond); - // Check that timestamps are strictly increasing. -#if DCHECK_IS_ON() - if (has_received_frame_) - DCHECK_GT(timestamp_ns, previous_timestamp_ns_); - has_received_frame_ = true; - previous_timestamp_ns_ = timestamp_ns; -#endif - - frame_writer_->PutFrame(image_data_impl, timestamp_ns); - - return PP_OK; -} - -int32_t PepperVideoDestinationHost::OnHostMsgClose( - HostMessageContext* context) { - frame_writer_.reset(nullptr); - return PP_OK; -} - -} // namespace content diff --git a/chromium/content/renderer/pepper/pepper_video_destination_host.h b/chromium/content/renderer/pepper/pepper_video_destination_host.h deleted file mode 100644 index 1041952ab5c..00000000000 --- a/chromium/content/renderer/pepper/pepper_video_destination_host.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DESTINATION_HOST_H_ -#define CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DESTINATION_HOST_H_ - -#include <stdint.h> - -#include <memory> - -#include "base/compiler_specific.h" -#include "base/macros.h" -#include "base/memory/weak_ptr.h" -#include "content/common/content_export.h" -#include "content/renderer/media/pepper/pepper_to_video_track_adapter.h" -#include "ppapi/c/pp_time.h" -#include "ppapi/host/resource_host.h" - -namespace content { - -class RendererPpapiHost; - -class CONTENT_EXPORT PepperVideoDestinationHost - : public ppapi::host::ResourceHost { - public: - PepperVideoDestinationHost(RendererPpapiHost* host, - PP_Instance instance, - PP_Resource resource); - - ~PepperVideoDestinationHost() override; - - int32_t OnResourceMessageReceived( - const IPC::Message& msg, - ppapi::host::HostMessageContext* context) override; - - private: - int32_t OnHostMsgOpen(ppapi::host::HostMessageContext* context, - const std::string& stream_url); - int32_t OnHostMsgPutFrame(ppapi::host::HostMessageContext* context, - const ppapi::HostResource& image_data_resource, - PP_TimeTicks timestamp); - int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context); - - std::unique_ptr<FrameWriterInterface> frame_writer_; - // Used for checking that timestamps are strictly increasing. -#if DCHECK_IS_ON() - bool has_received_frame_; - int64_t previous_timestamp_ns_; -#endif - - base::WeakPtrFactory<PepperVideoDestinationHost> weak_factory_; - - DISALLOW_COPY_AND_ASSIGN(PepperVideoDestinationHost); -}; - -} // namespace content - -#endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DESTINATION_HOST_H_ diff --git a/chromium/content/renderer/pepper/pepper_video_encoder_host.cc b/chromium/content/renderer/pepper/pepper_video_encoder_host.cc index cf8e6333142..1cb22a60969 100644 --- a/chromium/content/renderer/pepper/pepper_video_encoder_host.cc +++ b/chromium/content/renderer/pepper/pepper_video_encoder_host.cc @@ -11,8 +11,8 @@ #include "base/numerics/safe_math.h" #include "base/threading/thread_task_runner_handle.h" #include "build/build_config.h" -#include "content/common/gpu_stream_constants.h" #include "content/common/pepper_file_util.h" +#include "content/public/common/gpu_stream_constants.h" #include "content/public/renderer/renderer_ppapi_host.h" #include "content/renderer/pepper/gfx_conversion.h" #include "content/renderer/pepper/host_globals.h" diff --git a/chromium/content/renderer/pepper/pepper_video_source_host.cc b/chromium/content/renderer/pepper/pepper_video_source_host.cc deleted file mode 100644 index 48047137deb..00000000000 --- a/chromium/content/renderer/pepper/pepper_video_source_host.cc +++ /dev/null @@ -1,322 +0,0 @@ -// Copyright (c) 2013 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 "content/renderer/pepper/pepper_video_source_host.h" - -#include <string.h> - -#include "base/bind.h" -#include "base/numerics/safe_conversions.h" -#include "content/public/renderer/renderer_ppapi_host.h" -#include "content/renderer/media/pepper/video_track_to_pepper_adapter.h" -#include "content/renderer/pepper/ppb_image_data_impl.h" -#include "content/renderer/render_thread_impl.h" -#include "media/base/video_util.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/host/dispatch_host_message.h" -#include "ppapi/host/ppapi_host.h" -#include "ppapi/proxy/host_dispatcher.h" -#include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/proxy/ppb_image_data_proxy.h" -#include "ppapi/shared_impl/scoped_pp_resource.h" -#include "ppapi/thunk/enter.h" -#include "ppapi/thunk/ppb_image_data_api.h" -#include "third_party/libyuv/include/libyuv/convert.h" -#include "third_party/libyuv/include/libyuv/scale.h" -#include "third_party/skia/include/core/SkBitmap.h" - -using ppapi::host::HostMessageContext; -using ppapi::host::ReplyMessageContext; - -namespace content { - -class PepperVideoSourceHost::FrameReceiver - : public FrameReaderInterface, - public base::RefCountedThreadSafe<FrameReceiver> { - public: - explicit FrameReceiver(const base::WeakPtr<PepperVideoSourceHost>& host); - - // FrameReaderInterface implementation. - void GotFrame(const scoped_refptr<media::VideoFrame>& frame) override; - - private: - friend class base::RefCountedThreadSafe<FrameReceiver>; - ~FrameReceiver() override; - - base::WeakPtr<PepperVideoSourceHost> host_; - // |thread_checker_| is bound to the main render thread. - base::ThreadChecker thread_checker_; -}; - -PepperVideoSourceHost::FrameReceiver::FrameReceiver( - const base::WeakPtr<PepperVideoSourceHost>& host) - : host_(host) {} - -PepperVideoSourceHost::FrameReceiver::~FrameReceiver() {} - -void PepperVideoSourceHost::FrameReceiver::GotFrame( - const scoped_refptr<media::VideoFrame>& video_frame) { - DCHECK(thread_checker_.CalledOnValidThread()); - if (!host_) - return; - - if (!(video_frame->format() == media::PIXEL_FORMAT_I420 || - video_frame->format() == media::PIXEL_FORMAT_I420A)) { - NOTREACHED(); - return; - } - scoped_refptr<media::VideoFrame> frame = video_frame; - // Drop alpha channel since we do not support it yet. - if (frame->format() == media::PIXEL_FORMAT_I420A) - frame = media::WrapAsI420VideoFrame(video_frame); - - // Hold a reference to the new frame and release the previous. - host_->last_frame_ = frame; - if (host_->get_frame_pending_) - host_->SendGetFrameReply(); -} - -PepperVideoSourceHost::PepperVideoSourceHost(RendererPpapiHost* host, - PP_Instance instance, - PP_Resource resource) - : ResourceHost(host->GetPpapiHost(), instance, resource), - frame_source_(new VideoTrackToPepperAdapter(nullptr)), - get_frame_pending_(false), - weak_factory_(this) { - frame_receiver_ = new FrameReceiver(weak_factory_.GetWeakPtr()); - memset(&shared_image_desc_, 0, sizeof(shared_image_desc_)); -} - -PepperVideoSourceHost::~PepperVideoSourceHost() { Close(); } - -int32_t PepperVideoSourceHost::OnResourceMessageReceived( - const IPC::Message& msg, - HostMessageContext* context) { - PPAPI_BEGIN_MESSAGE_MAP(PepperVideoSourceHost, msg) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoSource_Open, - OnHostMsgOpen) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoSource_GetFrame, - OnHostMsgGetFrame) - PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoSource_Close, - OnHostMsgClose) - PPAPI_END_MESSAGE_MAP() - return PP_ERROR_FAILED; -} - -int32_t PepperVideoSourceHost::OnHostMsgOpen(HostMessageContext* context, - const std::string& stream_url) { - GURL gurl(stream_url); - if (!gurl.is_valid()) - return PP_ERROR_BADARGUMENT; - - if (!frame_source_->Open(gurl.spec(), frame_receiver_.get())) - return PP_ERROR_BADARGUMENT; - - stream_url_ = gurl.spec(); - - ReplyMessageContext reply_context = context->MakeReplyMessageContext(); - reply_context.params.set_result(PP_OK); - host()->SendReply(reply_context, PpapiPluginMsg_VideoSource_OpenReply()); - return PP_OK_COMPLETIONPENDING; -} - -int32_t PepperVideoSourceHost::OnHostMsgGetFrame(HostMessageContext* context) { - if (!frame_source_.get()) - return PP_ERROR_FAILED; - if (get_frame_pending_) - return PP_ERROR_INPROGRESS; - - reply_context_ = context->MakeReplyMessageContext(); - get_frame_pending_ = true; - - // If a frame is ready, try to convert it and send the reply. - if (last_frame_.get()) - SendGetFrameReply(); - - return PP_OK_COMPLETIONPENDING; -} - -int32_t PepperVideoSourceHost::OnHostMsgClose(HostMessageContext* context) { - Close(); - return PP_OK; -} - -void PepperVideoSourceHost::SendGetFrameReply() { - DCHECK(get_frame_pending_); - get_frame_pending_ = false; - - DCHECK(last_frame_.get()); - const gfx::Size dst_size = last_frame_->natural_size(); - - // Note: We try to reuse the shared memory for the previous frame here. This - // means that the previous frame may be overwritten and is no longer valid - // after calling this function again. - base::SharedMemoryHandle image_handle; - uint32_t byte_count; - if (shared_image_.get() && dst_size.width() == shared_image_->width() && - dst_size.height() == shared_image_->height()) { - // We have already allocated the correct size in shared memory. We need to - // duplicate the handle for IPC however, which will close down the - // duplicated handle when it's done. - base::SharedMemory* local_shm; - if (shared_image_->GetSharedMemory(&local_shm, &byte_count) != PP_OK) { - SendGetFrameErrorReply(PP_ERROR_FAILED); - return; - } - - ppapi::proxy::HostDispatcher* dispatcher = - ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); - if (!dispatcher) { - SendGetFrameErrorReply(PP_ERROR_FAILED); - return; - } - - image_handle = - dispatcher->ShareSharedMemoryHandleWithRemote(local_shm->handle()); - } else { - // We need to allocate new shared memory. - shared_image_ = nullptr; // Release any previous image. - - ppapi::ScopedPPResource resource( - ppapi::ScopedPPResource::PassRef(), - ppapi::proxy::PPB_ImageData_Proxy::CreateImageData( - pp_instance(), - ppapi::PPB_ImageData_Shared::SIMPLE, - PP_IMAGEDATAFORMAT_BGRA_PREMUL, - PP_MakeSize(dst_size.width(), dst_size.height()), - false /* init_to_zero */, - &shared_image_desc_, - &image_handle, - &byte_count)); - if (!resource) { - SendGetFrameErrorReply(PP_ERROR_FAILED); - return; - } - - ppapi::thunk::EnterResourceNoLock<ppapi::thunk::PPB_ImageData_API> - enter_resource(resource, false); - if (enter_resource.failed()) { - SendGetFrameErrorReply(PP_ERROR_FAILED); - return; - } - - shared_image_ = static_cast<PPB_ImageData_Impl*>(enter_resource.object()); - if (!shared_image_.get()) { - SendGetFrameErrorReply(PP_ERROR_FAILED); - return; - } - - DCHECK(!shared_image_->IsMapped()); // New memory should not be mapped. - if (!shared_image_->Map() || shared_image_->GetMappedBitmap().empty()) { - shared_image_ = nullptr; - SendGetFrameErrorReply(PP_ERROR_FAILED); - return; - } - } - - SkBitmap bitmap(shared_image_->GetMappedBitmap()); - if (bitmap.empty()) { - SendGetFrameErrorReply(PP_ERROR_FAILED); - return; - } - - uint8_t* bitmap_pixels = static_cast<uint8_t*>(bitmap.getPixels()); - if (!bitmap_pixels) { - SendGetFrameErrorReply(PP_ERROR_FAILED); - return; - } - - // Calculate the portion of the |last_frame_| that should be copied into - // |bitmap|. If |last_frame_| is lazily scaled, then - // last_frame_->visible_rect()._size() != last_frame_.natural_size(). - scoped_refptr<media::VideoFrame> frame; - if (dst_size == last_frame_->visible_rect().size()) { - // No scaling is needed, convert directly from last_frame_. - frame = last_frame_; - // Frame resolution doesn't change frequently, so don't keep any unnecessary - // buffers around. - scaled_frame_ = nullptr; - } else { - // We need to create an intermediate scaled frame. Make sure we have - // allocated one of correct size. - if (!scaled_frame_.get() || scaled_frame_->coded_size() != dst_size) { - scaled_frame_ = media::VideoFrame::CreateFrame( - media::PIXEL_FORMAT_I420, dst_size, gfx::Rect(dst_size), dst_size, - last_frame_->timestamp()); - if (!scaled_frame_.get()) { - LOG(ERROR) << "Failed to allocate a media::VideoFrame"; - SendGetFrameErrorReply(PP_ERROR_FAILED); - return; - } - } - scaled_frame_->set_timestamp(last_frame_->timestamp()); - libyuv::I420Scale(last_frame_->visible_data(media::VideoFrame::kYPlane), - last_frame_->stride(media::VideoFrame::kYPlane), - last_frame_->visible_data(media::VideoFrame::kUPlane), - last_frame_->stride(media::VideoFrame::kUPlane), - last_frame_->visible_data(media::VideoFrame::kVPlane), - last_frame_->stride(media::VideoFrame::kVPlane), - last_frame_->visible_rect().width(), - last_frame_->visible_rect().height(), - scaled_frame_->data(media::VideoFrame::kYPlane), - scaled_frame_->stride(media::VideoFrame::kYPlane), - scaled_frame_->data(media::VideoFrame::kUPlane), - scaled_frame_->stride(media::VideoFrame::kUPlane), - scaled_frame_->data(media::VideoFrame::kVPlane), - scaled_frame_->stride(media::VideoFrame::kVPlane), - dst_size.width(), - dst_size.height(), - libyuv::kFilterBilinear); - frame = scaled_frame_; - } - last_frame_ = nullptr; - - libyuv::I420ToARGB(frame->visible_data(media::VideoFrame::kYPlane), - frame->stride(media::VideoFrame::kYPlane), - frame->visible_data(media::VideoFrame::kUPlane), - frame->stride(media::VideoFrame::kUPlane), - frame->visible_data(media::VideoFrame::kVPlane), - frame->stride(media::VideoFrame::kVPlane), - bitmap_pixels, - bitmap.rowBytes(), - dst_size.width(), - dst_size.height()); - - ppapi::HostResource host_resource; - host_resource.SetHostResource(pp_instance(), shared_image_->GetReference()); - - // Convert a video timestamp to a PP_TimeTicks (a double, in seconds). - const PP_TimeTicks timestamp = frame->timestamp().InSecondsF(); - - ppapi::proxy::SerializedHandle serialized_handle; - serialized_handle.set_shmem(image_handle, byte_count); - reply_context_.params.AppendHandle(std::move(serialized_handle)); - - host()->SendReply(reply_context_, - PpapiPluginMsg_VideoSource_GetFrameReply( - host_resource, shared_image_desc_, timestamp)); - - reply_context_ = ppapi::host::ReplyMessageContext(); -} - -void PepperVideoSourceHost::SendGetFrameErrorReply(int32_t error) { - reply_context_.params.set_result(error); - host()->SendReply( - reply_context_, - PpapiPluginMsg_VideoSource_GetFrameReply( - ppapi::HostResource(), PP_ImageDataDesc(), 0.0 /* timestamp */)); - reply_context_ = ppapi::host::ReplyMessageContext(); -} - -void PepperVideoSourceHost::Close() { - if (frame_source_.get() && !stream_url_.empty()) - frame_source_->Close(frame_receiver_.get()); - - frame_source_.reset(nullptr); - stream_url_.clear(); - - shared_image_ = nullptr; -} - -} // namespace content diff --git a/chromium/content/renderer/pepper/pepper_video_source_host.h b/chromium/content/renderer/pepper/pepper_video_source_host.h deleted file mode 100644 index 811a4616876..00000000000 --- a/chromium/content/renderer/pepper/pepper_video_source_host.h +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_SOURCE_HOST_H_ -#define CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_SOURCE_HOST_H_ - -#include <stdint.h> - -#include <memory> - -#include "base/compiler_specific.h" -#include "base/macros.h" -#include "base/memory/ref_counted.h" -#include "base/memory/weak_ptr.h" -#include "base/threading/thread_checker.h" -#include "content/common/content_export.h" -#include "ppapi/c/pp_time.h" -#include "ppapi/c/ppb_image_data.h" -#include "ppapi/host/host_message_context.h" -#include "ppapi/host/resource_host.h" - -struct PP_ImageDataDesc; - -namespace media { -class VideoFrame; -} // namespace media - -namespace content { - -class PPB_ImageData_Impl; -class RendererPpapiHost; -class VideoTrackToPepperAdapter; - -class CONTENT_EXPORT PepperVideoSourceHost : public ppapi::host::ResourceHost { - public: - PepperVideoSourceHost(RendererPpapiHost* host, - PP_Instance instance, - PP_Resource resource); - - ~PepperVideoSourceHost() override; - - int32_t OnResourceMessageReceived( - const IPC::Message& msg, - ppapi::host::HostMessageContext* context) override; - - private: - // Helper object to receive frames on a video worker thread and pass them on - // to us. - class FrameReceiver; - - int32_t OnHostMsgOpen(ppapi::host::HostMessageContext* context, - const std::string& stream_url); - int32_t OnHostMsgGetFrame(ppapi::host::HostMessageContext* context); - int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context); - - // Sends the reply to a GetFrame message from the plugin. A reply is always - // sent and last_frame_, reply_context_, and get_frame_pending_ are all reset. - void SendGetFrameReply(); - // Sends the reply to a GetFrame message from the plugin in case of an error. - void SendGetFrameErrorReply(int32_t error); - - void Close(); - - ppapi::host::ReplyMessageContext reply_context_; - - std::unique_ptr<VideoTrackToPepperAdapter> frame_source_; - scoped_refptr<FrameReceiver> frame_receiver_; - std::string stream_url_; - scoped_refptr<media::VideoFrame> last_frame_; - // An internal frame buffer to avoid reallocations. It is only allocated if - // scaling is needed. - scoped_refptr<media::VideoFrame> scaled_frame_; - bool get_frame_pending_; - // We use only one ImageData resource in order to avoid allocating - // shared memory repeatedly. We send the same one each time the plugin - // requests a frame. For this to work, the plugin must finish using - // the ImageData it receives prior to calling GetFrame, and not access - // the ImageData until it gets its next callback to GetFrame. - scoped_refptr<PPB_ImageData_Impl> shared_image_; - PP_ImageDataDesc shared_image_desc_; - - base::WeakPtrFactory<PepperVideoSourceHost> weak_factory_; - - DISALLOW_COPY_AND_ASSIGN(PepperVideoSourceHost); -}; - -} // namespace content - -#endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_SOURCE_HOST_H_ diff --git a/chromium/content/renderer/pepper/pepper_webplugin_impl.cc b/chromium/content/renderer/pepper/pepper_webplugin_impl.cc index ed9dd9bcee9..183c17f4aba 100644 --- a/chromium/content/renderer/pepper/pepper_webplugin_impl.cc +++ b/chromium/content/renderer/pepper/pepper_webplugin_impl.cc @@ -238,7 +238,7 @@ void PepperWebPluginImpl::DidReceiveResponse( instance_->HandleDocumentLoad(response); } -void PepperWebPluginImpl::DidReceiveData(const char* data, int data_length) { +void PepperWebPluginImpl::DidReceiveData(const char* data, size_t data_length) { // Re-entrancy may cause JS to try to execute script on the plugin before it // is fully initialized. See: crbug.com/715747. if (!instance_) diff --git a/chromium/content/renderer/pepper/pepper_webplugin_impl.h b/chromium/content/renderer/pepper/pepper_webplugin_impl.h index fb0a58b0d9e..0b192933256 100644 --- a/chromium/content/renderer/pepper/pepper_webplugin_impl.h +++ b/chromium/content/renderer/pepper/pepper_webplugin_impl.h @@ -55,7 +55,7 @@ class PepperWebPluginImpl : public blink::WebPlugin { const blink::WebCoalescedInputEvent& event, blink::WebCursorInfo& cursor_info) override; void DidReceiveResponse(const blink::WebURLResponse& response) override; - void DidReceiveData(const char* data, int data_length) override; + void DidReceiveData(const char* data, size_t data_length) override; void DidFinishLoading() override; void DidFailLoading(const blink::WebURLError&) override; bool HasSelection() const override; diff --git a/chromium/content/renderer/pepper/pepper_websocket_host.cc b/chromium/content/renderer/pepper/pepper_websocket_host.cc index 0a8e50abe68..0a6e752cdfc 100644 --- a/chromium/content/renderer/pepper/pepper_websocket_host.cc +++ b/chromium/content/renderer/pepper/pepper_websocket_host.cc @@ -216,10 +216,8 @@ int32_t PepperWebSocketHost::OnHostMsgConnect( // Validate protocols. std::string protocol_string; - for (std::vector<std::string>::const_iterator vector_it = protocols.begin(); - vector_it != protocols.end(); + for (auto vector_it = protocols.begin(); vector_it != protocols.end(); ++vector_it) { - // Check containing characters. for (std::string::const_iterator string_it = vector_it->begin(); string_it != vector_it->end(); diff --git a/chromium/content/renderer/pepper/plugin_instance_throttler_impl_unittest.cc b/chromium/content/renderer/pepper/plugin_instance_throttler_impl_unittest.cc index 1165db9b75e..65dea551fda 100644 --- a/chromium/content/renderer/pepper/plugin_instance_throttler_impl_unittest.cc +++ b/chromium/content/renderer/pepper/plugin_instance_throttler_impl_unittest.cc @@ -9,7 +9,7 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/logging.h" -#include "base/message_loop/message_loop.h" +#include "base/test/scoped_task_environment.h" #include "content/public/common/content_switches.h" #include "content/public/renderer/render_frame.h" #include "skia/ext/platform_canvas.h" @@ -83,7 +83,7 @@ class PluginInstanceThrottlerImplTest int change_callback_calls_; - base::MessageLoop loop_; + base::test::ScopedTaskEnvironment task_environment_; }; TEST_F(PluginInstanceThrottlerImplTest, ThrottleAndUnthrottleByClick) { diff --git a/chromium/content/renderer/pepper/plugin_module.cc b/chromium/content/renderer/pepper/plugin_module.cc index 7f3d594f71b..1cf83074a8d 100644 --- a/chromium/content/renderer/pepper/plugin_module.cc +++ b/chromium/content/renderer/pepper/plugin_module.cc @@ -15,6 +15,7 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/logging.h" +#include "base/no_destructor.h" #include "base/run_loop.h" #include "base/time/time.h" #include "build/build_config.h" @@ -127,8 +128,6 @@ #include "ppapi/c/private/ppb_testing_private.h" #include "ppapi/c/private/ppb_udp_socket_private.h" #include "ppapi/c/private/ppb_uma_private.h" -#include "ppapi/c/private/ppb_video_destination_private.h" -#include "ppapi/c/private/ppb_video_source_private.h" #include "ppapi/c/private/ppb_x509_certificate_private.h" #include "ppapi/c/trusted/ppb_broker_trusted.h" #include "ppapi/c/trusted/ppb_browser_font_trusted.h" @@ -175,8 +174,8 @@ HostGlobals* host_globals = nullptr; typedef std::set<PluginModule*> PluginModuleSet; PluginModuleSet* GetLivePluginSet() { - CR_DEFINE_STATIC_LOCAL(PluginModuleSet, live_plugin_libs, ()); - return &live_plugin_libs; + static base::NoDestructor<PluginModuleSet> live_plugin_libs; + return live_plugin_libs.get(); } class PowerSaverTestPluginDelegate : public PluginInstanceThrottler::Observer { @@ -681,9 +680,7 @@ void PluginModule::PluginCrashed() { is_crashed_ = true; // Notify all instances that they crashed. - for (PluginInstanceSet::iterator i = instances_.begin(); - i != instances_.end(); - ++i) + for (auto i = instances_.begin(); i != instances_.end(); ++i) (*i)->InstanceCrashed(); PepperPluginRegistry::GetInstance()->PluginModuleDead(this); diff --git a/chromium/content/renderer/pepper/plugin_object.cc b/chromium/content/renderer/pepper/plugin_object.cc index 98d8a2257e0..71e4a9bb976 100644 --- a/chromium/content/renderer/pepper/plugin_object.cc +++ b/chromium/content/renderer/pepper/plugin_object.cc @@ -239,9 +239,12 @@ v8::Local<v8::Value> PluginObject::GetPropertyOrMethod(v8::Isolate* isolate, return v8::Local<v8::Value>(); if (has_method) { + v8::Local<v8::Context> context = isolate->GetCurrentContext(); const std::string& identifier = StringVar::FromPPVar(identifier_var)->value(); - return GetFunctionTemplate(isolate, identifier)->GetFunction(); + return GetFunctionTemplate(isolate, identifier) + ->GetFunction(context) + .ToLocalChecked(); } return v8::Local<v8::Value>(); diff --git a/chromium/content/renderer/pepper/plugin_power_saver_helper.cc b/chromium/content/renderer/pepper/plugin_power_saver_helper.cc index b16d1e11e3e..7b5c4db65f4 100644 --- a/chromium/content/renderer/pepper/plugin_power_saver_helper.cc +++ b/chromium/content/renderer/pepper/plugin_power_saver_helper.cc @@ -48,8 +48,8 @@ PluginPowerSaverHelper::~PluginPowerSaverHelper() { } void PluginPowerSaverHelper::DidCommitProvisionalLoad( - bool is_new_navigation, - bool is_same_document_navigation) { + bool is_same_document_navigation, + ui::PageTransition transition) { blink::WebFrame* frame = render_frame()->GetWebFrame(); // Only apply to top-level and new page navigation. if (frame->Parent() || is_same_document_navigation) diff --git a/chromium/content/renderer/pepper/plugin_power_saver_helper.h b/chromium/content/renderer/pepper/plugin_power_saver_helper.h index b89e911c4f1..e178201b826 100644 --- a/chromium/content/renderer/pepper/plugin_power_saver_helper.h +++ b/chromium/content/renderer/pepper/plugin_power_saver_helper.h @@ -50,8 +50,8 @@ class CONTENT_EXPORT PluginPowerSaverHelper : public RenderFrameObserver { void WhitelistContentOrigin(const url::Origin& content_origin); // RenderFrameObserver implementation. - void DidCommitProvisionalLoad(bool is_new_navigation, - bool is_same_document_navigation) override; + void DidCommitProvisionalLoad(bool is_same_document_navigation, + ui::PageTransition transition) override; bool OnMessageReceived(const IPC::Message& message) override; void OnDestruct() override; diff --git a/chromium/content/renderer/pepper/plugin_power_saver_helper_browsertest.cc b/chromium/content/renderer/pepper/plugin_power_saver_helper_browsertest.cc index 7b44d06a87c..3496efeda9e 100644 --- a/chromium/content/renderer/pepper/plugin_power_saver_helper_browsertest.cc +++ b/chromium/content/renderer/pepper/plugin_power_saver_helper_browsertest.cc @@ -7,7 +7,6 @@ #include "base/macros.h" #include "base/run_loop.h" #include "content/common/frame_messages.h" -#include "content/common/view_message_enums.h" #include "content/public/common/content_constants.h" #include "content/public/test/frame_load_waiter.h" #include "content/public/test/render_view_test.h" diff --git a/chromium/content/renderer/pepper/ppb_flash_message_loop_impl.cc b/chromium/content/renderer/pepper/ppb_flash_message_loop_impl.cc index ec02280deb6..45c2f3b674d 100644 --- a/chromium/content/renderer/pepper/ppb_flash_message_loop_impl.cc +++ b/chromium/content/renderer/pepper/ppb_flash_message_loop_impl.cc @@ -16,7 +16,7 @@ namespace content { class PPB_Flash_MessageLoop_Impl::State : public base::RefCounted<PPB_Flash_MessageLoop_Impl::State> { public: - State() : result_(PP_OK), run_called_(false), quit_called_(false) {} + explicit State() : result_(PP_OK), run_called_(false) {} int32_t result() const { return result_; } void set_result(int32_t result) { result_ = result; } @@ -24,8 +24,10 @@ class PPB_Flash_MessageLoop_Impl::State bool run_called() const { return run_called_; } void set_run_called() { run_called_ = true; } - bool quit_called() const { return quit_called_; } - void set_quit_called() { quit_called_ = true; } + void set_quit_closure(base::OnceClosure quit_closure) { + quit_closure_ = std::move(quit_closure); + } + base::OnceClosure& quit_closure() { return quit_closure_; } const RunFromHostProxyCallback& run_callback() const { return run_callback_; } void set_run_callback(const RunFromHostProxyCallback& run_callback) { @@ -38,7 +40,7 @@ class PPB_Flash_MessageLoop_Impl::State int32_t result_; bool run_called_; - bool quit_called_; + base::OnceClosure quit_closure_; RunFromHostProxyCallback run_callback_; }; @@ -82,13 +84,16 @@ int32_t PPB_Flash_MessageLoop_Impl::InternalRun( state_->set_run_called(); state_->set_run_callback(callback); + base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed); + state_->set_quit_closure(run_loop.QuitClosure()); + // It is possible that the PPB_Flash_MessageLoop_Impl object has been // destroyed when the nested run loop exits. scoped_refptr<State> state_protector(state_); { blink::WebView::WillEnterModalLoop(); - base::RunLoop(base::RunLoop::Type::kNestableTasksAllowed).Run(); + run_loop.Run(); blink::WebView::DidExitModalLoop(); } @@ -98,12 +103,11 @@ int32_t PPB_Flash_MessageLoop_Impl::InternalRun( } void PPB_Flash_MessageLoop_Impl::InternalQuit(int32_t result) { - if (!state_->run_called() || state_->quit_called()) + if (!state_->run_called() || state_->quit_closure().is_null()) return; - state_->set_quit_called(); state_->set_result(result); - base::RunLoop::QuitCurrentDeprecated(); + std::move(state_->quit_closure()).Run(); if (!state_->run_callback().is_null()) state_->run_callback().Run(result); diff --git a/chromium/content/renderer/pepper/ppb_graphics_3d_impl.cc b/chromium/content/renderer/pepper/ppb_graphics_3d_impl.cc index 4e2717ba4b3..6043089b539 100644 --- a/chromium/content/renderer/pepper/ppb_graphics_3d_impl.cc +++ b/chromium/content/renderer/pepper/ppb_graphics_3d_impl.cc @@ -12,9 +12,9 @@ #include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" #include "base/threading/thread_task_runner_handle.h" -#include "content/common/gpu_stream_constants.h" #include "content/public/common/content_features.h" #include "content/public/common/content_switches.h" +#include "content/public/common/gpu_stream_constants.h" #include "content/public/common/web_preferences.h" #include "content/renderer/pepper/host_globals.h" #include "content/renderer/pepper/pepper_plugin_instance_impl.h" diff --git a/chromium/content/renderer/pepper/ppb_var_deprecated_impl.cc b/chromium/content/renderer/pepper/ppb_var_deprecated_impl.cc index e08f0a87445..9434262d0c6 100644 --- a/chromium/content/renderer/pepper/ppb_var_deprecated_impl.cc +++ b/chromium/content/renderer/pepper/ppb_var_deprecated_impl.cc @@ -98,9 +98,16 @@ bool HasPropertyDeprecated(PP_Var var, PP_Var name, PP_Var* exception) { if (try_catch.HasException()) return false; - bool result = accessor.GetObject()->Has(v8_name); + v8::Local<v8::Context> context = try_catch.GetContext(); if (try_catch.HasException()) return false; + + bool result = false; + if (!accessor.GetObject()->Has(context, v8_name).To(&result)) { + try_catch.HasException(); + return false; + } + return result; } @@ -115,8 +122,17 @@ bool HasMethodDeprecated(PP_Var var, PP_Var name, PP_Var* exception) { if (try_catch.HasException()) return false; - bool result = accessor.GetObject()->Has(v8_name) && - accessor.GetObject()->Get(v8_name)->IsFunction(); + v8::Local<v8::Context> context = try_catch.GetContext(); + if (try_catch.HasException()) + return false; + + bool has_name = false; + if (!accessor.GetObject()->Has(context, v8_name).To(&has_name)) { + try_catch.HasException(); + return false; + } + + bool result = has_name && accessor.GetObject()->Get(v8_name)->IsFunction(); if (try_catch.HasException()) return false; return result; @@ -203,8 +219,16 @@ void DeletePropertyDeprecated(PP_Var var, PP_Var name, PP_Var* exception) { if (try_catch.HasException()) return; - accessor.GetObject()->Delete(v8_name); - try_catch.HasException(); // Ensure an exception gets set if one occured. + v8::Local<v8::Context> context = try_catch.GetContext(); + if (try_catch.HasException()) + return; + + if (accessor.GetObject()->Delete(context, v8_name).IsNothing()) { + // Ensure exception object is created if V8 has thrown. + try_catch.HasException(); + return; + } + return; } PP_Var CallDeprecatedInternal(PP_Var var, diff --git a/chromium/content/renderer/pepper/resource_converter.cc b/chromium/content/renderer/pepper/resource_converter.cc index c2c6b691472..e97b9afb726 100644 --- a/chromium/content/renderer/pepper/resource_converter.cc +++ b/chromium/content/renderer/pepper/resource_converter.cc @@ -19,7 +19,7 @@ #include "ppapi/shared_impl/resource_var.h" #include "ppapi/shared_impl/scoped_pp_var.h" #include "storage/common/fileapi/file_system_util.h" -#include "third_party/blink/public/platform/web_file_system.h" +#include "third_party/blink/public/platform/web_file_system_type.h" #include "third_party/blink/public/platform/web_media_stream_source.h" #include "third_party/blink/public/platform/web_media_stream_track.h" #include "third_party/blink/public/web/web_dom_file_system.h" @@ -42,16 +42,15 @@ void FlushComplete( callback.Run(true); } -// Converts a blink::WebFileSystem::Type to a PP_FileSystemType. -PP_FileSystemType WebFileSystemTypeToPPAPI(blink::WebFileSystem::Type type) { +PP_FileSystemType WebFileSystemTypeToPPAPI(blink::WebFileSystemType type) { switch (type) { - case blink::WebFileSystem::kTypeTemporary: + case blink::WebFileSystemType::kWebFileSystemTypeTemporary: return PP_FILESYSTEMTYPE_LOCALTEMPORARY; - case blink::WebFileSystem::kTypePersistent: + case blink::WebFileSystemType::kWebFileSystemTypePersistent: return PP_FILESYSTEMTYPE_LOCALPERSISTENT; - case blink::WebFileSystem::kTypeIsolated: + case blink::WebFileSystemType::kWebFileSystemTypeIsolated: return PP_FILESYSTEMTYPE_ISOLATED; - case blink::WebFileSystem::kTypeExternal: + case blink::WebFileSystemType::kWebFileSystemTypeExternal: return PP_FILESYSTEMTYPE_EXTERNAL; default: NOTREACHED(); diff --git a/chromium/content/renderer/pepper/resource_creation_impl.cc b/chromium/content/renderer/pepper/resource_creation_impl.cc index 418806ab0db..5f0db4a60a6 100644 --- a/chromium/content/renderer/pepper/resource_creation_impl.cc +++ b/chromium/content/renderer/pepper/resource_creation_impl.cc @@ -331,18 +331,10 @@ PP_Resource ResourceCreationImpl::CreateVideoDecoderDev( return PPB_VideoDecoder_Impl::Create(instance, graphics3d_id, profile); } -PP_Resource ResourceCreationImpl::CreateVideoDestination(PP_Instance instance) { - return 0; // Not supported in-process. -} - PP_Resource ResourceCreationImpl::CreateVideoEncoder(PP_Instance instance) { return 0; // Not supported in-process. } -PP_Resource ResourceCreationImpl::CreateVideoSource(PP_Instance instance) { - return 0; // Not supported in-process. -} - PP_Resource ResourceCreationImpl::CreateVpnProvider(PP_Instance instance) { return 0; // Not supported in-process. } diff --git a/chromium/content/renderer/pepper/resource_creation_impl.h b/chromium/content/renderer/pepper/resource_creation_impl.h index d89ded28eac..13b5c04435b 100644 --- a/chromium/content/renderer/pepper/resource_creation_impl.h +++ b/chromium/content/renderer/pepper/resource_creation_impl.h @@ -128,9 +128,7 @@ class ResourceCreationImpl : public ppapi::thunk::ResourceCreationAPI { PP_Resource CreateVideoDecoderDev(PP_Instance instance, PP_Resource graphics3d_id, PP_VideoDecoder_Profile profile) override; - PP_Resource CreateVideoDestination(PP_Instance instance) override; PP_Resource CreateVideoEncoder(PP_Instance instance) override; - PP_Resource CreateVideoSource(PP_Instance instance) override; PP_Resource CreateVpnProvider(PP_Instance instance) override; PP_Resource CreateWheelInputEvent(PP_Instance instance, PP_TimeTicks time_stamp, diff --git a/chromium/content/renderer/pepper/url_request_info_util.cc b/chromium/content/renderer/pepper/url_request_info_util.cc index 5108a428a42..e9f7dfa0c71 100644 --- a/chromium/content/renderer/pepper/url_request_info_util.cc +++ b/chromium/content/renderer/pepper/url_request_info_util.cc @@ -238,15 +238,13 @@ bool CreateWebURLRequest(PP_Instance instance, WebString::FromUTF8(data->custom_content_transfer_encoding)); } - if (data->has_custom_user_agent || !name_version.empty()) { + if (!name_version.empty()) + dest->SetRequestedWith(WebString::FromUTF8(name_version)); + + if (data->has_custom_user_agent) { auto extra_data = std::make_unique<RequestExtraData>(); - if (data->has_custom_user_agent) { - extra_data->set_custom_user_agent( - WebString::FromUTF8(data->custom_user_agent)); - } - if (!name_version.empty()) { - extra_data->set_requested_with(WebString::FromUTF8(name_version)); - } + extra_data->set_custom_user_agent( + WebString::FromUTF8(data->custom_user_agent)); dest->SetExtraData(std::move(extra_data)); } diff --git a/chromium/content/renderer/pepper/v8_var_converter.cc b/chromium/content/renderer/pepper/v8_var_converter.cc index 5c4319dca59..ca81eb01bab 100644 --- a/chromium/content/renderer/pepper/v8_var_converter.cc +++ b/chromium/content/renderer/pepper/v8_var_converter.cc @@ -94,7 +94,7 @@ bool GetOrCreateV8Value(v8::Local<v8::Context> context, if (ppapi::VarTracker::IsVarTypeRefcounted(var.type)) { if (parent_ids->count(var.value.as_id) != 0) return false; - VarHandleMap::iterator it = visited_ids->find(var.value.as_id); + auto it = visited_ids->find(var.value.as_id); if (it != visited_ids->end()) { *result = it->second; return true; @@ -130,8 +130,10 @@ bool GetOrCreateV8Value(v8::Local<v8::Context> context, // in the sense that string primitives in JavaScript can't be referenced // in the same way that string vars can in pepper. But that information // isn't very useful and primitive strings are a more expected form in JS. - *result = v8::String::NewFromUtf8( - isolate, value.c_str(), v8::String::kNormalString, value.size()); + *result = + v8::String::NewFromUtf8(isolate, value.c_str(), + v8::NewStringType::kNormal, value.size()) + .ToLocalChecked(); break; } case PP_VARTYPE_ARRAY_BUFFER: { @@ -399,10 +401,8 @@ bool V8VarConverter::ToV8Value(const PP_Var& var, DCHECK(current_v8->IsObject()); v8::Local<v8::Object> v8_object = current_v8.As<v8::Object>(); - for (DictionaryVar::KeyValueMap::const_iterator iter = - dict_var->key_value_map().begin(); - iter != dict_var->key_value_map().end(); - ++iter) { + for (auto iter = dict_var->key_value_map().begin(); + iter != dict_var->key_value_map().end(); ++iter) { const std::string& key = iter->first; const PP_Var& child_var = iter->second.get(); v8::Local<v8::Value> child_v8; @@ -419,10 +419,11 @@ bool V8VarConverter::ToV8Value(const PP_Var& var, if (did_create && CanHaveChildren(child_var)) stack.push_back(child_var); v8::TryCatch try_catch(isolate); - v8_object->Set( - v8::String::NewFromUtf8( - isolate, key.c_str(), v8::String::kNormalString, key.length()), - child_v8); + v8_object->Set(v8::String::NewFromUtf8(isolate, key.c_str(), + v8::NewStringType::kInternalized, + key.length()) + .ToLocalChecked(), + child_v8); if (try_catch.HasCaught()) { LOG(ERROR) << "Setter for property " << key.c_str() << " threw an " << "exception."; diff --git a/chromium/content/renderer/pepper/v8_var_converter_unittest.cc b/chromium/content/renderer/pepper/v8_var_converter_unittest.cc index 6c4bfd95190..543fb868b01 100644 --- a/chromium/content/renderer/pepper/v8_var_converter_unittest.cc +++ b/chromium/content/renderer/pepper/v8_var_converter_unittest.cc @@ -12,9 +12,9 @@ #include "base/logging.h" #include "base/memory/ref_counted.h" -#include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "base/synchronization/waitable_event.h" +#include "base/test/scoped_task_environment.h" #include "base/values.h" #include "content/renderer/pepper/resource_converter.h" #include "ppapi/c/pp_bool.h" @@ -80,7 +80,7 @@ bool Equals(const PP_Var& var, v8::Local<v8::Value> val, VarHandleMap* visited_ids) { if (ppapi::VarTracker::IsVarTypeRefcounted(var.type)) { - VarHandleMap::iterator it = visited_ids->find(var.value.as_id); + auto it = visited_ids->find(var.value.as_id); if (it != visited_ids->end()) return it->second == val; (*visited_ids)[var.value.as_id] = val; @@ -236,7 +236,8 @@ class V8VarConverterTest : public testing::Test { std::unique_ptr<V8VarConverter> converter_; private: - base::MessageLoop message_loop_; // Required to receive callbacks. + base::test::ScopedTaskEnvironment + task_environment_; // Required to receive callbacks. TestGlobals globals_; }; diff --git a/chromium/content/renderer/pepper/video_decoder_shim.cc b/chromium/content/renderer/pepper/video_decoder_shim.cc index ac45730b1c3..b7ea303d191 100644 --- a/chromium/content/renderer/pepper/video_decoder_shim.cc +++ b/chromium/content/renderer/pepper/video_decoder_shim.cc @@ -848,7 +848,7 @@ VideoDecoderShim::VideoDecoderShim( VideoDecoderShim::~VideoDecoderShim() { DCHECK(RenderThreadImpl::current()); // Delete any remaining textures. - TextureIdMap::iterator it = texture_id_map_.begin(); + auto it = texture_id_map_.begin(); for (; it != texture_id_map_.end(); ++it) DeleteTexture(it->second); texture_id_map_.clear(); @@ -1024,9 +1024,8 @@ void VideoDecoderShim::OnOutputComplete(std::unique_ptr<PendingFrame> frame) { ++it) { textures_to_dismiss_.insert(it->first); } - for (TextureIdSet::const_iterator it = available_textures_.begin(); - it != available_textures_.end(); - ++it) { + for (auto it = available_textures_.begin(); + it != available_textures_.end(); ++it) { DismissTexture(*it); } available_textures_.clear(); @@ -1049,7 +1048,7 @@ void VideoDecoderShim::SendPictures() { while (!pending_frames_.empty() && !available_textures_.empty()) { const std::unique_ptr<PendingFrame>& frame = pending_frames_.front(); - TextureIdSet::iterator it = available_textures_.begin(); + auto it = available_textures_.begin(); uint32_t texture_id = *it; available_textures_.erase(it); |