OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_CPP_CORE_H_ | 5 #ifndef PPAPI_CPP_CORE_H_ |
6 #define PPAPI_CPP_CORE_H_ | 6 #define PPAPI_CPP_CORE_H_ |
7 | 7 |
8 #include "ppapi/c/ppb_core.h" | 8 #include "ppapi/c/ppb_core.h" |
9 | 9 |
10 /// @file | 10 /// @file |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 /// browser. | 44 /// browser. |
45 /// | 45 /// |
46 /// @return A <code>PP_Time</code> containing the "wall clock time" according | 46 /// @return A <code>PP_Time</code> containing the "wall clock time" according |
47 /// to the browser. | 47 /// to the browser. |
48 PP_Time GetTime() { | 48 PP_Time GetTime() { |
49 return interface_->GetTime(); | 49 return interface_->GetTime(); |
50 } | 50 } |
51 | 51 |
52 /// GetTimeTicks() returns the "tick time" according to the browser. | 52 /// GetTimeTicks() returns the "tick time" according to the browser. |
53 /// This clock is used by the browser when passing some event times to the | 53 /// This clock is used by the browser when passing some event times to the |
54 /// plugin (for example, using the | 54 /// module (for example, using the |
55 /// <code>PP_InputEvent::time_stamp_seconds</code> field). It is not | 55 /// <code>PP_InputEvent::time_stamp_seconds</code> field). It is not |
56 /// correlated to any actual wall clock time (like GetTime()). Because | 56 /// correlated to any actual wall clock time (like GetTime()). Because |
57 /// of this, it will not change if the user changes their computer clock. | 57 /// of this, it will not change if the user changes their computer clock. |
58 /// | 58 /// |
59 /// @return A <code>PP_TimeTicks</code> containing the "tick time" according | 59 /// @return A <code>PP_TimeTicks</code> containing the "tick time" according |
60 /// to the browser. | 60 /// to the browser. |
61 PP_TimeTicks GetTimeTicks() { | 61 PP_TimeTicks GetTimeTicks() { |
62 return interface_->GetTimeTicks(); | 62 return interface_->GetTimeTicks(); |
63 } | 63 } |
64 | 64 |
65 /// CallOnMainThread() schedules work to be executed on the main pepper | 65 /// CallOnMainThread() schedules work to be executed on the main pepper |
66 /// thread after the specified delay. The delay may be 0 to specify a call | 66 /// thread after the specified delay. The delay may be 0 to specify a call |
67 /// back as soon as possible. | 67 /// back as soon as possible. |
68 /// | 68 /// |
69 /// The |result| parameter will just be passed as the second argument to the | 69 /// The |result| parameter will just be passed as the second argument to the |
70 /// callback. Many applications won't need this, but it allows a plugin to | 70 /// callback. Many applications won't need this, but it allows a module to |
71 /// emulate calls of some callbacks which do use this value. | 71 /// emulate calls of some callbacks which do use this value. |
72 /// | 72 /// |
73 /// <strong>Note:</strong> CallOnMainThread(), even when used from the main | 73 /// <strong>Note:</strong> CallOnMainThread(), even when used from the main |
74 /// thread with a delay of 0 milliseconds, will never directly invoke the | 74 /// thread with a delay of 0 milliseconds, will never directly invoke the |
75 /// callback. Even in this case, the callback will be scheduled | 75 /// callback. Even in this case, the callback will be scheduled |
76 /// asynchronously. | 76 /// asynchronously. |
77 /// | 77 /// |
78 /// <strong>Note:</strong> If the browser is shutting down or if the module | 78 /// <strong>Note:</strong> If the browser is shutting down or if the module |
79 /// has no instances, then the callback function may not be called. | 79 /// has no instances, then the callback function may not be called. |
80 /// | 80 /// |
81 /// @param[in] delay_in_milliseconds An int32_t delay in milliseconds. | 81 /// @param[in] delay_in_milliseconds An int32_t delay in milliseconds. |
82 /// @param[in] callback A <code>CompletionCallback</code> callback function | 82 /// @param[in] callback A <code>CompletionCallback</code> callback function |
83 /// that the browser will call after the specified delay. | 83 /// that the browser will call after the specified delay. |
84 /// @param[in] result An int32_t that the browser will pass to the given | 84 /// @param[in] result An int32_t that the browser will pass to the given |
85 /// <code>CompletionCallback</code>. | 85 /// <code>CompletionCallback</code>. |
86 void CallOnMainThread(int32_t delay_in_milliseconds, | 86 void CallOnMainThread(int32_t delay_in_milliseconds, |
87 const CompletionCallback& callback, | 87 const CompletionCallback& callback, |
88 int32_t result = 0); | 88 int32_t result = 0); |
89 | 89 |
90 | 90 |
91 /// IsMainThread() returns true if the current thread is the main pepper | 91 /// IsMainThread() returns true if the current thread is the main pepper |
92 /// thread. | 92 /// thread. |
93 /// | 93 /// |
94 /// This function is useful for implementing sanity checks, and deciding if | 94 /// This function is useful for implementing sanity checks, and deciding if |
95 /// dispatching using CallOnMainThread() is required. | 95 /// dispatching using CallOnMainThread() is required. |
96 /// | 96 /// |
97 /// @return A bool containing true if the current thread is | 97 /// @return true if the current thread is the main pepper thread, otherwise |
98 /// the main pepper thread, otherwise false. | 98 /// false. |
99 bool IsMainThread(); | 99 bool IsMainThread(); |
100 | 100 |
101 private: | 101 private: |
102 // Allow Module to construct. | 102 // Allow Module to construct. |
103 friend class Module; | 103 friend class Module; |
104 | 104 |
105 // Only module should make this class so this constructor is private. | 105 // Only module should make this class so this constructor is private. |
106 Core(const PPB_Core* inter) : interface_(inter) {} | 106 Core(const PPB_Core* inter) : interface_(inter) {} |
107 | 107 |
108 // Copy and assignment are disallowed. | 108 // Copy and assignment are disallowed. |
109 Core(const Core& other); | 109 Core(const Core& other); |
110 Core& operator=(const Core& other); | 110 Core& operator=(const Core& other); |
111 | 111 |
112 const PPB_Core* interface_; | 112 const PPB_Core* interface_; |
113 }; | 113 }; |
114 | 114 |
115 } // namespace pp | 115 } // namespace pp |
116 | 116 |
117 #endif // PPAPI_CPP_CORE_H_ | 117 #endif // PPAPI_CPP_CORE_H_ |
OLD | NEW |