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 define("mojo/public/js/bindings/connector", [ | 5 define("mojo/public/js/bindings/connector", [ |
6 "mojo/public/js/bindings/buffer", | 6 "mojo/public/js/bindings/buffer", |
7 "mojo/public/js/bindings/codec", | 7 "mojo/public/js/bindings/codec", |
8 "mojo/public/js/bindings/core", | 8 "mojo/public/js/bindings/core", |
9 "mojo/public/js/bindings/support", | 9 "mojo/public/js/bindings/support", |
10 ], function(buffer, codec, core, support) { | 10 ], function(buffer, codec, core, support) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 return; | 97 return; |
98 } | 98 } |
99 var messageBuffer = new buffer.Buffer(read.buffer); | 99 var messageBuffer = new buffer.Buffer(read.buffer); |
100 var message = new codec.Message(messageBuffer, read.handles); | 100 var message = new codec.Message(messageBuffer, read.handles); |
101 if (this.incomingReceiver_) { | 101 if (this.incomingReceiver_) { |
102 this.incomingReceiver_.accept(message); | 102 this.incomingReceiver_.accept(message); |
103 } | 103 } |
104 } | 104 } |
105 }; | 105 }; |
106 | 106 |
| 107 // The TestConnector subclass is only intended to be used in unit tests. It |
| 108 // enables delivering a message to the pipe's handle without an async wait. |
| 109 |
| 110 function TestConnector(handle) { |
| 111 Connector.call(this, handle); |
| 112 } |
| 113 |
| 114 TestConnector.prototype = Object.create(Connector.prototype); |
| 115 |
| 116 TestConnector.prototype.waitToReadMore_ = function() { |
| 117 }; |
| 118 |
| 119 TestConnector.prototype.deliverMessage = function() { |
| 120 this.readMore_(core.RESULT_OK); |
| 121 } |
| 122 |
107 var exports = {}; | 123 var exports = {}; |
108 exports.Connector = Connector; | 124 exports.Connector = Connector; |
| 125 exports.TestConnector = TestConnector; |
109 return exports; | 126 return exports; |
110 }); | 127 }); |
OLD | NEW |