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

Unified Diff: mojo/public/js/connector.js

Issue 1777673003: [mojo-bindings] Use Watcher API for JS bindings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/js/waiting_callback.cc ('k') | mojo/public/js/support.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/js/connector.js
diff --git a/mojo/public/js/connector.js b/mojo/public/js/connector.js
index e672b54e5ff34c1caa72e014a8eb19d70fd0da9d..674f36b3210d3fced0abd04c1163fcfac49933b9 100644
--- a/mojo/public/js/connector.js
+++ b/mojo/public/js/connector.js
@@ -16,17 +16,20 @@ define("mojo/public/js/connector", [
this.dropWrites_ = false;
this.error_ = false;
this.incomingReceiver_ = null;
- this.readWaitCookie_ = null;
+ this.readWatcher_ = null;
this.errorHandler_ = null;
- if (handle)
- this.waitToReadMore_();
+ if (handle) {
+ this.readWatcher_ = support.watch(handle,
+ core.HANDLE_SIGNAL_READABLE,
+ this.readMore_.bind(this));
+ }
}
Connector.prototype.close = function() {
- if (this.readWaitCookie_) {
- support.cancelWait(this.readWaitCookie_);
- this.readWaitCookie_ = null;
+ if (this.readWatcher_) {
+ support.cancelWatch(this.readWatcher_);
+ this.readWatcher_ = null;
}
if (this.handle_ != null) {
core.close(this.handle_);
@@ -79,22 +82,14 @@ define("mojo/public/js/connector", [
return this.error_;
};
- Connector.prototype.waitToReadMore_ = function() {
- this.readWaitCookie_ = support.asyncWait(this.handle_,
- core.HANDLE_SIGNAL_READABLE,
- this.readMore_.bind(this));
- };
-
Connector.prototype.readMore_ = function(result) {
for (;;) {
var read = core.readMessage(this.handle_,
core.READ_MESSAGE_FLAG_NONE);
if (this.handle_ == null) // The connector has been closed.
return;
- if (read.result == core.RESULT_SHOULD_WAIT) {
- this.waitToReadMore_();
+ if (read.result == core.RESULT_SHOULD_WAIT)
return;
- }
if (read.result != core.RESULT_OK) {
this.error_ = true;
if (this.errorHandler_)
@@ -118,9 +113,6 @@ define("mojo/public/js/connector", [
TestConnector.prototype = Object.create(Connector.prototype);
- TestConnector.prototype.waitToReadMore_ = function() {
- }
-
TestConnector.prototype.waitForNextMessage = function() {
var wait = core.wait(this.handle_, core.HANDLE_SIGNAL_READABLE,
core.DEADLINE_INDEFINITE);
« no previous file with comments | « mojo/edk/js/waiting_callback.cc ('k') | mojo/public/js/support.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698