Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Side by Side Diff: ppapi/cpp/core.h

Issue 7054060: New documentation for resource.h, core.h, and common.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 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
11 /// This file defines APIs related to memory management, time, and threads.
12
10 namespace pp { 13 namespace pp {
11 14
12 class CompletionCallback; 15 class CompletionCallback;
13 class Module; 16 class Module;
14 17
15 // Simple wrapper around the PPB_Core interface. Some of these wrappers add 18 /// APIs related to memory management, time, and threads.
16 // nothing over the C interface, but some allow the use of C++ arguments.
17 class Core { 19 class Core {
18 public: 20 public:
19 // Note that we explicitly don't expose Resource& versions of this function 21 // Note that we explicitly don't expose Resource& versions of this function
20 // since Resource will normally manage the refcount properly. These should 22 // since Resource will normally manage the refcount properly. These should
21 // be called only when doing manual management on raw PP_Resource handles, 23 // be called only when doing manual management on raw PP_Resource handles,
22 // which should be fairly rare. 24 // which should be fairly rare.
25
26 /// A function that adds a reference to a resource.
dmichael (off chromium) 2011/06/07 05:01:23 'Ref' is really short for ref count. I would say
jond 2011/06/07 16:41:00 Done.
27 ///
28 /// @param[in] resource A PP_Resource containing the resource.
23 void AddRefResource(PP_Resource resource) { 29 void AddRefResource(PP_Resource resource) {
24 interface_->AddRefResource(resource); 30 interface_->AddRefResource(resource);
25 } 31 }
32
33 /// A function that removes a reference from a resource.
dmichael (off chromium) 2011/06/07 05:01:23 ReleaseResource decrements the reference count for
jond 2011/06/07 16:41:00 Done.
34 ///
35 /// @param[in] resource A PP_Resource containing the resource.
26 void ReleaseResource(PP_Resource resource) { 36 void ReleaseResource(PP_Resource resource) {
27 interface_->ReleaseResource(resource); 37 interface_->ReleaseResource(resource);
28 } 38 }
29 39
40 /// A function that allocates memory.
41 ///
42 /// @param[in] @param[in] num_bytes A number of bytes to allocate.
43 /// @return A pointer to the memory if successful, NULL If the
44 /// allocation fails.
30 void* MemAlloc(uint32_t num_bytes) { 45 void* MemAlloc(uint32_t num_bytes) {
31 return interface_->MemAlloc(num_bytes); 46 return interface_->MemAlloc(num_bytes);
32 } 47 }
48
49 /// A function that deallocates memory.
50 ///
51 /// @param[in] ptr A pointer to the memory to deallocate. It is safe to
52 /// pass NULL to this function.
33 void MemFree(void* ptr) { 53 void MemFree(void* ptr) {
34 interface_->MemFree(ptr); 54 interface_->MemFree(ptr);
35 } 55 }
36 56
57
58 /// A function that that returns the "wall clock time" according to the
59 /// browser.
60 ///
61 /// @return A PP_Time containing the "wall clock time" according to the
62 /// browser.
37 PP_Time GetTime() { 63 PP_Time GetTime() {
38 return interface_->GetTime(); 64 return interface_->GetTime();
39 } 65 }
40 66
67 /// A function that that returns the "tick time" according to the browser.
68 /// This clock is used by the browser when passing some event times to the
69 /// plugin (e.g., via the PP_InputEvent::time_stamp_seconds field). It is
70 /// not correlated to any actual wall clock time (like GetTime()). Because
71 /// of this, it will not run change if the user changes their computer clock.
dmichael (off chromium) 2011/06/07 05:01:23 remove 'run'
jond 2011/06/07 16:41:00 Done.
jond 2011/06/07 16:41:00 Done.
72 ///
73 /// @return A PP_TimeTicks containing the "tick time" according to the
74 /// browser.
41 PP_TimeTicks GetTimeTicks() { 75 PP_TimeTicks GetTimeTicks() {
42 return interface_->GetTimeTicks(); 76 return interface_->GetTimeTicks();
43 } 77 }
44 78
79
80 /// A function that schedules work to be executed on the main module thread
dmichael (off chromium) 2011/06/07 05:01:23 module thread->pepper thread? This should be cons
jond 2011/06/07 16:41:00 Done.
81 /// after the specified delay. The delay may be 0 to specify a call back as
82 /// soon as possible.
83 ///
84 /// The |result| parameter will just be passed as the second argument to the
85 /// callback. Many applications won't need this, but it allows a plugin to
86 /// emulate calls of some callbacks which do use this value.
87 ///
88 /// NOTE: CallOnMainThread, even when used from the main thread with a delay
89 /// of 0 milliseconds, will never directly invoke the callback. Even in this
90 /// case, the callback will be scheduled asynchronously.
91 ///
92 /// NOTE: If the browser is shutting down or if the plugin has no instances,
93 /// then the callback function may not be called.
94 ///
95 /// @param[in] delay_in_milliseconds An int32_t delay in milliseconds.
96 /// @param[in] callback A CompletionCallback callback function that the
97 /// browser will call after the specified delay.
98 /// @param[in] result An int32_t that the browser will pass to the given
99 /// CompletionCallback.
45 void CallOnMainThread(int32_t delay_in_milliseconds, 100 void CallOnMainThread(int32_t delay_in_milliseconds,
46 const CompletionCallback& callback, 101 const CompletionCallback& callback,
47 int32_t result = 0); 102 int32_t result = 0);
48 103
104
105 /// A function that returns true if thecurrent thread is the main pepper
dmichael (off chromium) 2011/06/07 05:01:23 thecurrent->the current
jond 2011/06/07 16:41:00 Done.
jond 2011/06/07 16:41:00 Done.
106 /// thread.
107 ///
108 /// This function is useful for implementing sanity checks, and deciding if
109 /// dispatching using CallOnMainThread() is required.
110 ///
111 /// @return A PP_BOOL containing PP_TRUE if the current thread is the main
112 /// pepper thread, otherwise PP_FALSE.
49 bool IsMainThread(); 113 bool IsMainThread();
50 114
51 private: 115 private:
52 // Allow Module to construct. 116 // Allow Module to construct.
53 friend class Module; 117 friend class Module;
54 118
55 // Only module should make this class so this constructor is private. 119 // Only module should make this class so this constructor is private.
56 Core(const PPB_Core* inter) : interface_(inter) {} 120 Core(const PPB_Core* inter) : interface_(inter) {}
57 121
58 // Copy and assignment are disallowed. 122 // Copy and assignment are disallowed.
59 Core(const Core& other); 123 Core(const Core& other);
60 Core& operator=(const Core& other); 124 Core& operator=(const Core& other);
61 125
62 const PPB_Core* interface_; 126 const PPB_Core* interface_;
63 }; 127 };
64 128
65 } // namespace pp 129 } // namespace pp
66 130
67 #endif // PPAPI_CPP_CORE_H_ 131 #endif // PPAPI_CPP_CORE_H_
OLDNEW
« no previous file with comments | « ppapi/cpp/common.h ('k') | ppapi/cpp/resource.h » ('j') | ppapi/cpp/resource.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698