| 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);
|
|
|