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

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

Issue 9113044: Convert to new enter method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: PATCH DESCRIPTIONS ARE A STUPID WASTE OF TIME Created 8 years, 10 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_video_capture_thunk.cc ('k') | ppapi/thunk/ppb_websocket_thunk.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/thunk/common.h"
7 #include "ppapi/thunk/enter.h" 6 #include "ppapi/thunk/enter.h"
8 #include "ppapi/thunk/thunk.h" 7 #include "ppapi/thunk/thunk.h"
9 #include "ppapi/thunk/ppb_video_decoder_api.h" 8 #include "ppapi/thunk/ppb_video_decoder_api.h"
10 #include "ppapi/thunk/resource_creation_api.h" 9 #include "ppapi/thunk/resource_creation_api.h"
11 10
12 namespace ppapi { 11 namespace ppapi {
13 namespace thunk { 12 namespace thunk {
14 13
15 namespace { 14 namespace {
16 15
17 typedef EnterResource<PPB_VideoDecoder_API> EnterVideoDecoder; 16 typedef EnterResource<PPB_VideoDecoder_API> EnterVideoDecoder;
18 17
19 PP_Resource Create(PP_Instance instance, 18 PP_Resource Create(PP_Instance instance,
20 PP_Resource graphics_3d, 19 PP_Resource graphics_3d,
21 PP_VideoDecoder_Profile profile) { 20 PP_VideoDecoder_Profile profile) {
22 EnterFunction<ResourceCreationAPI> enter(instance, true); 21 EnterFunction<ResourceCreationAPI> enter(instance, true);
23 if (enter.failed()) 22 if (enter.failed())
24 return 0; 23 return 0;
25 return enter.functions()->CreateVideoDecoder(instance, graphics_3d, profile); 24 return enter.functions()->CreateVideoDecoder(instance, graphics_3d, profile);
26 } 25 }
27 26
28 PP_Bool IsVideoDecoder(PP_Resource resource) { 27 PP_Bool IsVideoDecoder(PP_Resource resource) {
29 EnterVideoDecoder enter(resource, false); 28 EnterVideoDecoder enter(resource, false);
30 return PP_FromBool(enter.succeeded()); 29 return PP_FromBool(enter.succeeded());
31 } 30 }
32 31
33 int32_t Decode(PP_Resource video_decoder, 32 int32_t Decode(PP_Resource video_decoder,
34 const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, 33 const PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
35 PP_CompletionCallback callback) { 34 PP_CompletionCallback callback) {
36 EnterVideoDecoder enter(video_decoder, true); 35 EnterVideoDecoder enter(video_decoder, callback, true);
37 if (enter.failed()) 36 if (enter.failed())
38 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); 37 return enter.retval();
39 int32_t result = enter.object()->Decode(bitstream_buffer, callback); 38 return enter.SetResult(enter.object()->Decode(bitstream_buffer, callback));
40 return MayForceCallback(callback, result);
41 } 39 }
42 40
43 void AssignPictureBuffers(PP_Resource video_decoder, 41 void AssignPictureBuffers(PP_Resource video_decoder,
44 uint32_t no_of_buffers, 42 uint32_t no_of_buffers,
45 const PP_PictureBuffer_Dev* buffers) { 43 const PP_PictureBuffer_Dev* buffers) {
46 EnterVideoDecoder enter(video_decoder, true); 44 EnterVideoDecoder enter(video_decoder, true);
47 if (enter.succeeded()) 45 if (enter.succeeded())
48 enter.object()->AssignPictureBuffers(no_of_buffers, buffers); 46 enter.object()->AssignPictureBuffers(no_of_buffers, buffers);
49 } 47 }
50 48
51 void ReusePictureBuffer(PP_Resource video_decoder, int32_t picture_buffer_id) { 49 void ReusePictureBuffer(PP_Resource video_decoder, int32_t picture_buffer_id) {
52 EnterVideoDecoder enter(video_decoder, true); 50 EnterVideoDecoder enter(video_decoder, true);
53 if (enter.succeeded()) 51 if (enter.succeeded())
54 enter.object()->ReusePictureBuffer(picture_buffer_id); 52 enter.object()->ReusePictureBuffer(picture_buffer_id);
55 } 53 }
56 54
57 int32_t Flush(PP_Resource video_decoder, PP_CompletionCallback callback) { 55 int32_t Flush(PP_Resource video_decoder, PP_CompletionCallback callback) {
58 EnterVideoDecoder enter(video_decoder, true); 56 EnterVideoDecoder enter(video_decoder, callback, true);
59 if (enter.failed()) 57 if (enter.failed())
60 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); 58 return enter.retval();
61 int32_t result = enter.object()->Flush(callback); 59 return enter.SetResult(enter.object()->Flush(callback));
62 return MayForceCallback(callback, result);
63 } 60 }
64 61
65 int32_t Reset(PP_Resource video_decoder, 62 int32_t Reset(PP_Resource video_decoder,
66 PP_CompletionCallback callback) { 63 PP_CompletionCallback callback) {
67 EnterVideoDecoder enter(video_decoder, true); 64 EnterVideoDecoder enter(video_decoder, callback, true);
68 if (enter.failed()) 65 if (enter.failed())
69 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); 66 return enter.retval();
70 int32_t result = enter.object()->Reset(callback); 67 return enter.SetResult(enter.object()->Reset(callback));
71 return MayForceCallback(callback, result);
72 } 68 }
73 69
74 void Destroy(PP_Resource video_decoder) { 70 void Destroy(PP_Resource video_decoder) {
75 EnterVideoDecoder enter(video_decoder, true); 71 EnterVideoDecoder enter(video_decoder, true);
76 if (enter.succeeded()) 72 if (enter.succeeded())
77 enter.object()->Destroy(); 73 enter.object()->Destroy();
78 } 74 }
79 75
80 const PPB_VideoDecoder_Dev g_ppb_videodecoder_thunk = { 76 const PPB_VideoDecoder_Dev g_ppb_videodecoder_thunk = {
81 &Create, 77 &Create,
82 &IsVideoDecoder, 78 &IsVideoDecoder,
83 &Decode, 79 &Decode,
84 &AssignPictureBuffers, 80 &AssignPictureBuffers,
85 &ReusePictureBuffer, 81 &ReusePictureBuffer,
86 &Flush, 82 &Flush,
87 &Reset, 83 &Reset,
88 &Destroy 84 &Destroy
89 }; 85 };
90 86
91 } // namespace 87 } // namespace
92 88
93 const PPB_VideoDecoder_Dev_0_16* GetPPB_VideoDecoder_Dev_0_16_Thunk() { 89 const PPB_VideoDecoder_Dev_0_16* GetPPB_VideoDecoder_Dev_0_16_Thunk() {
94 return &g_ppb_videodecoder_thunk; 90 return &g_ppb_videodecoder_thunk;
95 } 91 }
96 92
97 } // namespace thunk 93 } // namespace thunk
98 } // namespace ppapi 94 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/thunk/ppb_video_capture_thunk.cc ('k') | ppapi/thunk/ppb_websocket_thunk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698