| 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 part of core; | 5 part of core; |
| 6 | 6 |
| 7 class MojoEventStream extends Stream<int> { | 7 class MojoEventStream extends Stream<List<int>> { |
| 8 // The underlying Mojo handle. | 8 // The underlying Mojo handle. |
| 9 MojoHandle _handle; | 9 MojoHandle _handle; |
| 10 | 10 |
| 11 // Providing our own stream controller allows us to take custom actions when | 11 // Providing our own stream controller allows us to take custom actions when |
| 12 // listeners pause/resume/etc. their StreamSubscription. | 12 // listeners pause/resume/etc. their StreamSubscription. |
| 13 StreamController _controller; | 13 StreamController _controller; |
| 14 | 14 |
| 15 // The send port that we give to the handle watcher to notify us of handle | 15 // The send port that we give to the handle watcher to notify us of handle |
| 16 // events. | 16 // events. |
| 17 SendPort _sendPort; | 17 SendPort _sendPort; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 bool get readyRead => _handle.readyRead; | 120 bool get readyRead => _handle.readyRead; |
| 121 bool get readyWrite => _handle.readyWrite; | 121 bool get readyWrite => _handle.readyWrite; |
| 122 | 122 |
| 123 String toString() => "$_handle"; | 123 String toString() => "$_handle"; |
| 124 } | 124 } |
| 125 | 125 |
| 126 abstract class Listener { | 126 abstract class Listener { |
| 127 StreamSubscription<List<int>> listen({Function onClosed}); | 127 StreamSubscription<List<int>> listen({Function onClosed}); |
| 128 } | 128 } |
| 129 | 129 |
| 130 class MojoEventStreamListener implements Listener { | 130 class MojoEventStreamListener { |
| 131 MojoMessagePipeEndpoint _endpoint; | 131 MojoMessagePipeEndpoint _endpoint; |
| 132 MojoEventStream _eventStream; | 132 MojoEventStream _eventStream; |
| 133 bool _isOpen = false; | 133 bool _isOpen = false; |
| 134 bool _isInHandler = false; | 134 bool _isInHandler = false; |
| 135 | 135 |
| 136 MojoEventStreamListener(MojoMessagePipeEndpoint endpoint) | 136 MojoEventStreamListener(MojoMessagePipeEndpoint endpoint) |
| 137 : _endpoint = endpoint, | 137 : _endpoint = endpoint, |
| 138 _eventStream = new MojoEventStream(endpoint.handle), | 138 _eventStream = new MojoEventStream(endpoint.handle), |
| 139 _isOpen = false; | 139 _isOpen = false; |
| 140 | 140 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 } | 202 } |
| 203 | 203 |
| 204 void handleRead() {} | 204 void handleRead() {} |
| 205 void handleWrite() {} | 205 void handleWrite() {} |
| 206 | 206 |
| 207 MojoMessagePipeEndpoint get endpoint => _endpoint; | 207 MojoMessagePipeEndpoint get endpoint => _endpoint; |
| 208 bool get isOpen => _isOpen; | 208 bool get isOpen => _isOpen; |
| 209 bool get isInHandler => _isInHandler; | 209 bool get isInHandler => _isInHandler; |
| 210 bool get isBound => _endpoint != null; | 210 bool get isBound => _endpoint != null; |
| 211 } | 211 } |
| OLD | NEW |