Delete unused downloads page asset.
[chromium-blink-merge.git] / ppapi / generators / test_thunk / simple_thunk.cc
blob8fc2ba26aba2d8d6331ec9325eec94118dffa302
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
3 // found in the LICENSE file.
5 // From ../test_thunk/simple.idl modified Fri Nov 16 11:26:06 2012.
7 #include "ppapi/c/../test_thunk/simple.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/shared_impl/tracked_callback.h"
10 #include "ppapi/thunk/enter.h"
11 #include "ppapi/thunk/ppb_instance_api.h"
12 #include "ppapi/thunk/resource_creation_api.h"
13 #include "ppapi/thunk/simple_api.h"
14 #include "ppapi/thunk/thunk.h"
16 namespace ppapi {
17 namespace thunk {
19 namespace {
21 PP_Resource Create(PP_Instance instance) {
22 VLOG(4) << "PPB_Simple::Create()";
23 EnterResourceCreation enter(instance);
24 if (enter.failed())
25 return 0;
26 return enter.functions()->CreateSimple(instance);
29 PP_Bool IsSimple(PP_Resource resource) {
30 VLOG(4) << "PPB_Simple::IsSimple()";
31 EnterResource<PPB_Simple_API> enter(resource, false);
32 return PP_FromBool(enter.succeeded());
35 void PostMessage(PP_Instance instance, PP_Var message) {
36 VLOG(4) << "PPB_Simple::PostMessage()";
37 EnterInstance enter(instance);
38 if (enter.failed())
39 return;
40 enter.functions()->PostMessage(instance, message);
43 uint32_t DoUint32Instance_0_5(PP_Instance instance) {
44 VLOG(4) << "PPB_Simple::DoUint32Instance()";
45 EnterInstance enter(instance);
46 if (enter.failed())
47 return 0;
48 return enter.functions()->DoUint32Instance0_5(instance);
51 uint32_t DoUint32Instance(PP_Instance instance, PP_Resource resource) {
52 VLOG(4) << "PPB_Simple::DoUint32Instance()";
53 EnterInstance enter(instance);
54 if (enter.failed())
55 return 0;
56 return enter.functions()->DoUint32Instance(instance, resource);
59 uint32_t DoUint32Resource(PP_Resource instance) {
60 VLOG(4) << "PPB_Simple::DoUint32Resource()";
61 EnterResource<PPB_Simple_API> enter(instance, true);
62 if (enter.failed())
63 return 0;
64 return enter.object()->DoUint32Resource();
67 uint32_t DoUint32ResourceNoErrors(PP_Resource instance) {
68 VLOG(4) << "PPB_Simple::DoUint32ResourceNoErrors()";
69 EnterResource<PPB_Simple_API> enter(instance, false);
70 if (enter.failed())
71 return 0;
72 return enter.object()->DoUint32ResourceNoErrors();
75 int32_t OnFailure12(PP_Instance instance) {
76 VLOG(4) << "PPB_Simple::OnFailure12()";
77 EnterInstance enter(instance);
78 if (enter.failed())
79 return 12;
80 return enter.functions()->OnFailure12(instance);
83 const PPB_Simple_0_5 g_ppb_simple_thunk_0_5 = {
84 &Create,
85 &IsSimple,
86 &PostMessage,
87 &DoUint32Instance_0_5,
88 &DoUint32Resource,
89 &DoUint32ResourceNoErrors
92 const PPB_Simple_1_0 g_ppb_simple_thunk_1_0 = {
93 &Create,
94 &IsSimple,
95 &DoUint32Instance_0_5,
96 &DoUint32Resource,
97 &DoUint32ResourceNoErrors,
98 &OnFailure12
101 const PPB_Simple_1_5 g_ppb_simple_thunk_1_5 = {
102 &Create,
103 &IsSimple,
104 &DoUint32Instance,
105 &DoUint32Resource,
106 &DoUint32ResourceNoErrors,
107 &OnFailure12
110 } // namespace
112 const PPB_Simple_0_5* GetPPB_Simple_0_5_Thunk() {
113 return &g_ppb_simple_thunk_0_5;
116 const PPB_Simple_1_0* GetPPB_Simple_1_0_Thunk() {
117 return &g_ppb_simple_thunk_1_0;
120 const PPB_Simple_1_5* GetPPB_Simple_1_5_Thunk() {
121 return &g_ppb_simple_thunk_1_5;
124 } // namespace thunk
125 } // namespace ppapi