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