| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 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 | 
|  | 3 // found in the LICENSE file. | 
|  | 4 | 
|  | 5 #include "ppapi/c/dev/ppb_hello_dev.h" | 
|  | 6 | 
|  | 7 #include <stdio.h> | 
|  | 8 | 
|  | 9 #include "base/logging.h" | 
|  | 10 #include "ppapi/c/pp_errors.h" | 
|  | 11 #include "ppapi/thunk/common.h" | 
|  | 12 #include "ppapi/thunk/enter.h" | 
|  | 13 #include "ppapi/thunk/thunk.h" | 
|  | 14 #include "ppapi/thunk/ppb_hello_api.h" | 
|  | 15 #include "ppapi/thunk/resource_creation_api.h" | 
|  | 16 | 
|  | 17 namespace ppapi { | 
|  | 18 namespace thunk { | 
|  | 19 | 
|  | 20 namespace { | 
|  | 21 | 
|  | 22 PP_Resource Create(PP_Instance instance) { | 
|  | 23   LOG(ERROR) << "Create"; | 
|  | 24   EnterFunction<ResourceCreationAPI> enter(instance, true); | 
|  | 25   if (enter.failed()) | 
|  | 26     return 0; | 
|  | 27   return enter.functions()->CreateHello(instance); | 
|  | 28 } | 
|  | 29 | 
|  | 30 PP_Bool IsHello(PP_Resource resource) { | 
|  | 31   LOG(ERROR) << "IsHello"; | 
|  | 32   EnterResource<PPB_Hello_API> enter(resource, false); | 
|  | 33   return PP_FromBool(enter.succeeded()); | 
|  | 34 } | 
|  | 35 | 
|  | 36 int32_t SayHello(PP_Resource hello) { | 
|  | 37   LOG(ERROR) << "SayHello"; | 
|  | 38   EnterResource<PPB_Hello_API> enter(hello, true); | 
|  | 39   if (enter.failed()) { | 
|  | 40     LOG(ERROR) << "  enter failed"; | 
|  | 41     return PP_ERROR_BADRESOURCE; | 
|  | 42   } | 
|  | 43   enter.object()->SayHello(); | 
|  | 44   return PP_OK; | 
|  | 45 } | 
|  | 46 | 
|  | 47 void WhoAreYou(PP_Resource hello, char* name, uint32_t size, | 
|  | 48     PP_CompletionCallback callback) { | 
|  | 49   LOG(ERROR) << "WhoAreYou"; | 
|  | 50   EnterResource<PPB_Hello_API> enter(hello, true); | 
|  | 51   if (enter.failed()) { | 
|  | 52     LOG(ERROR) << "  enter failed"; | 
|  | 53     snprintf(name, size, "enter failed"); | 
|  | 54     return; | 
|  | 55   } | 
|  | 56   enter.object()->WhoAreYou(name, size, | 
|  | 57       pp::CompletionCallback( | 
|  | 58           callback.func, callback.user_data, callback.flags)); | 
|  | 59 } | 
|  | 60 | 
|  | 61 const PPB_Hello_Dev g_ppb_hello_thunk = { | 
|  | 62   &Create, | 
|  | 63   &IsHello, | 
|  | 64   &SayHello, | 
|  | 65   &WhoAreYou | 
|  | 66 }; | 
|  | 67 | 
|  | 68 }  // namespace | 
|  | 69 | 
|  | 70 const PPB_Hello_Dev* GetPPB_Hello_Dev_Thunk() { | 
|  | 71   LOG(ERROR) << "GetPPB_Hello_Dev_Thunk"; | 
|  | 72   return &g_ppb_hello_thunk; | 
|  | 73 } | 
|  | 74 | 
|  | 75 }  // namespace thunk | 
|  | 76 }  // namespace ppapi | 
| OLD | NEW | 
|---|