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/codec", | 6 "mojo/public/js/bindings/codec", |
7 "mojo/public/js/bindings/core", | 7 "mojo/public/js/bindings/core", |
8 "mojo/public/js/bindings/support", | 8 "mojo/public/js/bindings/support", |
9 ], function(codec, core, support) { | 9 ], function(codec, core, support) { |
10 | 10 |
11 function Connector(handle) { | 11 function Connector(handle) { |
12 this.handle_ = handle; | 12 this.handle_ = handle; |
13 this.dropWrites_ = false; | 13 this.dropWrites_ = false; |
14 this.error_ = false; | 14 this.error_ = false; |
15 this.incomingReceiver_ = null; | 15 this.incomingReceiver_ = null; |
16 this.readWaitCookie_ = null; | 16 this.readWaitCookie_ = null; |
17 this.errorHandler_ = null; | 17 this.errorHandler_ = null; |
18 | 18 |
19 this.waitToReadMore_(); | 19 this.waitToReadMore_(); |
20 } | 20 } |
21 | 21 |
22 Connector.prototype.close = function() { | 22 Connector.prototype.close = function() { |
23 if (this.readWaitCookie_) { | 23 if (this.readWaitCookie_) { |
24 support.cancelWait(this.readWaitCookie_); | 24 support.cancelWait(this.readWaitCookie_); |
25 this.readWaitCookie_ = null; | 25 this.readWaitCookie_ = null; |
26 } | 26 } |
27 if (this.handle_ != core.kInvalidHandle) { | 27 if (this.handle_ != null) { |
28 core.close(this.handle_); | 28 core.close(this.handle_); |
29 this.handle_ = core.kInvalidHandle; | 29 this.handle_ = null; |
30 } | 30 } |
31 }; | 31 }; |
32 | 32 |
33 Connector.prototype.accept = function(message) { | 33 Connector.prototype.accept = function(message) { |
34 if (this.error_) | 34 if (this.error_) |
35 return false; | 35 return false; |
36 | 36 |
37 if (this.dropWrites_) | 37 if (this.dropWrites_) |
38 return true; | 38 return true; |
39 | 39 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 if (this.incomingReceiver_) { | 100 if (this.incomingReceiver_) { |
101 this.incomingReceiver_.accept(message); | 101 this.incomingReceiver_.accept(message); |
102 } | 102 } |
103 } | 103 } |
104 }; | 104 }; |
105 | 105 |
106 var exports = {}; | 106 var exports = {}; |
107 exports.Connector = Connector; | 107 exports.Connector = Connector; |
108 return exports; | 108 return exports; |
109 }); | 109 }); |
OLD | NEW |