| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/proxy/ppb_audio_proxy.h" | 5 #include "ppapi/proxy/ppb_audio_proxy.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/threading/simple_thread.h" | 8 #include "base/threading/simple_thread.h" |
| 9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
| 10 #include "ppapi/c/ppb_audio.h" | 10 #include "ppapi/c/ppb_audio.h" |
| 11 #include "ppapi/c/ppb_audio_config.h" | 11 #include "ppapi/c/ppb_audio_config.h" |
| 12 #include "ppapi/c/ppb_var.h" | 12 #include "ppapi/c/ppb_var.h" |
| 13 #include "ppapi/c/trusted/ppb_audio_trusted.h" | 13 #include "ppapi/c/trusted/ppb_audio_trusted.h" |
| 14 #include "ppapi/proxy/enter_proxy.h" | 14 #include "ppapi/proxy/enter_proxy.h" |
| 15 #include "ppapi/proxy/plugin_dispatcher.h" | 15 #include "ppapi/proxy/plugin_dispatcher.h" |
| 16 #include "ppapi/proxy/ppapi_messages.h" | 16 #include "ppapi/proxy/ppapi_messages.h" |
| 17 #include "ppapi/shared_impl/api_id.h" | 17 #include "ppapi/shared_impl/api_id.h" |
| 18 #include "ppapi/shared_impl/audio_impl.h" | 18 #include "ppapi/shared_impl/audio_impl.h" |
| 19 #include "ppapi/shared_impl/platform_file.h" |
| 19 #include "ppapi/shared_impl/ppapi_globals.h" | 20 #include "ppapi/shared_impl/ppapi_globals.h" |
| 20 #include "ppapi/shared_impl/resource.h" | 21 #include "ppapi/shared_impl/resource.h" |
| 21 #include "ppapi/thunk/ppb_audio_config_api.h" | 22 #include "ppapi/thunk/ppb_audio_config_api.h" |
| 22 #include "ppapi/thunk/enter.h" | 23 #include "ppapi/thunk/enter.h" |
| 23 #include "ppapi/thunk/resource_creation_api.h" | 24 #include "ppapi/thunk/resource_creation_api.h" |
| 24 #include "ppapi/thunk/thunk.h" | 25 #include "ppapi/thunk/thunk.h" |
| 25 | 26 |
| 27 using ppapi::IntToPlatformFile; |
| 26 using ppapi::thunk::EnterResourceNoLock; | 28 using ppapi::thunk::EnterResourceNoLock; |
| 27 using ppapi::thunk::PPB_Audio_API; | 29 using ppapi::thunk::PPB_Audio_API; |
| 28 using ppapi::thunk::PPB_AudioConfig_API; | 30 using ppapi::thunk::PPB_AudioConfig_API; |
| 29 | 31 |
| 30 namespace ppapi { | 32 namespace ppapi { |
| 31 namespace proxy { | 33 namespace proxy { |
| 32 | 34 |
| 33 class Audio : public Resource, public AudioImpl { | 35 class Audio : public Resource, public AudioImpl { |
| 34 public: | 36 public: |
| 35 Audio(const HostResource& audio_id, | 37 Audio(const HostResource& audio_id, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } | 110 } |
| 109 | 111 |
| 110 int32_t Audio::GetSyncSocket(int* sync_socket) { | 112 int32_t Audio::GetSyncSocket(int* sync_socket) { |
| 111 return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface. | 113 return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface. |
| 112 } | 114 } |
| 113 | 115 |
| 114 int32_t Audio::GetSharedMemory(int* shm_handle, uint32_t* shm_size) { | 116 int32_t Audio::GetSharedMemory(int* shm_handle, uint32_t* shm_size) { |
| 115 return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface. | 117 return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface. |
| 116 } | 118 } |
| 117 | 119 |
| 118 namespace { | |
| 119 | |
| 120 base::PlatformFile IntToPlatformFile(int32_t handle) { | |
| 121 // TODO(piman/brettw): Change trusted interface to return a PP_FileHandle, | |
| 122 // those casts are ugly. | |
| 123 #if defined(OS_WIN) | |
| 124 return reinterpret_cast<HANDLE>(static_cast<intptr_t>(handle)); | |
| 125 #elif defined(OS_POSIX) | |
| 126 return handle; | |
| 127 #else | |
| 128 #error Not implemented. | |
| 129 #endif | |
| 130 } | |
| 131 | |
| 132 } // namespace | |
| 133 | |
| 134 PPB_Audio_Proxy::PPB_Audio_Proxy(Dispatcher* dispatcher) | 120 PPB_Audio_Proxy::PPB_Audio_Proxy(Dispatcher* dispatcher) |
| 135 : InterfaceProxy(dispatcher), | 121 : InterfaceProxy(dispatcher), |
| 136 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 122 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 137 } | 123 } |
| 138 | 124 |
| 139 PPB_Audio_Proxy::~PPB_Audio_Proxy() { | 125 PPB_Audio_Proxy::~PPB_Audio_Proxy() { |
| 140 } | 126 } |
| 141 | 127 |
| 142 // static | 128 // static |
| 143 PP_Resource PPB_Audio_Proxy::CreateProxyResource( | 129 PP_Resource PPB_Audio_Proxy::CreateProxyResource( |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 *foreign_shared_memory_handle = dispatcher()->ShareHandleWithRemote( | 306 *foreign_shared_memory_handle = dispatcher()->ShareHandleWithRemote( |
| 321 IntToPlatformFile(shared_memory_handle), false); | 307 IntToPlatformFile(shared_memory_handle), false); |
| 322 if (*foreign_shared_memory_handle == IPC::InvalidPlatformFileForTransit()) | 308 if (*foreign_shared_memory_handle == IPC::InvalidPlatformFileForTransit()) |
| 323 return PP_ERROR_FAILED; | 309 return PP_ERROR_FAILED; |
| 324 | 310 |
| 325 return PP_OK; | 311 return PP_OK; |
| 326 } | 312 } |
| 327 | 313 |
| 328 } // namespace proxy | 314 } // namespace proxy |
| 329 } // namespace ppapi | 315 } // namespace ppapi |
| OLD | NEW |