OLD | NEW |
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 (function() { | 5 (function() { |
6 var internal = mojo.internal; | 6 var internal = mojo.internal; |
7 | 7 |
8 function Connector(handle) { | 8 function Connector(handle) { |
9 if (!(handle instanceof MojoHandle)) | 9 if (!(handle instanceof MojoHandle)) |
10 throw new Error("Connector: not a handle " + handle); | 10 throw new Error("Connector: not a handle " + handle); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 }; | 75 }; |
76 | 76 |
77 Connector.prototype.setIncomingReceiver = function(receiver) { | 77 Connector.prototype.setIncomingReceiver = function(receiver) { |
78 this.incomingReceiver_ = receiver; | 78 this.incomingReceiver_ = receiver; |
79 }; | 79 }; |
80 | 80 |
81 Connector.prototype.setErrorHandler = function(handler) { | 81 Connector.prototype.setErrorHandler = function(handler) { |
82 this.errorHandler_ = handler; | 82 this.errorHandler_ = handler; |
83 }; | 83 }; |
84 | 84 |
85 Connector.prototype.waitForNextMessageForTesting = function() { | |
86 // TODO(yzshen): Change the tests that use this method. | |
87 throw new Error("Not supported!"); | |
88 }; | |
89 | |
90 Connector.prototype.readMore_ = function(result) { | 85 Connector.prototype.readMore_ = function(result) { |
91 for (;;) { | 86 for (;;) { |
92 if (this.paused_) { | 87 if (this.paused_) { |
93 return; | 88 return; |
94 } | 89 } |
95 | 90 |
96 var read = this.handle_.readMessage(); | 91 var read = this.handle_.readMessage(); |
97 if (this.handle_ == null) // The connector has been closed. | 92 if (this.handle_ == null) // The connector has been closed. |
98 return; | 93 return; |
99 if (read.result == Mojo.RESULT_SHOULD_WAIT) | 94 if (read.result == Mojo.RESULT_SHOULD_WAIT) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } else { | 156 } else { |
162 this.error_ = true; | 157 this.error_ = true; |
163 if (this.errorHandler_) { | 158 if (this.errorHandler_) { |
164 this.errorHandler_.onError(); | 159 this.errorHandler_.onError(); |
165 } | 160 } |
166 } | 161 } |
167 }; | 162 }; |
168 | 163 |
169 internal.Connector = Connector; | 164 internal.Connector = Connector; |
170 })(); | 165 })(); |
OLD | NEW |