1// Copyright (c) 2013 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 <vector> 6 7#include "ppapi/c/extensions/dev/ppb_ext_alarms_dev.h" 8#include "ppapi/shared_impl/tracked_callback.h" 9#include "ppapi/thunk/enter.h" 10#include "ppapi/thunk/extensions_common_api.h" 11#include "ppapi/thunk/thunk.h" 12 13namespace ppapi { 14namespace thunk { 15 16namespace { 17 18void Create(PP_Instance instance, 19 PP_Var name, 20 PP_Ext_Alarms_AlarmCreateInfo_Dev alarm_info) { 21 EnterInstanceAPI<ExtensionsCommon_API> enter(instance); 22 if (enter.failed()) 23 return; 24 25 std::vector<PP_Var> args; 26 args.push_back(name); 27 args.push_back(alarm_info); 28 enter.functions()->PostRenderer("alarms.create", args); 29} 30 31int32_t Get(PP_Instance instance, 32 PP_Var name, 33 PP_Ext_Alarms_Alarm_Dev* alarm, 34 PP_CompletionCallback callback) { 35 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); 36 if (enter.failed()) 37 return enter.retval(); 38 39 std::vector<PP_Var> input_args; 40 std::vector<PP_Var*> output_args; 41 input_args.push_back(name); 42 output_args.push_back(alarm); 43 return enter.SetResult(enter.functions()->CallRenderer( 44 "alarms.get", input_args, output_args, enter.callback())); 45} 46 47int32_t GetAll(PP_Instance instance, 48 PP_Ext_Alarms_Alarm_Dev_Array* alarms, 49 PP_CompletionCallback callback) { 50 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); 51 if (enter.failed()) 52 return enter.retval(); 53 54 std::vector<PP_Var> input_args; 55 std::vector<PP_Var*> output_args; 56 output_args.push_back(alarms); 57 return enter.SetResult(enter.functions()->CallRenderer( 58 "alarms.getAll", input_args, output_args, enter.callback())); 59} 60 61void Clear(PP_Instance instance, PP_Var name) { 62 EnterInstanceAPI<ExtensionsCommon_API> enter(instance); 63 if (enter.failed()) 64 return; 65 66 std::vector<PP_Var> args; 67 args.push_back(name); 68 enter.functions()->PostRenderer("alarms.clear", args); 69} 70 71void ClearAll(PP_Instance instance) { 72 EnterInstanceAPI<ExtensionsCommon_API> enter(instance); 73 if (enter.failed()) 74 return; 75 76 std::vector<PP_Var> args; 77 enter.functions()->PostRenderer("alarms.clearAll", args); 78} 79 80const PPB_Ext_Alarms_Dev_0_1 g_ppb_ext_alarms_dev_0_1_thunk = { 81 &Create, 82 &Get, 83 &GetAll, 84 &Clear, 85 &ClearAll 86}; 87 88} // namespace 89 90const PPB_Ext_Alarms_Dev_0_1* GetPPB_Ext_Alarms_Dev_0_1_Thunk() { 91 return &g_ppb_ext_alarms_dev_0_1_thunk; 92} 93 94} // namespace thunk 95} // namespace ppapi 96