| OLD | NEW |
| 1 /* Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
| 4 */ | 4 */ |
| 5 #ifndef PPAPI_C_PPB_CORE_H_ | 5 #ifndef PPAPI_C_PPB_CORE_H_ |
| 6 #define PPAPI_C_PPB_CORE_H_ | 6 #define PPAPI_C_PPB_CORE_H_ |
| 7 | 7 |
| 8 #include "ppapi/c/pp_bool.h" | 8 #include "ppapi/c/pp_bool.h" |
| 9 #include "ppapi/c/pp_resource.h" | 9 #include "ppapi/c/pp_resource.h" |
| 10 #include "ppapi/c/pp_stdint.h" | 10 #include "ppapi/c/pp_stdint.h" |
| 11 #include "ppapi/c/pp_time.h" | 11 #include "ppapi/c/pp_time.h" |
| 12 #include "ppapi/c/pp_var.h" | 12 #include "ppapi/c/pp_var.h" |
| 13 | 13 |
| 14 struct PP_CompletionCallback; | 14 struct PP_CompletionCallback; |
| 15 | 15 |
| 16 #define PPB_CORE_INTERFACE "PPB_Core;0.3" | 16 #define PPB_CORE_INTERFACE "PPB_Core;0.3" |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * @file | 19 * @file |
| 20 * Defines the API ... | 20 * This file defines the PPB_Core interface defined by the browser and |
| 21 * | 21 * and containing pointers to functions related to memory management, |
| 22 * time, and threads. |
| 22 */ | 23 */ |
| 23 | 24 |
| 24 /** | 25 /** |
| 25 * @addtogroup Interfaces | 26 * @addtogroup Interfaces |
| 26 * @{ | 27 * @{ |
| 27 */ | 28 */ |
| 28 | 29 |
| 29 /** {PENDING: describe PPB_CORE} */ | 30 /** |
| 31 * The PPB_Core interface contains pointers to functions related to memory |
| 32 * management, time, and threads on the browser. |
| 33 * |
| 34 */ |
| 30 struct PPB_Core { | 35 struct PPB_Core { |
| 31 /** Same as AddRefVar for Resources. */ | 36 /** |
| 37 * Same as AddRefVar for Resources. |
| 38 * AddRefResource is a pointer to a function that adds a reference to |
| 39 * a resource. |
| 40 * |
| 41 * @param[in] config A PP_Resource containing the resource. |
| 42 */ |
| 32 void (*AddRefResource)(PP_Resource resource); | 43 void (*AddRefResource)(PP_Resource resource); |
| 33 | 44 |
| 34 /** Same as ReleaseVar for Resources. */ | 45 /** |
| 46 * ReleaseResource is a pointer to a function that removes a reference |
| 47 * from a resource. |
| 48 * |
| 49 * @param[in] config A PP_Resource containing the resource. |
| 50 */ |
| 51 /*Same as ReleaseVar for Resources. */ |
| 35 void (*ReleaseResource)(PP_Resource resource); | 52 void (*ReleaseResource)(PP_Resource resource); |
| 36 | 53 |
| 37 /** | 54 /** |
| 38 * Allocate memory. | 55 * MemAlloc is a pointer to a function that allocate memory. |
| 39 * | 56 * |
| 40 * @return NULL If the allocation fails. | 57 * @param[in] num_bytes A size_t number of bytes to allocate. |
| 58 * @return A pointer to the memory if successful, NULL If the |
| 59 * allocation fails. |
| 41 */ | 60 */ |
| 42 void* (*MemAlloc)(size_t num_bytes); | 61 void* (*MemAlloc)(size_t num_bytes); |
| 43 | 62 |
| 44 /** Free memory; it's safe to pass NULL. */ | 63 /** |
| 64 * MemFree is a pointer to a function that deallocates memory. |
| 65 * |
| 66 * @param[in] ptr A pointer to the memory to deallocate. It is safe to |
| 67 * pass NULL to this function. |
| 68 */ |
| 45 void (*MemFree)(void* ptr); | 69 void (*MemFree)(void* ptr); |
| 46 | 70 |
| 47 /** | 71 /** |
| 48 * Returns the "wall clock time" according to the browser. | 72 * GetTime is a pointer to a function that returns the "wall clock |
| 73 * time" according to the browser. |
| 49 * | 74 * |
| 50 * See the definition of PP_Time. | 75 * @return A PP_Time containing the "wall clock time" according to the |
| 76 * browser. |
| 51 */ | 77 */ |
| 52 PP_Time (*GetTime)(); | 78 PP_Time (*GetTime)(); |
| 53 | 79 |
| 54 /** | 80 /** |
| 55 * Returns the "tick time" according to the browser. This clock is used by | 81 * GetTimeTicks is a pointer to a function that returns the "tick time" |
| 56 * the browser when passing some event times to the plugin (e.g., via the | 82 * according to the browser. This clock is used by the browser when passing |
| 83 * some event times to the plugin (e.g., via the |
| 57 * PP_InputEvent::time_stamp_seconds field). It is not correlated to any | 84 * PP_InputEvent::time_stamp_seconds field). It is not correlated to any |
| 58 * actual wall clock time (like GetTime()). Because of this, it will not run | 85 * actual wall clock time (like GetTime()). Because of this, it will not run |
| 59 * change if the user changes their computer clock. | 86 * change if the user changes their computer clock. |
| 60 * | 87 * |
| 61 * TODO(brettw) http://code.google.com/p/chromium/issues/detail?id=57448 | 88 * @return A PP_TimeTicks containing the "tick time" according to the |
| 62 * This currently does change with wall clock time, but will be fixed in | 89 * browser. |
| 63 * a future release. | |
| 64 */ | 90 */ |
| 91 |
| 92 // TODO(brettw) http://code.google.com/p/chromium/issues/detail?id=57448 |
| 93 // This currently does change with wall clock time, but will be fixed in |
| 94 // a future release. |
| 65 PP_TimeTicks (*GetTimeTicks)(); | 95 PP_TimeTicks (*GetTimeTicks)(); |
| 66 | 96 |
| 67 /** | 97 /** |
| 68 * Schedules work to be executed on the main plugin thread after the | 98 * CallOnMainThread is a pointer to a function that schedules work to be |
| 69 * specified delay. The delay may be 0 to specify a call back as soon as | 99 * executed on the main module thread after the specified delay. The delay |
| 70 * possible. | 100 * may be 0 to specify a call back as soon as possible. |
| 71 * | 101 * |
| 72 * The |result| parameter will just be passed as the second argument as the | 102 * The |result| parameter will just be passed as the second argument to the |
| 73 * callback. Many applications won't need this, but it allows a plugin to | 103 * callback. Many applications won't need this, but it allows a plugin to |
| 74 * emulate calls of some callbacks which do use this value. | 104 * emulate calls of some callbacks which do use this value. |
| 75 * | 105 * |
| 76 * NOTE: If the browser is shutting down or if the plugin has no instances, | 106 * NOTE: If the browser is shutting down or if the plugin has no instances, |
| 77 * then the callback function may not be called. | 107 * then the callback function may not be called. |
| 108 * |
| 109 * @param[in] delay_in_milliseconds An int32_t delay in milliseconds. |
| 110 * @param[in] callback A PP_CompletionCallback callback function that the |
| 111 * browser will call after the specified delay. |
| 112 * @param[in] result An int32_t that the browser will pass to the given |
| 113 * PP_CompletionCallback. |
| 78 */ | 114 */ |
| 79 void (*CallOnMainThread)(int32_t delay_in_milliseconds, | 115 void (*CallOnMainThread)(int32_t delay_in_milliseconds, |
| 80 struct PP_CompletionCallback callback, | 116 struct PP_CompletionCallback callback, |
| 81 int32_t result); | 117 int32_t result); |
| 82 | 118 |
| 83 /** | 119 /** |
| 84 * Returns true if the current thread is the main pepper thread. | 120 * IsMainThread is a pointer to a function that returns true if the |
| 121 * current thread is the main pepper thread. |
| 85 * | 122 * |
| 86 * This is useful for implementing sanity checks, and deciding if dispatching | 123 * This function is useful for implementing sanity checks, and deciding if |
| 87 * via CallOnMainThread() is required. | 124 * dispatching using CallOnMainThread() is required. |
| 125 * |
| 126 * @return A PP_BOOL containing PP_TRUE if the current thread is the main |
| 127 * pepper thread, otherwise PP_FALSE. |
| 88 */ | 128 */ |
| 89 PP_Bool (*IsMainThread)(); | 129 PP_Bool (*IsMainThread)(); |
| 90 }; | 130 }; |
| 91 /** | 131 /** |
| 92 * @} | 132 * @} |
| 93 */ | 133 */ |
| 94 | 134 |
| 95 | 135 |
| 96 #endif /* PPAPI_C_DEV_PPB_CORE_DEV_H_ */ | 136 #endif /* PPAPI_C_DEV_PPB_CORE_DEV_H_ */ |
| 97 | 137 |
| OLD | NEW |