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 ppb_core.idl modified Mon Mar 19 12:02:10 2012. */ 7 8 #ifndef PPAPI_C_PPB_CORE_H_ 9 #define PPAPI_C_PPB_CORE_H_ 10 11 #include "ppapi/c/pp_bool.h" 12 #include "ppapi/c/pp_completion_callback.h" 13 #include "ppapi/c/pp_macros.h" 14 #include "ppapi/c/pp_resource.h" 15 #include "ppapi/c/pp_stdint.h" 16 #include "ppapi/c/pp_time.h" 17 18 #define PPB_CORE_INTERFACE_1_0 "PPB_Core;1.0" 19 #define PPB_CORE_INTERFACE PPB_CORE_INTERFACE_1_0 20 21 /** 22 * @file 23 * This file defines the <code>PPB_Core</code> interface defined by the browser 24 * and containing pointers to functions related to memory management, time, and 25 * threads. 26 */ 27 28 29 /** 30 * @addtogroup Interfaces 31 * @{ 32 */ 33 /** 34 * The <code>PPB_Core</code> interface contains pointers to functions related 35 * to memory management, time, and threads on the browser. 36 * 37 */ 38 struct PPB_Core_1_0 { 39 /** 40 * 41 * AddRefResource() adds a reference to a resource. 42 * 43 * @param[in] config A <code>PP_Resource</code> corresponding to a 44 * resource. 45 */ 46 void (*AddRefResource)(PP_Resource resource); 47 /** 48 * ReleaseResource() removes a reference from a resource. 49 * 50 * @param[in] config A <code>PP_Resource</code> corresponding to a 51 * resource. 52 */ 53 void (*ReleaseResource)(PP_Resource resource); 54 /** 55 * GetTime() returns the "wall clock time" according to the 56 * browser. 57 * 58 * @return A <code>PP_Time</code> containing the "wall clock time" according 59 * to the browser. 60 */ 61 PP_Time (*GetTime)(void); 62 /** 63 * GetTimeTicks() returns the "tick time" according to the browser. 64 * This clock is used by the browser when passing some event times to the 65 * module (e.g. using the <code>PP_InputEvent::time_stamp_seconds</code> 66 * field). It is not correlated to any actual wall clock time 67 * (like GetTime()). Because of this, it will not run change if the user 68 * changes their computer clock. 69 * 70 * @return A <code>PP_TimeTicks</code> containing the "tick time" according 71 * to the browser. 72 */ 73 PP_TimeTicks (*GetTimeTicks)(void); 74 /** 75 * CallOnMainThread() schedules work to be executed on the main module thread 76 * after the specified delay. The delay may be 0 to specify a call back as 77 * soon as possible. 78 * 79 * The <code>result</code> parameter will just be passed as the second 80 * argument to the callback. Many applications won't need this, but it allows 81 * a module to emulate calls of some callbacks which do use this value. 82 * 83 * <strong>Note:</strong> CallOnMainThread, even when used from the main 84 * thread with a delay of 0 milliseconds, will never directly invoke the 85 * callback. Even in this case, the callback will be scheduled 86 * asynchronously. 87 * 88 * <strong>Note:</strong> If the browser is shutting down or if the module 89 * has no instances, then the callback function may not be called. 90 * 91 * @param[in] delay_in_milliseconds An int32_t delay in milliseconds. 92 * @param[in] callback A <code>PP_CompletionCallback</code> callback function 93 * that the browser will call after the specified delay. 94 * @param[in] result An int32_t that the browser will pass to the given 95 * <code>PP_CompletionCallback</code>. 96 */ 97 void (*CallOnMainThread)(int32_t delay_in_milliseconds, 98 struct PP_CompletionCallback callback, 99 int32_t result); 100 /** 101 * IsMainThread() returns true if the current thread is the main pepper 102 * thread. 103 * 104 * This function is useful for implementing sanity checks, and deciding if 105 * dispatching using CallOnMainThread() is required. 106 * 107 * @return A <code>PP_Bool</code> containing <code>PP_TRUE</code> if the 108 * current thread is the main pepper thread, otherwise <code>PP_FALSE</code>. 109 */ 110 PP_Bool (*IsMainThread)(void); 111 }; 112 113 typedef struct PPB_Core_1_0 PPB_Core; 114 /** 115 * @} 116 */ 117 118 #endif /* PPAPI_C_PPB_CORE_H_ */ 119 120