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

Side by Side Diff: ppapi/api/ppb_message_loop.idl

Issue 15004017: Clean up formatting to simplify post-Doxygen processing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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) 2012 The Chromium Authors. All rights reserved. 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 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 5
6 /** 6 /**
7 * Defines the PPB_MessageLoop interface. 7 * Defines the PPB_MessageLoop interface.
8 */ 8 */
9 label Chrome { 9 label Chrome {
10 M25 = 1.0 10 M25 = 1.0
(...skipping 19 matching lines...) Expand all
30 * - Create the thread yourself (using pthreads). 30 * - Create the thread yourself (using pthreads).
31 * - Create the message loop resource. 31 * - Create the message loop resource.
32 * - Pass the message loop resource to your thread's main function. 32 * - Pass the message loop resource to your thread's main function.
33 * - Call PostWork() on the message loop to run functions on the thread. 33 * - Call PostWork() on the message loop to run functions on the thread.
34 * 34 *
35 * From the background thread's main function: 35 * From the background thread's main function:
36 * - Call AttachToCurrentThread() with the message loop resource. 36 * - Call AttachToCurrentThread() with the message loop resource.
37 * - Call Run() with the message loop resource. 37 * - Call Run() with the message loop resource.
38 * 38 *
39 * Your callbacks should look like this: 39 * Your callbacks should look like this:
40 * @code 40 * @code
41 * void DoMyWork(void* user_data, int32_t status) { 41 * void DoMyWork(void* user_data, int32_t status) {
42 * if (status != PP_OK) { 42 * if (status != PP_OK) {
43 * Cleanup(); // e.g. free user_data. 43 * Cleanup(); // e.g. free user_data.
44 * return; 44 * return;
45 * } 45 * }
46 * ... do your work... 46 * ... do your work...
47 * } 47 * }
48 * @endcode 48 * @endcode
49 * For a C++ example, see ppapi/utility/threading/simple_thread.h 49 * For a C++ example, see ppapi/utility/threading/simple_thread.h
50 * 50 *
51 * (You can also create the message loop resource on the background thread, 51 * (You can also create the message loop resource on the background thread,
52 * but then the main thread will have no reference to it should you want to 52 * but then the main thread will have no reference to it should you want to
53 * call PostWork()). 53 * call PostWork()).
54 * 54 *
55 * 55 *
56 * THREAD HANDLING 56 * THREAD HANDLING
57 * 57 *
58 * The main thread has an implicitly created message loop. The main thread is 58 * The main thread has an implicitly created message loop. The main thread is
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 * 109 *
110 * If you post a callback to a message loop that's been destroyed, or to an 110 * If you post a callback to a message loop that's been destroyed, or to an
111 * invalid message loop, PostWork will return an error and will not run the 111 * invalid message loop, PostWork will return an error and will not run the
112 * callback. This is true even for callbacks with the "required" flag set, 112 * callback. This is true even for callbacks with the "required" flag set,
113 * since the system may not even know what thread to issue the error callback 113 * since the system may not even know what thread to issue the error callback
114 * on. 114 * on.
115 * 115 *
116 * Therefore, you should check for errors from PostWork and destroy any 116 * Therefore, you should check for errors from PostWork and destroy any
117 * associated memory to avoid leaks. If you're using the C++ 117 * associated memory to avoid leaks. If you're using the C++
118 * CompletionCallbackFactory, use the following pattern: 118 * CompletionCallbackFactory, use the following pattern:
119 * 119 * @code
120 * pp::CompletionCallback callback = factory_.NewOptionalCallback(...); 120 * pp::CompletionCallback callback = factory_.NewOptionalCallback(...);
121 * int32_t result = message_loop.PostWork(callback); 121 * int32_t result = message_loop.PostWork(callback);
122 * if (result != PP_OK) 122 * if (result != PP_OK)
123 * callback.Run(result); 123 * callback.Run(result);
124 * 124 * @endcode
125 * This will run the callback with an error value, and assumes that the 125 * This will run the callback with an error value, and assumes that the
126 * implementation of your callback checks the "result" argument and returns 126 * implementation of your callback checks the "result" argument and returns
127 * immediately on error. 127 * immediately on error.
128 */ 128 */
129 interface PPB_MessageLoop { 129 interface PPB_MessageLoop {
130 /** 130 /**
131 * Creates a message loop resource. 131 * Creates a message loop resource.
132 * 132 *
133 * This may be called from any thread. After your thread starts but before 133 * This may be called from any thread. After your thread starts but before
134 * issuing any other PPAPI calls on it, you must associate it with a message 134 * issuing any other PPAPI calls on it, you must associate it with a message
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 * 262 *
263 * @return 263 * @return
264 * - PP_OK: The request to quit was successfully posted. 264 * - PP_OK: The request to quit was successfully posted.
265 * - PP_ERROR_BADRESOURCE: The message loop was invalid. 265 * - PP_ERROR_BADRESOURCE: The message loop was invalid.
266 * - PP_ERROR_WRONG_THREAD: You are attempting to quit the main thread. 266 * - PP_ERROR_WRONG_THREAD: You are attempting to quit the main thread.
267 * The main thread's message loop is managed by the system and can't be 267 * The main thread's message loop is managed by the system and can't be
268 * quit. 268 * quit.
269 */ 269 */
270 int32_t PostQuit([in] PP_Resource message_loop, PP_Bool should_destroy); 270 int32_t PostQuit([in] PP_Resource message_loop, PP_Bool should_destroy);
271 }; 271 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698