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

Side by Side Diff: ppapi/thunk/ppb_video_capture_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_url_loader_thunk.cc ('k') | ppapi/thunk/ppb_video_decoder_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_capture_api.h" 8 #include "ppapi/thunk/ppb_video_capture_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_VideoCapture_API> EnterVideoCapture; 16 typedef EnterResource<PPB_VideoCapture_API> EnterVideoCapture;
18 17
19 PP_Resource Create(PP_Instance instance) { 18 PP_Resource Create(PP_Instance instance) {
20 EnterFunction<ResourceCreationAPI> enter(instance, true); 19 EnterFunction<ResourceCreationAPI> enter(instance, true);
21 if (enter.failed()) 20 if (enter.failed())
22 return 0; 21 return 0;
23 return enter.functions()->CreateVideoCapture(instance); 22 return enter.functions()->CreateVideoCapture(instance);
24 } 23 }
25 24
26 PP_Bool IsVideoCapture(PP_Resource resource) { 25 PP_Bool IsVideoCapture(PP_Resource resource) {
27 EnterVideoCapture enter(resource, false); 26 EnterVideoCapture enter(resource, false);
28 return PP_FromBool(enter.succeeded()); 27 return PP_FromBool(enter.succeeded());
29 } 28 }
30 29
31 int32_t StartCapture(PP_Resource video_capture, 30 int32_t StartCapture(PP_Resource video_capture,
32 const PP_VideoCaptureDeviceInfo_Dev* requested_info, 31 const PP_VideoCaptureDeviceInfo_Dev* requested_info,
33 uint32_t buffer_count) { 32 uint32_t buffer_count) {
34 EnterVideoCapture enter(video_capture, true); 33 EnterVideoCapture enter(video_capture, true);
35 if (enter.failed()) 34 if (enter.failed())
36 return PP_ERROR_BADRESOURCE; 35 return enter.retval();
37
38 return enter.object()->StartCapture(*requested_info, buffer_count); 36 return enter.object()->StartCapture(*requested_info, buffer_count);
39 } 37 }
40 38
41 int32_t ReuseBuffer(PP_Resource video_capture, 39 int32_t ReuseBuffer(PP_Resource video_capture,
42 uint32_t buffer) { 40 uint32_t buffer) {
43 EnterVideoCapture enter(video_capture, true); 41 EnterVideoCapture enter(video_capture, true);
44 if (enter.failed()) 42 if (enter.failed())
45 return PP_ERROR_BADRESOURCE; 43 return enter.retval();
46
47 return enter.object()->ReuseBuffer(buffer); 44 return enter.object()->ReuseBuffer(buffer);
48 } 45 }
49 46
50 int32_t StopCapture(PP_Resource video_capture) { 47 int32_t StopCapture(PP_Resource video_capture) {
51 EnterVideoCapture enter(video_capture, true); 48 EnterVideoCapture enter(video_capture, true);
52 if (enter.failed()) 49 if (enter.failed())
53 return PP_ERROR_BADRESOURCE; 50 return enter.retval();
54
55 return enter.object()->StopCapture(); 51 return enter.object()->StopCapture();
56 } 52 }
57 53
58 const PPB_VideoCapture_Dev g_ppb_videocapture_thunk = { 54 const PPB_VideoCapture_Dev g_ppb_videocapture_thunk = {
59 &Create, 55 &Create,
60 &IsVideoCapture, 56 &IsVideoCapture,
61 &StartCapture, 57 &StartCapture,
62 &ReuseBuffer, 58 &ReuseBuffer,
63 &StopCapture 59 &StopCapture
64 }; 60 };
65 61
66 } // namespace 62 } // namespace
67 63
68 const PPB_VideoCapture_Dev_0_1* GetPPB_VideoCapture_Dev_0_1_Thunk() { 64 const PPB_VideoCapture_Dev_0_1* GetPPB_VideoCapture_Dev_0_1_Thunk() {
69 return &g_ppb_videocapture_thunk; 65 return &g_ppb_videocapture_thunk;
70 } 66 }
71 67
72 } // namespace thunk 68 } // namespace thunk
73 } // namespace ppapi 69 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/thunk/ppb_url_loader_thunk.cc ('k') | ppapi/thunk/ppb_video_decoder_thunk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698