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

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

Issue 7006022: Revert 87415 - Convert more interfaces to the new thunk system. This goes up to and including (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/ppb_audio_config_proxy.cc ('k') | ppapi/proxy/ppb_broker_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_proxy.h" 5 #include "ppapi/proxy/ppb_audio_proxy.h"
6 6
7 #include "base/threading/simple_thread.h" 7 #include "base/threading/simple_thread.h"
8 #include "ppapi/c/pp_errors.h" 8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/c/ppb_audio.h" 9 #include "ppapi/c/ppb_audio.h"
10 #include "ppapi/c/ppb_audio_config.h" 10 #include "ppapi/c/ppb_audio_config.h"
11 #include "ppapi/c/ppb_var.h" 11 #include "ppapi/c/ppb_var.h"
12 #include "ppapi/c/trusted/ppb_audio_trusted.h" 12 #include "ppapi/c/trusted/ppb_audio_trusted.h"
13 #include "ppapi/proxy/enter_proxy.h"
14 #include "ppapi/proxy/interface_id.h" 13 #include "ppapi/proxy/interface_id.h"
15 #include "ppapi/proxy/plugin_dispatcher.h" 14 #include "ppapi/proxy/plugin_dispatcher.h"
16 #include "ppapi/proxy/plugin_resource.h" 15 #include "ppapi/proxy/plugin_resource.h"
17 #include "ppapi/proxy/ppapi_messages.h" 16 #include "ppapi/proxy/ppapi_messages.h"
18 #include "ppapi/shared_impl/audio_impl.h" 17 #include "ppapi/shared_impl/audio_impl.h"
19 #include "ppapi/thunk/ppb_audio_config_api.h" 18 #include "ppapi/thunk/ppb_audio_config_api.h"
20 #include "ppapi/thunk/ppb_audio_trusted_api.h" 19 #include "ppapi/thunk/ppb_audio_trusted_api.h"
21 #include "ppapi/thunk/enter.h" 20 #include "ppapi/thunk/enter.h"
22 #include "ppapi/thunk/resource_creation_api.h" 21 #include "ppapi/thunk/resource_creation_api.h"
23 #include "ppapi/thunk/thunk.h" 22 #include "ppapi/thunk/thunk.h"
24 23
25 using ::ppapi::thunk::PPB_Audio_API;
26
27 namespace pp { 24 namespace pp {
28 namespace proxy { 25 namespace proxy {
29 26
30 class Audio : public PluginResource, public ppapi::AudioImpl { 27 class Audio : public PluginResource, public ppapi::AudioImpl {
31 public: 28 public:
32 Audio(const HostResource& audio_id, 29 Audio(const HostResource& audio_id,
33 PP_Resource config_id, 30 PP_Resource config_id,
34 PPB_Audio_Callback callback, 31 PPB_Audio_Callback callback,
35 void* user_data); 32 void* user_data);
36 virtual ~Audio(); 33 virtual ~Audio();
37 34
38 // ResourceObjectBase overrides. 35 // ResourceObjectBase overrides.
39 virtual PPB_Audio_API* AsPPB_Audio_API(); 36 virtual ::ppapi::thunk::PPB_Audio_API* AsAudio_API();
40 37
41 // PPB_Audio_API implementation. 38 // PPB_Audio_API implementation.
42 virtual PP_Resource GetCurrentConfig() OVERRIDE; 39 virtual PP_Resource GetCurrentConfig() OVERRIDE;
43 virtual PP_Bool StartPlayback() OVERRIDE; 40 virtual PP_Bool StartPlayback() OVERRIDE;
44 virtual PP_Bool StopPlayback() OVERRIDE; 41 virtual PP_Bool StopPlayback() OVERRIDE;
45 42
46 private: 43 private:
47 // Owning reference to the current config object. This isn't actually used, 44 // Owning reference to the current config object. This isn't actually used,
48 // we just dish it out as requested by the plugin. 45 // we just dish it out as requested by the plugin.
49 PP_Resource config_; 46 PP_Resource config_;
50 47
51 DISALLOW_COPY_AND_ASSIGN(Audio); 48 DISALLOW_COPY_AND_ASSIGN(Audio);
52 }; 49 };
53 50
54 Audio::Audio(const HostResource& audio_id, 51 Audio::Audio(const HostResource& audio_id,
55 PP_Resource config_id, 52 PP_Resource config_id,
56 PPB_Audio_Callback callback, 53 PPB_Audio_Callback callback,
57 void* user_data) 54 void* user_data)
58 : PluginResource(audio_id), 55 : PluginResource(audio_id),
59 config_(config_id) { 56 config_(config_id) {
60 SetCallback(callback, user_data); 57 SetCallback(callback, user_data);
61 PluginResourceTracker::GetInstance()->AddRefResource(config_); 58 PluginResourceTracker::GetInstance()->AddRefResource(config_);
62 } 59 }
63 60
64 Audio::~Audio() { 61 Audio::~Audio() {
65 PluginResourceTracker::GetInstance()->ReleaseResource(config_); 62 PluginResourceTracker::GetInstance()->ReleaseResource(config_);
66 } 63 }
67 64
68 PPB_Audio_API* Audio::AsPPB_Audio_API() { 65 ::ppapi::thunk::PPB_Audio_API* Audio::AsAudio_API() {
69 return this; 66 return this;
70 } 67 }
71 68
72 PP_Resource Audio::GetCurrentConfig() { 69 PP_Resource Audio::GetCurrentConfig() {
73 // AddRef for the caller. 70 // AddRef for the caller.
74 PluginResourceTracker::GetInstance()->AddRefResource(config_); 71 PluginResourceTracker::GetInstance()->AddRefResource(config_);
75 return config_; 72 return config_;
76 } 73 }
77 74
78 PP_Bool Audio::StartPlayback() { 75 PP_Bool Audio::StartPlayback() {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 ppb_audio_target()->StopPlayback(audio_id.host_resource()); 225 ppb_audio_target()->StopPlayback(audio_id.host_resource());
229 } 226 }
230 227
231 // Processed in the plugin (message from host). 228 // Processed in the plugin (message from host).
232 void PPB_Audio_Proxy::OnMsgNotifyAudioStreamCreated( 229 void PPB_Audio_Proxy::OnMsgNotifyAudioStreamCreated(
233 const HostResource& audio_id, 230 const HostResource& audio_id,
234 int32_t result_code, 231 int32_t result_code,
235 IPC::PlatformFileForTransit socket_handle, 232 IPC::PlatformFileForTransit socket_handle,
236 base::SharedMemoryHandle handle, 233 base::SharedMemoryHandle handle,
237 uint32_t length) { 234 uint32_t length) {
238 EnterPluginFromHostResource<PPB_Audio_API> enter(audio_id); 235 PP_Resource plugin_resource =
236 PluginResourceTracker::GetInstance()->PluginResourceForHostResource(
237 audio_id);
238 ppapi::thunk::EnterResource<ppapi::thunk::PPB_Audio_API> enter(
239 plugin_resource, false);
239 if (enter.failed() || result_code != PP_OK) { 240 if (enter.failed() || result_code != PP_OK) {
240 // The caller may still have given us these handles in the failure case. 241 // The caller may still have given us these handles in the failure case.
241 // The easiest way to clean these up is to just put them in the objects 242 // The easiest way to clean these up is to just put them in the objects
242 // and then close them. This failure case is not performance critical. 243 // and then close them. This failure case is not performance critical.
243 base::SyncSocket temp_socket( 244 base::SyncSocket temp_socket(
244 IPC::PlatformFileForTransitToPlatformFile(socket_handle)); 245 IPC::PlatformFileForTransitToPlatformFile(socket_handle));
245 base::SharedMemory temp_mem(handle, false); 246 base::SharedMemory temp_mem(handle, false);
246 } else { 247 return;
247 static_cast<Audio*>(enter.object())->SetStreamInfo(
248 handle, length,
249 IPC::PlatformFileForTransitToPlatformFile(socket_handle));
250 } 248 }
249 Audio* audio = static_cast<Audio*>(enter.object());
250 audio->SetStreamInfo(
251 handle, length, IPC::PlatformFileForTransitToPlatformFile(socket_handle));
251 } 252 }
252 253
253 void PPB_Audio_Proxy::AudioChannelConnected( 254 void PPB_Audio_Proxy::AudioChannelConnected(
254 int32_t result, 255 int32_t result,
255 const HostResource& resource) { 256 const HostResource& resource) {
256 IPC::PlatformFileForTransit socket_handle = 257 IPC::PlatformFileForTransit socket_handle =
257 IPC::InvalidPlatformFileForTransit(); 258 IPC::InvalidPlatformFileForTransit();
258 base::SharedMemoryHandle shared_memory = IPC::InvalidPlatformFileForTransit(); 259 base::SharedMemoryHandle shared_memory = IPC::InvalidPlatformFileForTransit();
259 uint32_t shared_memory_length = 0; 260 uint32_t shared_memory_length = 0;
260 261
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 *foreign_shared_memory_handle = dispatcher()->ShareHandleWithRemote( 310 *foreign_shared_memory_handle = dispatcher()->ShareHandleWithRemote(
310 IntToPlatformFile(shared_memory_handle), false); 311 IntToPlatformFile(shared_memory_handle), false);
311 if (*foreign_shared_memory_handle == IPC::InvalidPlatformFileForTransit()) 312 if (*foreign_shared_memory_handle == IPC::InvalidPlatformFileForTransit())
312 return PP_ERROR_FAILED; 313 return PP_ERROR_FAILED;
313 314
314 return PP_OK; 315 return PP_OK;
315 } 316 }
316 317
317 } // namespace proxy 318 } // namespace proxy
318 } // namespace pp 319 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_audio_config_proxy.cc ('k') | ppapi/proxy/ppb_broker_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698