OLD | NEW |
(Empty) | |
| 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. |
| 4 */ |
| 5 |
| 6 /* From ../test_thunk/simple.idl modified Thu Nov 15 10:43:12 2012. */ |
| 7 |
| 8 #include "ppapi/c/../test_thunk/simple.h" |
| 9 #include "ppapi/c/pp_errors.h" |
| 10 #include "ppapi/shared_impl/tracked_callback.h" |
| 11 #include "ppapi/thunk/enter.h" |
| 12 #include "ppapi/thunk/ppb_instance_api.h" |
| 13 #include "ppapi/thunk/resource_creation_api.h" |
| 14 #include "ppapi/thunk/simple_api.h" |
| 15 #include "ppapi/thunk/thunk.h" |
| 16 |
| 17 namespace ppapi { |
| 18 namespace thunk { |
| 19 |
| 20 namespace { |
| 21 |
| 22 PP_Resource Create(PP_Instance instance) { |
| 23 EnterResourceCreation enter(instance); |
| 24 if (enter.failed()) |
| 25 return 0; |
| 26 return enter.functions()->CreateSimple(instance); |
| 27 } |
| 28 |
| 29 PP_Bool IsSimple(PP_Resource resource) { |
| 30 EnterResource<PPB_Simple_API> enter(resource, false); |
| 31 return PP_FromBool(enter.succeeded()); |
| 32 } |
| 33 |
| 34 void PostMessage(PP_Instance instance, PP_Var message) { |
| 35 EnterInstance enter(instance); |
| 36 if (enter.succeeded()) |
| 37 enter.functions()->PostMessage(instance, message); |
| 38 } |
| 39 |
| 40 uint32_t DoUint32Instance(PP_Instance instance) { |
| 41 EnterInstance enter(instance); |
| 42 if (enter.failed()) |
| 43 return 0; |
| 44 return enter.functions()->DoUint32Instance(instance); |
| 45 } |
| 46 |
| 47 uint32_t DoUint32Resource(PP_Resource instance) { |
| 48 EnterResource<PPB_Simple_API> enter(instance, true); |
| 49 if (enter.failed()) |
| 50 return 0; |
| 51 return enter.object()->DoUint32Resource(); |
| 52 } |
| 53 |
| 54 uint32_t DoUint32ResourceNoErrors(PP_Resource instance) { |
| 55 EnterResource<PPB_Simple_API> enter(instance, false); |
| 56 if (enter.failed()) |
| 57 return 0; |
| 58 return enter.object()->DoUint32ResourceNoErrors(); |
| 59 } |
| 60 |
| 61 int32_t OnFailure12(PP_Instance instance) { |
| 62 EnterInstance enter(instance); |
| 63 if (enter.failed()) |
| 64 return 12; |
| 65 return enter.functions()->OnFailure12(instance); |
| 66 } |
| 67 |
| 68 const PPB_Simple_0_5 g_ppb_simple_thunk_0_5 = { |
| 69 &Create, |
| 70 &IsSimple, |
| 71 &PostMessage, |
| 72 &DoUint32Instance, |
| 73 &DoUint32Resource, |
| 74 &DoUint32ResourceNoErrors, |
| 75 }; |
| 76 |
| 77 const PPB_Simple_1_0 g_ppb_simple_thunk_1_0 = { |
| 78 &Create, |
| 79 &IsSimple, |
| 80 &DoUint32Instance, |
| 81 &DoUint32Resource, |
| 82 &DoUint32ResourceNoErrors, |
| 83 &OnFailure12, |
| 84 }; |
| 85 |
| 86 } // namespace |
| 87 |
| 88 const PPB_Simple_0_5* GetPPB_Simple_0_5_Thunk() { |
| 89 return &g_ppb_simple_thunk_0_5; |
| 90 } |
| 91 |
| 92 const PPB_Simple_1_0* GetPPB_Simple_1_0_Thunk() { |
| 93 return &g_ppb_simple_thunk_1_0; |
| 94 } |
| 95 |
| 96 } // namespace thunk |
| 97 } // namespace ppapi |
OLD | NEW |