diff options
-rw-r--r-- | ppapi/ppapi_shared.gypi | 1 | ||||
-rw-r--r-- | ppapi/proxy/enter_proxy.h | 90 | ||||
-rw-r--r-- | ppapi/proxy/ppb_audio_proxy.cc | 70 | ||||
-rw-r--r-- | ppapi/proxy/ppb_broker_proxy.cc | 22 | ||||
-rw-r--r-- | ppapi/proxy/ppb_file_chooser_proxy.cc | 12 | ||||
-rw-r--r-- | ppapi/proxy/ppb_file_system_proxy.cc | 13 | ||||
-rw-r--r-- | ppapi/proxy/ppb_flash_menu_proxy.cc | 18 | ||||
-rw-r--r-- | ppapi/proxy/ppb_graphics_2d_proxy.cc | 14 | ||||
-rw-r--r-- | ppapi/proxy/ppb_graphics_3d_proxy.cc | 14 | ||||
-rw-r--r-- | ppapi/proxy/ppb_surface_3d_proxy.cc | 14 | ||||
-rw-r--r-- | ppapi/proxy/ppb_url_loader_proxy.cc | 17 | ||||
-rw-r--r-- | ppapi/thunk/ppb_audio_api.h | 7 | ||||
-rw-r--r-- | ppapi/thunk/ppb_audio_thunk.cc | 10 | ||||
-rw-r--r-- | ppapi/thunk/ppb_audio_trusted_api.h | 27 | ||||
-rw-r--r-- | ppapi/thunk/ppb_audio_trusted_thunk.cc | 11 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_audio_impl.cc | 19 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_audio_impl.h | 5 |
17 files changed, 205 insertions, 159 deletions
diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index fea7e66..aa46c74 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -70,7 +70,6 @@ 'thunk/ppb_audio_config_api.h', 'thunk/ppb_audio_config_thunk.cc', 'thunk/ppb_audio_thunk.cc', - 'thunk/ppb_audio_trusted_api.h', 'thunk/ppb_audio_trusted_thunk.cc', 'thunk/ppb_broker_api.h', 'thunk/ppb_broker_thunk.cc', diff --git a/ppapi/proxy/enter_proxy.h b/ppapi/proxy/enter_proxy.h index 6e52705..584ae30 100644 --- a/ppapi/proxy/enter_proxy.h +++ b/ppapi/proxy/enter_proxy.h @@ -6,6 +6,7 @@ #define PPAPI_PROXY_ENTER_PROXY_H_ #include "base/logging.h" +#include "ppapi/cpp/completion_callback.h" #include "ppapi/proxy/host_dispatcher.h" #include "ppapi/proxy/plugin_dispatcher.h" #include "ppapi/proxy/plugin_resource_tracker.h" @@ -52,6 +53,95 @@ class EnterHostFromHostResource } }; +// Enters a resource and forces a completion callback to be issued. +// +// This is used when implementing the host (renderer) side of a resource +// function that issues a completion callback. In all cases, we need to issue +// the callback to avoid hanging the plugin. +// +// This class automatically constructs a callback with the given factory +// calling the given method. The method will generally be the one that sends +// the message to trigger the completion callback in the plugin process. +// +// It will automatically issue the callback with PP_ERROR_NOINTERFACE if the +// host resource is invalid (i.e. failed() is set). In all other cases you +// should call SetResult(), which will issue the callback immediately if the +// result value isn't PP_OK_COMPLETIONPENDING. In the "completion pending" +// case, it's assumed the function the proxy is calling will take responsibility +// of executing the callback (returned by callback()). +// +// Example: +// EnterHostFromHostResourceForceCallback<PPB_Foo_API> enter( +// resource, callback_factory_, &MyClass::SendResult, resource); +// if (enter.failed()) +// return; // SendResult automatically called with PP_ERROR_BADRESOURCE. +// enter.SetResult(enter.object()->DoFoo(enter.callback())); +// +// Where DoFoo's signature looks like this: +// int32_t DoFoo(PP_CompletionCallback callback); +// And SendResult's implementation looks like this: +// void MyClass::SendResult(int32_t result, const HostResource& res) { +// Send(new FooMsg_FooComplete(..., result, res)); +// } +template<typename ResourceT> +class EnterHostFromHostResourceForceCallback + : public EnterHostFromHostResource<ResourceT> { + public: + // For callbacks that take no parameters except the "int32_t result". Most + // implementations will use the 1-extra-argument constructor below. + template<class CallbackFactory, typename Method> + EnterHostFromHostResourceForceCallback(const HostResource& host_resource, + CallbackFactory& factory, + Method method) + : EnterHostFromHostResource<ResourceT>(host_resource), + needs_running_(true), + callback_(factory.NewOptionalCallback(method)) { + if (this->failed()) + RunCallback(PP_ERROR_BADRESOURCE); + } + + // For callbacks that take an extra parameter as a closure. + template<class CallbackFactory, typename Method, typename A> + EnterHostFromHostResourceForceCallback(const HostResource& host_resource, + CallbackFactory& factory, + Method method, + const A& a) + : EnterHostFromHostResource<ResourceT>(host_resource), + needs_running_(true), + callback_(factory.NewOptionalCallback(method, a)) { + if (this->failed()) + RunCallback(PP_ERROR_BADRESOURCE); + } + + ~EnterHostFromHostResourceForceCallback() { + if (needs_running_) { + NOTREACHED() << "Should always call SetResult except in the " + "initialization failed case."; + RunCallback(PP_ERROR_FAILED); + } + } + + void SetResult(int32_t result) { + DCHECK(needs_running_) << "Don't call SetResult when there already is one."; + if (result != PP_OK_COMPLETIONPENDING) + callback_.Run(result); + } + + PP_CompletionCallback callback() { + return callback_.pp_completion_callback(); + } + + private: + void RunCallback(int32_t result) { + DCHECK(needs_running_); + needs_running_ = false; + callback_.Run(result); + } + + bool needs_running_; + pp::CompletionCallback callback_; +}; + } // namespace proxy } // namespace pp diff --git a/ppapi/proxy/ppb_audio_proxy.cc b/ppapi/proxy/ppb_audio_proxy.cc index 76f3046..f0db204 100644 --- a/ppapi/proxy/ppb_audio_proxy.cc +++ b/ppapi/proxy/ppb_audio_proxy.cc @@ -4,6 +4,7 @@ #include "ppapi/proxy/ppb_audio_proxy.h" +#include "base/compiler_specific.h" #include "base/threading/simple_thread.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/ppb_audio.h" @@ -17,12 +18,13 @@ #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/shared_impl/audio_impl.h" #include "ppapi/thunk/ppb_audio_config_api.h" -#include "ppapi/thunk/ppb_audio_trusted_api.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/resource_creation_api.h" #include "ppapi/thunk/thunk.h" -using ::ppapi::thunk::PPB_Audio_API; +using ppapi::thunk::EnterResourceNoLock; +using ppapi::thunk::PPB_Audio_API; +using ppapi::thunk::PPB_AudioConfig_API; namespace pp { namespace proxy { @@ -42,6 +44,10 @@ class Audio : public PluginResource, public ppapi::AudioImpl { virtual PP_Resource GetCurrentConfig() OVERRIDE; virtual PP_Bool StartPlayback() OVERRIDE; virtual PP_Bool StopPlayback() OVERRIDE; + virtual int32_t OpenTrusted(PP_Resource config_id, + PP_CompletionCallback create_callback) OVERRIDE; + virtual int32_t GetSyncSocket(int* sync_socket) OVERRIDE; + virtual int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) OVERRIDE; private: // Owning reference to the current config object. This isn't actually used, @@ -95,6 +101,19 @@ PP_Bool Audio::StopPlayback() { return PP_TRUE; } +int32_t Audio::OpenTrusted(PP_Resource config_id, + PP_CompletionCallback create_callback) { + return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface. +} + +int32_t Audio::GetSyncSocket(int* sync_socket) { + return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface. +} + +int32_t Audio::GetSharedMemory(int* shm_handle, uint32_t* shm_size) { + return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface. +} + namespace { InterfaceProxy* CreateAudioProxy(Dispatcher* dispatcher, @@ -147,8 +166,7 @@ PP_Resource PPB_Audio_Proxy::CreateProxyResource( if (!dispatcher) return 0; - ::ppapi::thunk::EnterResourceNoLock< ::ppapi::thunk::PPB_AudioConfig_API> - config(config_id, true); + EnterResourceNoLock<PPB_AudioConfig_API> config(config_id, true); if (config.failed()) return 0; @@ -193,26 +211,35 @@ void PPB_Audio_Proxy::OnMsgCreate(PP_Instance instance_id, resource_creation.functions()->CreateAudioTrusted(instance_id)); if (result->is_null()) return; - ::ppapi::thunk::EnterResourceNoLock< ::ppapi::thunk::PPB_AudioTrusted_API> - trusted_audio(result->host_resource(), false); - if (trusted_audio.failed()) - return; + + // At this point, we've set the result resource, and this is a sync request. + // Anything below this point must issue the AudioChannelConnected callback + // to the browser. Since that's an async message, it will be issued back to + // the plugin after the Create function returns (which is good because it + // would be weird to get a connected message with a failure code for a + // resource you haven't finished creating yet). + // + // The ...ForceCallback class will help ensure the callback is always called. + // All error cases must call SetResult on this class. + EnterHostFromHostResourceForceCallback<PPB_Audio_API> enter( + *result, callback_factory_, + &PPB_Audio_Proxy::AudioChannelConnected, *result); + if (enter.failed()) + return; // When enter fails, it will internally schedule the callback. // Make an audio config object. PP_Resource audio_config_res = resource_creation.functions()->CreateAudioConfig( instance_id, static_cast<PP_AudioSampleRate>(sample_rate), sample_frame_count); - if (!audio_config_res) + if (!audio_config_res) { + enter.SetResult(PP_ERROR_FAILED); return; + } // Initiate opening the audio object. - CompletionCallback callback = callback_factory_.NewOptionalCallback( - &PPB_Audio_Proxy::AudioChannelConnected, *result); - int32_t open_error = trusted_audio.object()->OpenTrusted( - audio_config_res, callback.pp_completion_callback()); - if (open_error != PP_OK_COMPLETIONPENDING) - callback.Run(open_error); + enter.SetResult(enter.object()->OpenTrusted(audio_config_res, + enter.callback())); // Clean up the temporary audio config resource we made. const PPB_Core* core = static_cast<const PPB_Core*>( @@ -280,15 +307,14 @@ int32_t PPB_Audio_Proxy::GetAudioConnectedHandles( IPC::PlatformFileForTransit* foreign_socket_handle, base::SharedMemoryHandle* foreign_shared_memory_handle, uint32_t* shared_memory_length) { - // Get the trusted audio interface which will give us the handles. - ::ppapi::thunk::EnterResourceNoLock< ::ppapi::thunk::PPB_AudioTrusted_API> - trusted_audio(resource.host_resource(), false); - if (trusted_audio.failed()) + // Get the audio interface which will give us the handles. + EnterResourceNoLock<PPB_Audio_API> enter(resource.host_resource(), false); + if (enter.failed()) return PP_ERROR_NOINTERFACE; // Get the socket handle for signaling. int32_t socket_handle; - int32_t result = trusted_audio.object()->GetSyncSocket(&socket_handle); + int32_t result = enter.object()->GetSyncSocket(&socket_handle); if (result != PP_OK) return result; @@ -300,8 +326,8 @@ int32_t PPB_Audio_Proxy::GetAudioConnectedHandles( // Get the shared memory for the buffer. int shared_memory_handle; - result = trusted_audio.object()->GetSharedMemory(&shared_memory_handle, - shared_memory_length); + result = enter.object()->GetSharedMemory(&shared_memory_handle, + shared_memory_length); if (result != PP_OK) return result; diff --git a/ppapi/proxy/ppb_broker_proxy.cc b/ppapi/proxy/ppb_broker_proxy.cc index 37f8ba0..637c6a0 100644 --- a/ppapi/proxy/ppb_broker_proxy.cc +++ b/ppapi/proxy/ppb_broker_proxy.cc @@ -14,6 +14,8 @@ #include "ppapi/thunk/enter.h" #include "ppapi/thunk/thunk.h" +using ppapi::thunk::PPB_Broker_API; + namespace pp { namespace proxy { @@ -46,14 +48,13 @@ InterfaceProxy* CreateBrokerProxy(Dispatcher* dispatcher, } // namespace -class Broker : public ppapi::thunk::PPB_Broker_API, - public PluginResource { +class Broker : public PPB_Broker_API, public PluginResource { public: explicit Broker(const HostResource& resource); virtual ~Broker(); // ResourceObjectBase overries. - virtual ppapi::thunk::PPB_Broker_API* AsPPB_Broker_API() OVERRIDE; + virtual PPB_Broker_API* AsPPB_Broker_API() OVERRIDE; // PPB_Broker_API implementation. virtual int32_t Connect(PP_CompletionCallback connect_callback) OVERRIDE; @@ -96,7 +97,7 @@ Broker::~Broker() { socket_handle_ = base::kInvalidPlatformFileValue; } -ppapi::thunk::PPB_Broker_API* Broker::AsPPB_Broker_API() { +PPB_Broker_API* Broker::AsPPB_Broker_API() { return this; } @@ -204,14 +205,11 @@ void PPB_Broker_Proxy::OnMsgCreate(PP_Instance instance, } void PPB_Broker_Proxy::OnMsgConnect(const HostResource& broker) { - CompletionCallback callback = callback_factory_.NewOptionalCallback( + EnterHostFromHostResourceForceCallback<PPB_Broker_API> enter( + broker, callback_factory_, &PPB_Broker_Proxy::ConnectCompleteInHost, broker); - - int32_t result = ppb_broker_target()->Connect( - broker.host_resource(), - callback.pp_completion_callback()); - if (result != PP_OK_COMPLETIONPENDING) - callback.Run(result); + if (enter.succeeded()) + enter.SetResult(enter.object()->Connect(enter.callback())); } // Called in the plugin to handle the connect callback. @@ -225,7 +223,7 @@ void PPB_Broker_Proxy::OnMsgConnectComplete( DCHECK(result == PP_OK || socket_handle == IPC::InvalidPlatformFileForTransit()); - EnterPluginFromHostResource<ppapi::thunk::PPB_Broker_API> enter(resource); + EnterPluginFromHostResource<PPB_Broker_API> enter(resource); if (enter.failed()) { // As in Broker::ConnectComplete, we need to close the resource on error. base::SyncSocket temp_socket( diff --git a/ppapi/proxy/ppb_file_chooser_proxy.cc b/ppapi/proxy/ppb_file_chooser_proxy.cc index cda175f..d8ea705 100644 --- a/ppapi/proxy/ppb_file_chooser_proxy.cc +++ b/ppapi/proxy/ppb_file_chooser_proxy.cc @@ -194,13 +194,11 @@ void PPB_FileChooser_Proxy::OnMsgCreate(PP_Instance instance, } void PPB_FileChooser_Proxy::OnMsgShow(const HostResource& chooser) { - CompletionCallback callback = callback_factory_.NewOptionalCallback( - &PPB_FileChooser_Proxy::OnShowCallback, chooser); - - int32_t result = ppb_file_chooser_target()->Show( - chooser.host_resource(), callback.pp_completion_callback()); - if (result != PP_OK_COMPLETIONPENDING) - callback.Run(result); + EnterHostFromHostResourceForceCallback<PPB_FileChooser_API> enter( + chooser, callback_factory_, &PPB_FileChooser_Proxy::OnShowCallback, + chooser); + if (enter.succeeded()) + enter.SetResult(enter.object()->Show(enter.callback())); } void PPB_FileChooser_Proxy::OnMsgChooseComplete( diff --git a/ppapi/proxy/ppb_file_system_proxy.cc b/ppapi/proxy/ppb_file_system_proxy.cc index 1edf5d7..c13a163 100644 --- a/ppapi/proxy/ppb_file_system_proxy.cc +++ b/ppapi/proxy/ppb_file_system_proxy.cc @@ -174,16 +174,11 @@ void PPB_FileSystem_Proxy::OnMsgCreate(PP_Instance instance, void PPB_FileSystem_Proxy::OnMsgOpen(const HostResource& host_resource, int64_t expected_size) { - EnterHostFromHostResource<PPB_FileSystem_API> enter(host_resource); - if (enter.failed()) - return; - - CompletionCallback callback = callback_factory_.NewOptionalCallback( + EnterHostFromHostResourceForceCallback<PPB_FileSystem_API> enter( + host_resource, callback_factory_, &PPB_FileSystem_Proxy::OpenCompleteInHost, host_resource); - int32_t result = enter.object()->Open(expected_size, - callback.pp_completion_callback()); - if (result != PP_OK_COMPLETIONPENDING) - callback.Run(result); + if (enter.succeeded()) + enter.SetResult(enter.object()->Open(expected_size, enter.callback())); } // Called in the plugin to handle the open callback. diff --git a/ppapi/proxy/ppb_flash_menu_proxy.cc b/ppapi/proxy/ppb_flash_menu_proxy.cc index c42c10e..a9c195c 100644 --- a/ppapi/proxy/ppb_flash_menu_proxy.cc +++ b/ppapi/proxy/ppb_flash_menu_proxy.cc @@ -162,21 +162,13 @@ void PPB_Flash_Menu_Proxy::OnMsgShow(const HostResource& menu, const PP_Point& location) { ShowRequest* request = new ShowRequest; request->menu = menu; - CompletionCallback callback = callback_factory_.NewOptionalCallback( - &PPB_Flash_Menu_Proxy::SendShowACKToPlugin, request); - EnterHostFromHostResource<PPB_Flash_Menu_API> enter(menu); - int32_t result = PP_ERROR_BADRESOURCE; + EnterHostFromHostResourceForceCallback<PPB_Flash_Menu_API> enter( + menu, callback_factory_, &PPB_Flash_Menu_Proxy::SendShowACKToPlugin, + request); if (enter.succeeded()) { - result = enter.object()->Show(&location, - &request->selected_id, - callback.pp_completion_callback()); - } - if (result != PP_OK_COMPLETIONPENDING) { - // There was some error, so we won't get a callback. We need to now issue - // the ACK to the plugin so that it hears about the error. This will also - // clean up the data associated with the callback. - callback.Run(result); + enter.SetResult(enter.object()->Show(&location, &request->selected_id, + enter.callback())); } } diff --git a/ppapi/proxy/ppb_graphics_2d_proxy.cc b/ppapi/proxy/ppb_graphics_2d_proxy.cc index 0f8a247..c74e244d 100644 --- a/ppapi/proxy/ppb_graphics_2d_proxy.cc +++ b/ppapi/proxy/ppb_graphics_2d_proxy.cc @@ -240,16 +240,12 @@ void PPB_Graphics2D_Proxy::OnMsgReplaceContents( } void PPB_Graphics2D_Proxy::OnMsgFlush(const HostResource& graphics_2d) { - CompletionCallback callback = callback_factory_.NewOptionalCallback( + EnterHostFromHostResourceForceCallback<PPB_Graphics2D_API> enter( + graphics_2d, callback_factory_, &PPB_Graphics2D_Proxy::SendFlushACKToPlugin, graphics_2d); - int32_t result = ppb_graphics_2d_target()->Flush( - graphics_2d.host_resource(), callback.pp_completion_callback()); - if (result != PP_OK_COMPLETIONPENDING) { - // There was some error, so we won't get a flush callback. We need to now - // issue the ACK to the plugin hears about the error. This will also clean - // up the data associated with the callback. - callback.Run(result); - } + if (enter.failed()) + return; + enter.SetResult(enter.object()->Flush(enter.callback())); } void PPB_Graphics2D_Proxy::OnMsgFlushACK(const HostResource& host_resource, diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.cc b/ppapi/proxy/ppb_graphics_3d_proxy.cc index 480f06b..11250d9 100644 --- a/ppapi/proxy/ppb_graphics_3d_proxy.cc +++ b/ppapi/proxy/ppb_graphics_3d_proxy.cc @@ -587,19 +587,11 @@ void PPB_Graphics3D_Proxy::OnMsgGetTransferBuffer( } void PPB_Graphics3D_Proxy::OnMsgSwapBuffers(const HostResource& context) { - CompletionCallback callback = callback_factory_.NewOptionalCallback( + EnterHostFromHostResourceForceCallback<PPB_Graphics3D_API> enter( + context, callback_factory_, &PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin, context); - - EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); - int32_t result = PP_ERROR_BADRESOURCE; if (enter.succeeded()) - result = enter.object()->SwapBuffers(callback.pp_completion_callback()); - if (result != PP_OK_COMPLETIONPENDING) { - // There was some error, so we won't get a flush callback. We need to now - // issue the ACK to the plugin hears about the error. This will also clean - // up the data associated with the callback. - callback.Run(result); - } + enter.SetResult(enter.object()->SwapBuffers(enter.callback())); } void PPB_Graphics3D_Proxy::OnMsgSwapBuffersACK(const HostResource& resource, diff --git a/ppapi/proxy/ppb_surface_3d_proxy.cc b/ppapi/proxy/ppb_surface_3d_proxy.cc index c0288d0..2e432bc 100644 --- a/ppapi/proxy/ppb_surface_3d_proxy.cc +++ b/ppapi/proxy/ppb_surface_3d_proxy.cc @@ -177,19 +177,11 @@ void PPB_Surface3D_Proxy::OnMsgCreate(PP_Instance instance, } void PPB_Surface3D_Proxy::OnMsgSwapBuffers(const HostResource& surface_3d) { - CompletionCallback callback = callback_factory_.NewOptionalCallback( + EnterHostFromHostResourceForceCallback<PPB_Surface3D_API> enter( + surface_3d, callback_factory_, &PPB_Surface3D_Proxy::SendSwapBuffersACKToPlugin, surface_3d); - - EnterHostFromHostResource<PPB_Surface3D_API> enter(surface_3d); - int32_t result = PP_ERROR_BADRESOURCE; if (enter.succeeded()) - result = enter.object()->SwapBuffers(callback.pp_completion_callback()); - if (result != PP_OK_COMPLETIONPENDING) { - // There was some error, so we won't get a flush callback. We need to now - // issue the ACK to the plugin hears about the error. This will also clean - // up the data associated with the callback. - callback.Run(result); - } + enter.SetResult(enter.object()->SwapBuffers(enter.callback())); } void PPB_Surface3D_Proxy::OnMsgSwapBuffersACK(const HostResource& resource, diff --git a/ppapi/proxy/ppb_url_loader_proxy.cc b/ppapi/proxy/ppb_url_loader_proxy.cc index b2d6276..1fc4db1 100644 --- a/ppapi/proxy/ppb_url_loader_proxy.cc +++ b/ppapi/proxy/ppb_url_loader_proxy.cc @@ -517,21 +517,12 @@ void PPB_URLLoader_Proxy::OnMsgReadResponseBody( // TODO(brettw) have a way to check for out-of-memory. info->read_buffer.resize(bytes_to_read); - CompletionCallback callback = callback_factory_.NewOptionalCallback( - &PPB_URLLoader_Proxy::OnReadCallback, info); - - EnterHostFromHostResource<PPB_URLLoader_API> enter(loader); - int32_t result = PP_ERROR_BADRESOURCE; + EnterHostFromHostResourceForceCallback<PPB_URLLoader_API> enter( + loader, callback_factory_, &PPB_URLLoader_Proxy::OnReadCallback, info); if (enter.succeeded()) { - result = enter.object()->ReadResponseBody( + enter.SetResult(enter.object()->ReadResponseBody( const_cast<char*>(info->read_buffer.c_str()), - bytes_to_read, callback.pp_completion_callback()); - } - if (result != PP_OK_COMPLETIONPENDING) { - // Send error (or perhaps success for synchronous reads) back to plugin. - // The callback function is already set up to do this and also delete the - // callback info. - callback.Run(result); + bytes_to_read, enter.callback())); } } diff --git a/ppapi/thunk/ppb_audio_api.h b/ppapi/thunk/ppb_audio_api.h index d105e1c..3d21299 100644 --- a/ppapi/thunk/ppb_audio_api.h +++ b/ppapi/thunk/ppb_audio_api.h @@ -5,6 +5,7 @@ #ifndef PPAPI_THUNK_AUDIO_API_H_ #define PPAPI_THUNK_AUDIO_API_H_ +#include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/ppb_audio.h" namespace ppapi { @@ -17,6 +18,12 @@ class PPB_Audio_API { virtual PP_Resource GetCurrentConfig() = 0; virtual PP_Bool StartPlayback() = 0; virtual PP_Bool StopPlayback() = 0; + + // Trusted API. + virtual int32_t OpenTrusted(PP_Resource config_id, + PP_CompletionCallback create_callback) = 0; + virtual int32_t GetSyncSocket(int* sync_socket) = 0; + virtual int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) = 0; }; } // namespace thunk diff --git a/ppapi/thunk/ppb_audio_thunk.cc b/ppapi/thunk/ppb_audio_thunk.cc index 426ba29..18b70b6 100644 --- a/ppapi/thunk/ppb_audio_thunk.cc +++ b/ppapi/thunk/ppb_audio_thunk.cc @@ -12,6 +12,8 @@ namespace thunk { namespace { +typedef EnterResource<PPB_Audio_API> EnterAudio; + PP_Resource Create(PP_Instance instance, PP_Resource config_id, PPB_Audio_Callback callback, @@ -24,26 +26,26 @@ PP_Resource Create(PP_Instance instance, } PP_Bool IsAudio(PP_Resource resource) { - EnterResource<PPB_Audio_API> enter(resource, false); + EnterAudio enter(resource, false); return enter.succeeded() ? PP_TRUE : PP_FALSE; } PP_Resource GetCurrentConfiguration(PP_Resource audio_id) { - EnterResource<PPB_Audio_API> enter(audio_id, true); + EnterAudio enter(audio_id, true); if (enter.failed()) return 0; return enter.object()->GetCurrentConfig(); } PP_Bool StartPlayback(PP_Resource audio_id) { - EnterResource<PPB_Audio_API> enter(audio_id, true); + EnterAudio enter(audio_id, true); if (enter.failed()) return PP_FALSE; return enter.object()->StartPlayback(); } PP_Bool StopPlayback(PP_Resource audio_id) { - EnterResource<PPB_Audio_API> enter(audio_id, true); + EnterAudio enter(audio_id, true); if (enter.failed()) return PP_FALSE; return enter.object()->StopPlayback(); diff --git a/ppapi/thunk/ppb_audio_trusted_api.h b/ppapi/thunk/ppb_audio_trusted_api.h deleted file mode 100644 index de4b79a..0000000 --- a/ppapi/thunk/ppb_audio_trusted_api.h +++ /dev/null @@ -1,27 +0,0 @@ -// 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. - -#ifndef PPAPI_THUNK_AUDIO_TRUSTED_API_H_ -#define PPAPI_THUNK_AUDIO_TRUSTED_API_H_ - -#include "ppapi/c/trusted/ppb_audio_trusted.h" -#include "ppapi/c/ppb_audio.h" - -namespace ppapi { -namespace thunk { - -class PPB_AudioTrusted_API { - public: - virtual ~PPB_AudioTrusted_API() {} - - virtual int32_t OpenTrusted(PP_Resource config_id, - PP_CompletionCallback create_callback) = 0; - virtual int32_t GetSyncSocket(int* sync_socket) = 0; - virtual int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) = 0; -}; - -} // namespace thunk -} // namespace ppapi - -#endif // PPAPI_THUNK_AUDIO_TRUSTED_API_H_ diff --git a/ppapi/thunk/ppb_audio_trusted_thunk.cc b/ppapi/thunk/ppb_audio_trusted_thunk.cc index 05c1b4e..97f8978 100644 --- a/ppapi/thunk/ppb_audio_trusted_thunk.cc +++ b/ppapi/thunk/ppb_audio_trusted_thunk.cc @@ -3,10 +3,11 @@ // found in the LICENSE file. #include "ppapi/c/pp_errors.h" +#include "ppapi/c/trusted/ppb_audio_trusted.h" #include "ppapi/thunk/common.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/thunk.h" -#include "ppapi/thunk/ppb_audio_trusted_api.h" +#include "ppapi/thunk/ppb_audio_api.h" #include "ppapi/thunk/resource_creation_api.h" namespace ppapi { @@ -14,6 +15,8 @@ namespace thunk { namespace { +typedef EnterResource<PPB_Audio_API> EnterAudio; + PP_Resource Create(PP_Instance instance_id) { EnterFunction<ResourceCreationAPI> enter(instance_id, true); if (enter.failed()) @@ -24,7 +27,7 @@ PP_Resource Create(PP_Instance instance_id) { int32_t Open(PP_Resource audio_id, PP_Resource config_id, PP_CompletionCallback create_callback) { - EnterResource<PPB_AudioTrusted_API> enter(audio_id, true); + EnterAudio enter(audio_id, true); if (enter.failed()) return MayForceCallback(create_callback, PP_ERROR_BADRESOURCE); int32_t result = enter.object()->OpenTrusted(config_id, create_callback); @@ -32,7 +35,7 @@ int32_t Open(PP_Resource audio_id, } int32_t GetSyncSocket(PP_Resource audio_id, int* sync_socket) { - EnterResource<PPB_AudioTrusted_API> enter(audio_id, true); + EnterAudio enter(audio_id, true); if (enter.failed()) return PP_ERROR_BADRESOURCE; return enter.object()->GetSyncSocket(sync_socket); @@ -41,7 +44,7 @@ int32_t GetSyncSocket(PP_Resource audio_id, int* sync_socket) { int32_t GetSharedMemory(PP_Resource audio_id, int* shm_handle, uint32_t* shm_size) { - EnterResource<PPB_AudioTrusted_API> enter(audio_id, true); + EnterAudio enter(audio_id, true); if (enter.failed()) return PP_ERROR_BADRESOURCE; return enter.object()->GetSharedMemory(shm_handle, shm_size); diff --git a/webkit/plugins/ppapi/ppb_audio_impl.cc b/webkit/plugins/ppapi/ppb_audio_impl.cc index 1dc64e6..4c74181 100644 --- a/webkit/plugins/ppapi/ppb_audio_impl.cc +++ b/webkit/plugins/ppapi/ppb_audio_impl.cc @@ -14,6 +14,10 @@ #include "ppapi/thunk/thunk.h" #include "webkit/plugins/ppapi/common.h" +using ppapi::thunk::EnterResourceNoLock; +using ppapi::thunk::PPB_Audio_API; +using ppapi::thunk::PPB_AudioConfig_API; + namespace webkit { namespace ppapi { @@ -37,8 +41,7 @@ PP_Resource PPB_AudioConfig_Impl::Create(PluginInstance* instance, return config->GetReference(); } -::ppapi::thunk::PPB_AudioConfig_API* -PPB_AudioConfig_Impl::AsPPB_AudioConfig_API() { +PPB_AudioConfig_API* PPB_AudioConfig_Impl::AsPPB_AudioConfig_API() { return this; } @@ -86,19 +89,14 @@ PP_Resource PPB_Audio_Impl::Create(PluginInstance* instance, return audio->GetReference(); } -::ppapi::thunk::PPB_Audio_API* PPB_Audio_Impl::AsPPB_Audio_API() { - return this; -} - -::ppapi::thunk::PPB_AudioTrusted_API* PPB_Audio_Impl::AsPPB_AudioTrusted_API() { +PPB_Audio_API* PPB_Audio_Impl::AsPPB_Audio_API() { return this; } bool PPB_Audio_Impl::Init(PP_Resource config_id, PPB_Audio_Callback callback, void* user_data) { // Validate the config and keep a reference to it. - ::ppapi::thunk::EnterResourceNoLock< ::ppapi::thunk::PPB_AudioConfig_API> - enter(config_id, true); + EnterResourceNoLock<PPB_AudioConfig_API> enter(config_id, true); if (enter.failed()) return false; config_id_ = config_id; @@ -147,8 +145,7 @@ int32_t PPB_Audio_Impl::OpenTrusted(PP_Resource config_id, PP_CompletionCallback create_callback) { // Validate the config and keep a reference to it. - ::ppapi::thunk::EnterResourceNoLock< ::ppapi::thunk::PPB_AudioConfig_API> - enter(config_id, true); + EnterResourceNoLock<PPB_AudioConfig_API> enter(config_id, true); if (enter.failed()) return false; config_id_ = config_id; diff --git a/webkit/plugins/ppapi/ppb_audio_impl.h b/webkit/plugins/ppapi/ppb_audio_impl.h index 3fbd8fa..2a3ae8a 100644 --- a/webkit/plugins/ppapi/ppb_audio_impl.h +++ b/webkit/plugins/ppapi/ppb_audio_impl.h @@ -15,7 +15,6 @@ #include "ppapi/c/trusted/ppb_audio_trusted.h" #include "ppapi/shared_impl/audio_config_impl.h" #include "ppapi/shared_impl/audio_impl.h" -#include "ppapi/thunk/ppb_audio_trusted_api.h" #include "webkit/plugins/ppapi/plugin_delegate.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" #include "webkit/plugins/ppapi/resource.h" @@ -49,7 +48,6 @@ class PPB_AudioConfig_Impl : public Resource, // AudioImpl so it can be shared with the proxy. class PPB_Audio_Impl : public Resource, public ::ppapi::AudioImpl, - public ::ppapi::thunk::PPB_AudioTrusted_API, public PluginDelegate::PlatformAudio::Client { public: // Trusted initialization. You must call Init after this. @@ -73,14 +71,11 @@ class PPB_Audio_Impl : public Resource, // ResourceObjectBase overrides. virtual ::ppapi::thunk::PPB_Audio_API* AsPPB_Audio_API(); - virtual ::ppapi::thunk::PPB_AudioTrusted_API* AsPPB_AudioTrusted_API(); // PPB_Audio_API implementation. virtual PP_Resource GetCurrentConfig() OVERRIDE; virtual PP_Bool StartPlayback() OVERRIDE; virtual PP_Bool StopPlayback() OVERRIDE; - - // PPB_AudioTrusted_API implementation. virtual int32_t OpenTrusted(PP_Resource config_id, PP_CompletionCallback create_callback) OVERRIDE; virtual int32_t GetSyncSocket(int* sync_socket) OVERRIDE; |