Chromium Code Reviews| 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_0_4 "PPB_Core;0.4" | 16 #define PPB_CORE_INTERFACE_0_4 "PPB_Core;0.4" |
| 17 #define PPB_CORE_INTERFACE PPB_CORE_INTERFACE_0_4 | 17 #define PPB_CORE_INTERFACE PPB_CORE_INTERFACE_0_4 |
| 18 | 18 |
| 19 /** | 19 /** |
| 20 * @file | 20 * @file |
| 21 * This file defines the PPB_Core interface defined by the browser and | 21 * This file defines the <code>PPB_Core</code> interface defined by the browser |
| 22 * and containing pointers to functions related to memory management, | 22 * and containing pointers to functions related to memory management, time, and |
| 23 * time, and threads. | 23 * threads. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 /** | 26 /** |
| 27 * @addtogroup Interfaces | 27 * @addtogroup Interfaces |
| 28 * @{ | 28 * @{ |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * The PPB_Core interface contains pointers to functions related to memory | 32 * The <code>PPB_Core</code> interface contains pointers to functions related |
| 33 * management, time, and threads on the browser. | 33 * to memory management, time, and threads on the browser. |
| 34 * | 34 * |
| 35 */ | 35 */ |
| 36 struct PPB_Core { | 36 struct PPB_Core { |
| 37 /** | 37 /** |
| 38 * Same as AddRefVar for Resources. | |
| 39 * AddRefResource is a pointer to a function that adds a reference to | |
| 40 * a resource. | |
| 41 * | 38 * |
| 42 * @param[in] config A PP_Resource containing the resource. | 39 * AddRefResource() adds a reference to a resource. This |
| 40 * function is similar to <code>AddRefVar</code> for resources. | |
|
dmichael (off chromium)
2011/07/01 16:45:00
Actually, we should just remove the second sentenc
jond
2011/07/01 20:31:23
Done.
| |
| 41 * | |
| 42 * @param[in] config A <code>PP_Resource</code> containing the resource. | |
| 43 */ | 43 */ |
| 44 void (*AddRefResource)(PP_Resource resource); | 44 void (*AddRefResource)(PP_Resource resource); |
| 45 | 45 |
| 46 /** | 46 /** |
| 47 * ReleaseResource is a pointer to a function that removes a reference | 47 * ReleaseResource() removes a reference from a resource. This |
| 48 * from a resource. | 48 * function is similar to <code>ReleaseVar</code> for Resources. |
| 49 * | 49 * |
| 50 * @param[in] config A PP_Resource containing the resource. | 50 * @param[in] config A <code>PP_Resource</code> containing the resource. |
| 51 */ | 51 */ |
| 52 /*Same as ReleaseVar for Resources. */ | |
| 53 void (*ReleaseResource)(PP_Resource resource); | 52 void (*ReleaseResource)(PP_Resource resource); |
| 54 | 53 |
| 55 /** | 54 /** |
| 56 * MemAlloc is a pointer to a function that allocate memory. | 55 * MemAlloc() allocates memory. |
| 57 * | 56 * |
| 58 * @param[in] num_bytes A number of bytes to allocate. | 57 * @param[in] num_bytes A number of bytes to allocate. |
| 59 * @return A pointer to the memory if successful, NULL If the | 58 * |
| 59 * @return A pointer to the memory if successful, <code>NULL</code> If the | |
| 60 * allocation fails. | 60 * allocation fails. |
| 61 */ | 61 */ |
| 62 void* (*MemAlloc)(uint32_t num_bytes); | 62 void* (*MemAlloc)(uint32_t num_bytes); |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * MemFree is a pointer to a function that deallocates memory. | 65 * <code>MemFree()</code> deallocates memory. |
| 66 * | 66 * |
| 67 * @param[in] ptr A pointer to the memory to deallocate. It is safe to | 67 * @param[in] ptr A pointer to the memory to deallocate. It is safe to |
| 68 * pass NULL to this function. | 68 * pass <code>NULL</code> to this function. |
| 69 */ | 69 */ |
| 70 void (*MemFree)(void* ptr); | 70 void (*MemFree)(void* ptr); |
| 71 | 71 |
| 72 /** | 72 /** |
| 73 * GetTime is a pointer to a function that returns the "wall clock | 73 * GetTime() returns the "wall clock time" according to the |
| 74 * time" according to the browser. | 74 * browser. |
| 75 * | 75 * |
| 76 * @return A PP_Time containing the "wall clock time" according to the | 76 * @return A <code>PP_Time</code> containing the "wall clock time" according |
| 77 * browser. | 77 * to the browser. |
| 78 */ | 78 */ |
| 79 PP_Time (*GetTime)(); | 79 PP_Time (*GetTime)(); |
| 80 | 80 |
| 81 /** | 81 /** |
| 82 * GetTimeTicks is a pointer to a function that returns the "tick time" | 82 * GetTimeTicks() returns the "tick time" according to the browser. |
| 83 * according to the browser. This clock is used by the browser when passing | 83 * This clock is used by the browser when passing some event times to the |
| 84 * some event times to the plugin (e.g., via the | 84 * module (e.g. using the <code>PP_InputEvent::time_stamp_seconds</code> |
| 85 * PP_InputEvent::time_stamp_seconds field). It is not correlated to any | 85 * field). It is not correlated to any actual wall clock time |
| 86 * actual wall clock time (like GetTime()). Because of this, it will not run | 86 * (like GetTime()). Because of this, it will not run change if the user |
| 87 * change if the user changes their computer clock. | 87 * changes their computer clock. |
| 88 * | 88 * |
| 89 * @return A PP_TimeTicks containing the "tick time" according to the | 89 * @return A <code>PP_TimeTicks</code> containing the "tick time" according |
| 90 * browser. | 90 * to the browser. |
| 91 */ | 91 */ |
| 92 | 92 |
| 93 // TODO(brettw) http://code.google.com/p/chromium/issues/detail?id=57448 | 93 // TODO(brettw) http://code.google.com/p/chromium/issues/detail?id=57448 |
| 94 // This currently does change with wall clock time, but will be fixed in | 94 // This currently does change with wall clock time, but will be fixed in |
| 95 // a future release. | 95 // a future release. |
| 96 PP_TimeTicks (*GetTimeTicks)(); | 96 PP_TimeTicks (*GetTimeTicks)(); |
| 97 | 97 |
| 98 /** | 98 /** |
| 99 * CallOnMainThread is a pointer to a function that schedules work to be | 99 * CallOnMainThread() schedules work to be executed on the main module thread |
| 100 * executed on the main module thread after the specified delay. The delay | 100 * after the specified delay. The delay may be 0 to specify a call back as |
| 101 * may be 0 to specify a call back as soon as possible. | 101 * soon as possible. |
| 102 * | 102 * |
| 103 * The |result| parameter will just be passed as the second argument to the | 103 * The <code>result</code> parameter will just be passed as the second |
| 104 * callback. Many applications won't need this, but it allows a plugin to | 104 * argument to the callback. Many applications won't need this, but it allows |
| 105 * emulate calls of some callbacks which do use this value. | 105 * a module to emulate calls of some callbacks which do use this value. |
| 106 * | 106 * |
| 107 * NOTE: CallOnMainThread, even when used from the main thread with a delay | 107 * <strong>Note:</strong> CallOnMainThread, even when used from the main |
| 108 * of 0 milliseconds, will never directly invoke the callback. Even in this | 108 * thread with a delay of 0 milliseconds, will never directly invoke the |
| 109 * case, the callback will be scheduled asynchronously. | 109 * callback. Even in this case, the callback will be scheduled |
| 110 * asynchronously. | |
| 110 * | 111 * |
| 111 * NOTE: If the browser is shutting down or if the plugin has no instances, | 112 * <strong>Note:</strong> If the browser is shutting down or if the module |
| 112 * then the callback function may not be called. | 113 * has no instances, then the callback function may not be called. |
| 113 * | 114 * |
| 114 * @param[in] delay_in_milliseconds An int32_t delay in milliseconds. | 115 * @param[in] delay_in_milliseconds An int32_t delay in milliseconds. |
| 115 * @param[in] callback A PP_CompletionCallback callback function that the | 116 * @param[in] callback A <code>PP_CompletionCallback</code> callback function |
| 116 * browser will call after the specified delay. | 117 * that the browser will call after the specified delay. |
| 117 * @param[in] result An int32_t that the browser will pass to the given | 118 * @param[in] result An int32_t that the browser will pass to the given |
| 118 * PP_CompletionCallback. | 119 * <code>PP_CompletionCallback</code>. |
| 119 */ | 120 */ |
| 120 void (*CallOnMainThread)(int32_t delay_in_milliseconds, | 121 void (*CallOnMainThread)(int32_t delay_in_milliseconds, |
| 121 struct PP_CompletionCallback callback, | 122 struct PP_CompletionCallback callback, |
| 122 int32_t result); | 123 int32_t result); |
| 123 | 124 |
| 124 /** | 125 /** |
| 125 * IsMainThread is a pointer to a function that returns true if the | 126 * IsMainThread() returns true if the current thread is the main pepper |
| 126 * current thread is the main pepper thread. | 127 * thread. |
| 127 * | 128 * |
| 128 * This function is useful for implementing sanity checks, and deciding if | 129 * This function is useful for implementing sanity checks, and deciding if |
| 129 * dispatching using CallOnMainThread() is required. | 130 * dispatching using CallOnMainThread() is required. |
| 130 * | 131 * |
| 131 * @return A PP_BOOL containing PP_TRUE if the current thread is the main | 132 * @return A <code>PP_BOOL</code> containing <code>PP_TRUE</code> if the |
|
dmichael (off chromium)
2011/07/01 16:45:00
PP_BOOL->PP_Bool
jond
2011/07/01 20:31:23
Done.
| |
| 132 * pepper thread, otherwise PP_FALSE. | 133 * current thread is the main pepper thread, otherwise <code>PP_FALSE</code>. |
| 133 */ | 134 */ |
| 134 PP_Bool (*IsMainThread)(); | 135 PP_Bool (*IsMainThread)(); |
| 135 }; | 136 }; |
| 136 /** | 137 /** |
| 137 * @} | 138 * @} |
| 138 */ | 139 */ |
| 139 | 140 |
| 140 | 141 |
| 141 #endif /* PPAPI_C_DEV_PPB_CORE_DEV_H_ */ | 142 #endif /* PPAPI_C_DEV_PPB_CORE_DEV_H_ */ |
| 142 | 143 |
| OLD | NEW |