Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: ppapi/proxy/ppb_audio_input_proxy.cc

Issue 8585013: Merge definitions of PlatformFileToInt and IntToPlatformFile to one place. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add PPAPI_SHARED_EXPORT to make component build work. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ppapi/proxy/broker_dispatcher.cc ('k') | ppapi/proxy/ppb_audio_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_input_proxy.h" 5 #include "ppapi/proxy/ppb_audio_input_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/dev/ppb_audio_input_dev.h" 9 #include "ppapi/c/dev/ppb_audio_input_dev.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.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_input_impl.h" 18 #include "ppapi/shared_impl/audio_input_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/enter.h" 22 #include "ppapi/thunk/enter.h"
22 #include "ppapi/thunk/ppb_audio_config_api.h" 23 #include "ppapi/thunk/ppb_audio_config_api.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_AudioInput_API; 29 using ppapi::thunk::PPB_AudioInput_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 AudioInput : public Resource, public AudioInputImpl { 35 class AudioInput : public Resource, public AudioInputImpl {
34 public: 36 public:
35 AudioInput(const HostResource& audio_input_id, 37 AudioInput(const HostResource& audio_input_id,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 111 }
110 112
111 int32_t AudioInput::GetSyncSocket(int* sync_socket) { 113 int32_t AudioInput::GetSyncSocket(int* sync_socket) {
112 return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface. 114 return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface.
113 } 115 }
114 116
115 int32_t AudioInput::GetSharedMemory(int* shm_handle, uint32_t* shm_size) { 117 int32_t AudioInput::GetSharedMemory(int* shm_handle, uint32_t* shm_size) {
116 return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface. 118 return PP_ERROR_NOTSUPPORTED; // Don't proxy the trusted interface.
117 } 119 }
118 120
119 namespace {
120
121 base::PlatformFile IntToPlatformFile(int32_t handle) {
122 // TODO(piman/brettw): Change trusted interface to return a PP_FileHandle,
123 // those casts are ugly.
124 #if defined(OS_WIN)
125 return reinterpret_cast<HANDLE>(static_cast<intptr_t>(handle));
126 #elif defined(OS_POSIX)
127 return handle;
128 #else
129 #error Not implemented.
130 #endif
131 }
132
133 } // namespace
134
135 PPB_AudioInput_Proxy::PPB_AudioInput_Proxy(Dispatcher* dispatcher) 121 PPB_AudioInput_Proxy::PPB_AudioInput_Proxy(Dispatcher* dispatcher)
136 : InterfaceProxy(dispatcher), 122 : InterfaceProxy(dispatcher),
137 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 123 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
138 } 124 }
139 125
140 PPB_AudioInput_Proxy::~PPB_AudioInput_Proxy() { 126 PPB_AudioInput_Proxy::~PPB_AudioInput_Proxy() {
141 } 127 }
142 128
143 // static 129 // static
144 PP_Resource PPB_AudioInput_Proxy::CreateProxyResource( 130 PP_Resource PPB_AudioInput_Proxy::CreateProxyResource(
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 *foreign_shared_memory_handle = dispatcher()->ShareHandleWithRemote( 311 *foreign_shared_memory_handle = dispatcher()->ShareHandleWithRemote(
326 IntToPlatformFile(shared_memory_handle), false); 312 IntToPlatformFile(shared_memory_handle), false);
327 if (*foreign_shared_memory_handle == IPC::InvalidPlatformFileForTransit()) 313 if (*foreign_shared_memory_handle == IPC::InvalidPlatformFileForTransit())
328 return PP_ERROR_FAILED; 314 return PP_ERROR_FAILED;
329 315
330 return PP_OK; 316 return PP_OK;
331 } 317 }
332 318
333 } // namespace proxy 319 } // namespace proxy
334 } // namespace ppapi 320 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/broker_dispatcher.cc ('k') | ppapi/proxy/ppb_audio_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698