summaryrefslogtreecommitdiffstats
path: root/ppapi/api/ppb_core.idl
blob: e28fb0a48585b192ebd53bf4736d651f5068ccd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* Copyright (c) 2011 The Chromium Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

/* Defines the core API. */

/*
 * The PPB_Core interface contains pointers to functions related to memory
 * management, time, and threads on the browser.
 */
interface PPB_Core_0_3 {
  /* Same as AddRefVar for Resources. */
  void AddRefResource(
      [in] PP_Resource resource);

  /* Same as ReleaseVar for Resources. */
  void ReleaseResource(
      [in] PP_Resource resource);

  /* Allocate memory.
   *
   * Returns NULL If the allocation fails.
   */
  mem_t MemAlloc(
      [in] uint32_t num_bytes);

  /* Free memory; it's safe to pass NULL. */
  void MemFree(
      [inout] mem_t ptr);

  /* Returns the "wall clock time" according to the browser.
   *
   * See the definition of PP_Time.
   */
  PP_Time GetTime();

  /* Returns the "tick time" according to the browser. This clock is used by
   * the browser when passing some event times to the plugin (e.g., via the
   * PP_InputEvent::time_stamp_seconds field). It is not correlated to any
   * actual wall clock time (like GetTime()). Because of this, it will not run
   * change if the user changes their computer clock.
   *
   * TODO(brettw) http://code.google.com/p/chromium/issues/detail?id=57448
   * This currently does change with wall clock time, but will be fixed in
   * a future release.
   */
  PP_TimeTicks GetTimeTicks();

  /* Schedules work to be executed on the main plugin thread after the
   * specified delay. The delay may be 0 to specify a call back as soon as
   * possible.
   *
   * The |result| parameter will just be passed as the second argument as the
   * callback. Many applications won't need this, but it allows a plugin to
   * emulate calls of some callbacks which do use this value.
   *
   * NOTE: If the browser is shutting down or if the plugin has no instances,
   * then the callback function may not be called.
   */
  void CallOnMainThread(
      [in] int32_t delay_in_milliseconds,
      [in] PP_CompletionCallback callback,
      [in] int32_t result);

  /* Returns true if the current thread is the main pepper thread.
   *
   * This is useful for implementing sanity checks, and deciding if dispatching
   * via CallOnMainThread() is required.
   */
  PP_Bool IsMainThread();
};