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/codec", | 7 "mojo/public/js/bindings/codec", |
7 "mojo/public/js/bindings/core", | 8 "mojo/public/js/bindings/core", |
8 "mojo/public/js/bindings/support", | 9 "mojo/public/js/bindings/support", |
9 ], function(codec, core, support) { | 10 ], function(buffer, codec, core, support) { |
10 | 11 |
11 function Connector(handle) { | 12 function Connector(handle) { |
12 this.handle_ = handle; | 13 this.handle_ = handle; |
13 this.dropWrites_ = false; | 14 this.dropWrites_ = false; |
14 this.error_ = false; | 15 this.error_ = false; |
15 this.incomingReceiver_ = null; | 16 this.incomingReceiver_ = null; |
16 this.readWaitCookie_ = null; | 17 this.readWaitCookie_ = null; |
17 this.errorHandler_ = null; | 18 this.errorHandler_ = null; |
18 | 19 |
19 this.waitToReadMore_(); | 20 this.waitToReadMore_(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 if (read.result == core.RESULT_SHOULD_WAIT) { | 89 if (read.result == core.RESULT_SHOULD_WAIT) { |
89 this.waitToReadMore_(); | 90 this.waitToReadMore_(); |
90 return; | 91 return; |
91 } | 92 } |
92 if (read.result != core.RESULT_OK) { | 93 if (read.result != core.RESULT_OK) { |
93 this.error_ = true; | 94 this.error_ = true; |
94 if (this.errorHandler_) | 95 if (this.errorHandler_) |
95 this.errorHandler_.onError(read.result); | 96 this.errorHandler_.onError(read.result); |
96 return; | 97 return; |
97 } | 98 } |
98 var buffer = new codec.Buffer(read.buffer); | 99 var messageBuffer = new buffer.Buffer(read.buffer); |
99 var message = new codec.Message(buffer, read.handles); | 100 var message = new codec.Message(messageBuffer, read.handles); |
100 if (this.incomingReceiver_) { | 101 if (this.incomingReceiver_) { |
101 this.incomingReceiver_.accept(message); | 102 this.incomingReceiver_.accept(message); |
102 } | 103 } |
103 } | 104 } |
104 }; | 105 }; |
105 | 106 |
106 var exports = {}; | 107 var exports = {}; |
107 exports.Connector = Connector; | 108 exports.Connector = Connector; |
108 return exports; | 109 return exports; |
109 }); | 110 }); |
OLD | NEW |