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

Side by Side Diff: extensions/renderer/resources/async_waiter.js

Issue 571333002: Add serialization support to the JS DataSender and DataReceiver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@stash-service
Patch Set: clean up jsdoc Created 6 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 define('async_waiter', [ 5 define('async_waiter', [
6 'mojo/public/js/bindings/support', 6 'mojo/public/js/bindings/support',
7 ], function(supportModule) { 7 ], function(supportModule) {
8 /** 8 /**
9 * @module async_waiter 9 * @module async_waiter
10 */ 10 */
11 11
12 /** 12 /**
13 * @callback module:async_waiter.AsyncWaiter.Callback 13 * @callback module:async_waiter.AsyncWaiter.Callback
14 * @param {number} result The result of waiting. 14 * @param {number} result The result of waiting.
15 */ 15 */
16 16
17 /** 17 /**
18 * A waiter that waits for a handle to be ready for either reading or writing. 18 * A waiter that waits for a handle to be ready for either reading or writing.
19 * @param {MojoHandle} handle The handle to wait on. 19 * @param {!MojoHandle} handle The handle to wait on.
20 * @param {int} signals The signals to wait for handle to be ready for. 20 * @param {number} signals The signals to wait for handle to be ready for.
21 * @param {module:async_waiter.AsyncWaiter.Callback} callback The callback to 21 * @param {module:async_waiter.AsyncWaiter.Callback} callback The callback to
22 * call when handle is ready. 22 * call when handle is ready.
23 * @constructor 23 * @constructor
24 * @alias module:async_waiter.AsyncWaiter 24 * @alias module:async_waiter.AsyncWaiter
25 */ 25 */
26 function AsyncWaiter(handle, signals, callback) { 26 function AsyncWaiter(handle, signals, callback) {
27 /** 27 /**
28 * The handle to wait on. 28 * The handle to wait on.
29 * @type {MojoHandle} 29 * @type {!MojoHandle}
30 * @private 30 * @private
31 */ 31 */
32 this.handle_ = handle; 32 this.handle_ = handle;
33 33
34 /** 34 /**
35 * The signals to wait for. 35 * The signals to wait for.
36 * @type {number} 36 * @type {number}
37 * @private 37 * @private
38 */ 38 */
39 this.signals_ = signals; 39 this.signals_ = signals;
(...skipping 24 matching lines...) Expand all
64 */ 64 */
65 AsyncWaiter.prototype.stop = function() { 65 AsyncWaiter.prototype.stop = function() {
66 if (!this.id_) 66 if (!this.id_)
67 return; 67 return;
68 68
69 supportModule.cancelWait(this.id_); 69 supportModule.cancelWait(this.id_);
70 this.id_ = null; 70 this.id_ = null;
71 }; 71 };
72 72
73 /** 73 /**
74 * Returns whether this {@ linke AsyncWaiter} is waiting. 74 * Returns whether this {@link AsyncWaiter} is waiting.
75 * @return {boolean} Whether this AsyncWaiter is waiting. 75 * @return {boolean} Whether this AsyncWaiter is waiting.
76 */ 76 */
77 AsyncWaiter.prototype.isWaiting = function() { 77 AsyncWaiter.prototype.isWaiting = function() {
78 return !!this.id_; 78 return !!this.id_;
79 }; 79 };
80 80
81 /** 81 /**
82 * Invoked when |[handle_]{@link module:async_waiter.AsyncWaiter#handle_}| is 82 * Invoked when |[handle_]{@link module:async_waiter.AsyncWaiter#handle_}| is
83 * ready. 83 * ready.
84 * @param {number} result The result of the wait. 84 * @param {number} result The result of the wait.
85 * @private 85 * @private
86 */ 86 */
87 AsyncWaiter.prototype.onHandleReady_ = function(result) { 87 AsyncWaiter.prototype.onHandleReady_ = function(result) {
88 this.id_ = null; 88 this.id_ = null;
89 this.callback_(result); 89 this.callback_(result);
90 }; 90 };
91 91
92 return {AsyncWaiter: AsyncWaiter}; 92 return {AsyncWaiter: AsyncWaiter};
93 }); 93 });
OLDNEW
« no previous file with comments | « extensions/renderer/api/serial/serial_api_unittest.cc ('k') | extensions/renderer/resources/data_receiver.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698