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 #include "ppapi/c/pp_bool.h" 6 #include "ppapi/c/pp_errors.h" 7 #include "ppapi/thunk/enter.h" 8 #include "ppapi/thunk/ppb_flash_message_loop_api.h" 9 #include "ppapi/thunk/resource_creation_api.h" 10 #include "ppapi/thunk/thunk.h" 11 12 namespace ppapi { 13 namespace thunk { 14 15 namespace { 16 Create(PP_Instance instance)17PP_Resource Create(PP_Instance instance) { 18 EnterResourceCreation enter(instance); 19 if (enter.failed()) 20 return 0; 21 return enter.functions()->CreateFlashMessageLoop(instance); 22 } 23 IsFlashMessageLoop(PP_Resource resource)24PP_Bool IsFlashMessageLoop(PP_Resource resource) { 25 EnterResource<PPB_Flash_MessageLoop_API> enter(resource, false); 26 return PP_FromBool(enter.succeeded()); 27 } 28 Run(PP_Resource resource)29int32_t Run(PP_Resource resource) { 30 EnterResource<PPB_Flash_MessageLoop_API> enter(resource, true); 31 if (enter.failed()) 32 return PP_ERROR_BADRESOURCE; 33 return enter.object()->Run(); 34 } 35 Quit(PP_Resource resource)36void Quit(PP_Resource resource) { 37 EnterResource<PPB_Flash_MessageLoop_API> enter(resource, true); 38 if (enter.succeeded()) 39 enter.object()->Quit(); 40 } 41 42 const PPB_Flash_MessageLoop g_ppb_flash_message_loop_thunk = { 43 &Create, 44 &IsFlashMessageLoop, 45 &Run, 46 &Quit 47 }; 48 49 } // namespace 50 GetPPB_Flash_MessageLoop_0_1_Thunk()51const PPB_Flash_MessageLoop_0_1* GetPPB_Flash_MessageLoop_0_1_Thunk() { 52 return &g_ppb_flash_message_loop_thunk; 53 } 54 55 } // namespace thunk 56 } // namespace ppapi 57