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

Side by Side Diff: ppapi/thunk/ppb_audio_trusted_thunk.cc

Issue 7585025: Reland 95309. Add a template to handle properly issuing completion callbacks. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 4 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/thunk/ppb_audio_trusted_api.h ('k') | webkit/plugins/ppapi/ppb_audio_impl.h » ('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/c/pp_errors.h" 5 #include "ppapi/c/pp_errors.h"
6 #include "ppapi/c/trusted/ppb_audio_trusted.h"
6 #include "ppapi/thunk/common.h" 7 #include "ppapi/thunk/common.h"
7 #include "ppapi/thunk/enter.h" 8 #include "ppapi/thunk/enter.h"
8 #include "ppapi/thunk/thunk.h" 9 #include "ppapi/thunk/thunk.h"
9 #include "ppapi/thunk/ppb_audio_trusted_api.h" 10 #include "ppapi/thunk/ppb_audio_api.h"
10 #include "ppapi/thunk/resource_creation_api.h" 11 #include "ppapi/thunk/resource_creation_api.h"
11 12
12 namespace ppapi { 13 namespace ppapi {
13 namespace thunk { 14 namespace thunk {
14 15
15 namespace { 16 namespace {
16 17
18 typedef EnterResource<PPB_Audio_API> EnterAudio;
19
17 PP_Resource Create(PP_Instance instance_id) { 20 PP_Resource Create(PP_Instance instance_id) {
18 EnterFunction<ResourceCreationAPI> enter(instance_id, true); 21 EnterFunction<ResourceCreationAPI> enter(instance_id, true);
19 if (enter.failed()) 22 if (enter.failed())
20 return 0; 23 return 0;
21 return enter.functions()->CreateAudioTrusted(instance_id); 24 return enter.functions()->CreateAudioTrusted(instance_id);
22 } 25 }
23 26
24 int32_t Open(PP_Resource audio_id, 27 int32_t Open(PP_Resource audio_id,
25 PP_Resource config_id, 28 PP_Resource config_id,
26 PP_CompletionCallback create_callback) { 29 PP_CompletionCallback create_callback) {
27 EnterResource<PPB_AudioTrusted_API> enter(audio_id, true); 30 EnterAudio enter(audio_id, true);
28 if (enter.failed()) 31 if (enter.failed())
29 return MayForceCallback(create_callback, PP_ERROR_BADRESOURCE); 32 return MayForceCallback(create_callback, PP_ERROR_BADRESOURCE);
30 int32_t result = enter.object()->OpenTrusted(config_id, create_callback); 33 int32_t result = enter.object()->OpenTrusted(config_id, create_callback);
31 return MayForceCallback(create_callback, result); 34 return MayForceCallback(create_callback, result);
32 } 35 }
33 36
34 int32_t GetSyncSocket(PP_Resource audio_id, int* sync_socket) { 37 int32_t GetSyncSocket(PP_Resource audio_id, int* sync_socket) {
35 EnterResource<PPB_AudioTrusted_API> enter(audio_id, true); 38 EnterAudio enter(audio_id, true);
36 if (enter.failed()) 39 if (enter.failed())
37 return PP_ERROR_BADRESOURCE; 40 return PP_ERROR_BADRESOURCE;
38 return enter.object()->GetSyncSocket(sync_socket); 41 return enter.object()->GetSyncSocket(sync_socket);
39 } 42 }
40 43
41 int32_t GetSharedMemory(PP_Resource audio_id, 44 int32_t GetSharedMemory(PP_Resource audio_id,
42 int* shm_handle, 45 int* shm_handle,
43 uint32_t* shm_size) { 46 uint32_t* shm_size) {
44 EnterResource<PPB_AudioTrusted_API> enter(audio_id, true); 47 EnterAudio enter(audio_id, true);
45 if (enter.failed()) 48 if (enter.failed())
46 return PP_ERROR_BADRESOURCE; 49 return PP_ERROR_BADRESOURCE;
47 return enter.object()->GetSharedMemory(shm_handle, shm_size); 50 return enter.object()->GetSharedMemory(shm_handle, shm_size);
48 } 51 }
49 52
50 const PPB_AudioTrusted g_ppb_audio_trusted_thunk = { 53 const PPB_AudioTrusted g_ppb_audio_trusted_thunk = {
51 &Create, 54 &Create,
52 &Open, 55 &Open,
53 &GetSyncSocket, 56 &GetSyncSocket,
54 &GetSharedMemory, 57 &GetSharedMemory,
55 }; 58 };
56 59
57 } // namespace 60 } // namespace
58 61
59 const PPB_AudioTrusted* GetPPB_AudioTrusted_Thunk() { 62 const PPB_AudioTrusted* GetPPB_AudioTrusted_Thunk() {
60 return &g_ppb_audio_trusted_thunk; 63 return &g_ppb_audio_trusted_thunk;
61 } 64 }
62 65
63 } // namespace thunk 66 } // namespace thunk
64 } // namespace ppapi 67 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/thunk/ppb_audio_trusted_api.h ('k') | webkit/plugins/ppapi/ppb_audio_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698