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