blob: f7ef9515a6008672877c9acf8fd65a9391f0970d [file] [log] [blame]
[email protected]2272ed32011-03-30 17:37:541/* 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]745b0d42011-07-16 23:53:226/**
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]cfe868c2011-06-20 18:03:0610 */
[email protected]2272ed32011-03-30 17:37:5411
[email protected]745b0d42011-07-16 23:53:2212label Chrome {
13 M14 = 1.0
14};
[email protected]2272ed32011-03-30 17:37:5415
[email protected]745b0d42011-07-16 23:53:2216/**
17 * The <code>PPB_Core</code> interface contains pointers to functions related
18 * to memory management, time, and threads on the browser.
19 *
20 */
21interface PPB_Core {
22 /**
[email protected]2272ed32011-03-30 17:37:5423 *
[email protected]745b0d42011-07-16 23:53:2224 * AddRefResource() adds a reference to a resource.
25 *
26 * @param[in] config A <code>PP_Resource</code> containing the resource.
[email protected]2272ed32011-03-30 17:37:5427 */
[email protected]745b0d42011-07-16 23:53:2228 void AddRefResource([in] PP_Resource resource);
[email protected]2272ed32011-03-30 17:37:5429
[email protected]745b0d42011-07-16 23:53:2230 /**
31 * ReleaseResource() removes a reference from a resource.
[email protected]2272ed32011-03-30 17:37:5432 *
[email protected]745b0d42011-07-16 23:53:2233 * @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]2272ed32011-03-30 17:37:5443 */
44 PP_Time GetTime();
45
[email protected]745b0d42011-07-16 23:53:2246 /**
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]2272ed32011-03-30 17:37:5453 *
[email protected]745b0d42011-07-16 23:53:2254 * @return A <code>PP_TimeTicks</code> containing the "tick time" according
55 * to the browser.
[email protected]2272ed32011-03-30 17:37:5456 */
57 PP_TimeTicks GetTimeTicks();
58
[email protected]745b0d42011-07-16 23:53:2259 /**
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]2272ed32011-03-30 17:37:5463 *
[email protected]745b0d42011-07-16 23:53:2264 * 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]2272ed32011-03-30 17:37:5467 *
[email protected]745b0d42011-07-16 23:53:2268 * <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]2272ed32011-03-30 17:37:5481 */
82 void CallOnMainThread(
83 [in] int32_t delay_in_milliseconds,
84 [in] PP_CompletionCallback callback,
85 [in] int32_t result);
86
[email protected]745b0d42011-07-16 23:53:2287 /**
88 * IsMainThread() returns true if the current thread is the main pepper
89 * thread.
[email protected]2272ed32011-03-30 17:37:5490 *
[email protected]745b0d42011-07-16 23:53:2291 * 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]2272ed32011-03-30 17:37:5496 */
97 PP_Bool IsMainThread();
98};
[email protected]745b0d42011-07-16 23:53:2299