Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: lib/src/util/multi_channel.dart

Issue 959383004: Add a host script to run in a browser and start iframes for suites. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library unittest.multi_channel; 5 library unittest.multi_channel;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'stream_channel.dart';
10
9 /// A class that multiplexes multiple virtual channels across a single 11 /// A class that multiplexes multiple virtual channels across a single
10 /// underlying transport layer. 12 /// underlying transport layer.
11 /// 13 ///
12 /// This should be connected to another [MultiChannel] on the other end of the 14 /// This should be connected to another [MultiChannel] on the other end of the
13 /// underlying channel. It starts with a single default virtual channel, 15 /// underlying channel. It starts with a single default virtual channel,
14 /// accessible via [stream] and [sink]. Additional virtual channels can be 16 /// accessible via [stream] and [sink]. Additional virtual channels can be
15 /// created with [virtualChannel]. 17 /// created with [virtualChannel].
16 /// 18 ///
17 /// When a virtual channel is created by one endpoint, the other must connect to 19 /// When a virtual channel is created by one endpoint, the other must connect to
18 /// it before messages may be sent through it. The first endpoint passes its 20 /// it before messages may be sent through it. The first endpoint passes its
(...skipping 13 matching lines...) Expand all
32 /// // ... 34 /// // ...
33 /// }); 35 /// });
34 /// ``` 36 /// ```
35 /// 37 ///
36 /// Sending errors across a [MultiChannel] is not supported. Any errors from the 38 /// Sending errors across a [MultiChannel] is not supported. Any errors from the
37 /// underlying stream will be reported only via the default 39 /// underlying stream will be reported only via the default
38 /// [MultiChannel.stream]. 40 /// [MultiChannel.stream].
39 /// 41 ///
40 /// Each virtual channel may be closed individually. When all of them are 42 /// Each virtual channel may be closed individually. When all of them are
41 /// closed, the underlying [StreamSink] is closed automatically. 43 /// closed, the underlying [StreamSink] is closed automatically.
42 abstract class MultiChannel { 44 abstract class MultiChannel implements StreamChannel {
43 /// The default input stream. 45 /// The default input stream.
44 /// 46 ///
45 /// This connects to the remote [sink]. 47 /// This connects to the remote [sink].
46 Stream get stream; 48 Stream get stream;
47 49
48 /// The default output stream. 50 /// The default output stream.
49 /// 51 ///
50 /// This connects to the remote [stream]. If this is closed, the remote 52 /// This connects to the remote [stream]. If this is closed, the remote
51 /// [stream] will close, but other virtual channels will remain open and new 53 /// [stream] will close, but other virtual channels will remain open and new
52 /// virtual channels may be opened. 54 /// virtual channels may be opened.
(...skipping 17 matching lines...) Expand all
70 /// 72 ///
71 /// Throws an [ArgumentError] if a virtual channel already exists for [id]. 73 /// Throws an [ArgumentError] if a virtual channel already exists for [id].
72 /// Throws a [StateError] if the underlying channel is closed. 74 /// Throws a [StateError] if the underlying channel is closed.
73 VirtualChannel virtualChannel([id]); 75 VirtualChannel virtualChannel([id]);
74 } 76 }
75 77
76 /// The implementation of [MultiChannel]. 78 /// The implementation of [MultiChannel].
77 /// 79 ///
78 /// This is private so that [VirtualChannel] can inherit from [MultiChannel] 80 /// This is private so that [VirtualChannel] can inherit from [MultiChannel]
79 /// without having to implement all the private members. 81 /// without having to implement all the private members.
80 class _MultiChannel implements MultiChannel { 82 class _MultiChannel extends StreamChannelMixin implements MultiChannel {
81 /// The inner stream over which all communication is received. 83 /// The inner stream over which all communication is received.
82 /// 84 ///
83 /// This will be `null` if the underlying communication channel is closed. 85 /// This will be `null` if the underlying communication channel is closed.
84 Stream _innerStream; 86 Stream _innerStream;
85 87
86 /// The inner sink over which all communication is sent. 88 /// The inner sink over which all communication is sent.
87 /// 89 ///
88 /// This will be `null` if the underlying communication channel is closed. 90 /// This will be `null` if the underlying communication channel is closed.
89 StreamSink _innerSink; 91 StreamSink _innerSink;
90 92
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 controller.close(); 218 controller.close();
217 } 219 }
218 } 220 }
219 } 221 }
220 222
221 /// A virtual channel created by [MultiChannel]. 223 /// A virtual channel created by [MultiChannel].
222 /// 224 ///
223 /// This implements [MultiChannel] for convenience. 225 /// This implements [MultiChannel] for convenience.
224 /// [VirtualChannel.virtualChannel] is semantically identical to the parent's 226 /// [VirtualChannel.virtualChannel] is semantically identical to the parent's
225 /// [MultiChannel.virtualChannel]. 227 /// [MultiChannel.virtualChannel].
226 class VirtualChannel implements MultiChannel { 228 class VirtualChannel extends StreamChannelMixin implements MultiChannel {
227 /// The [MultiChannel] that created this. 229 /// The [MultiChannel] that created this.
228 final MultiChannel _parent; 230 final MultiChannel _parent;
229 231
230 /// The identifier for this channel. 232 /// The identifier for this channel.
231 /// 233 ///
232 /// This can be sent across the [MultiChannel] to provide the remote endpoint 234 /// This can be sent across the [MultiChannel] to provide the remote endpoint
233 /// a means to connect to this channel. Nothing about this is guaranteed 235 /// a means to connect to this channel. Nothing about this is guaranteed
234 /// except that it will be JSON-serializable. 236 /// except that it will be JSON-serializable.
235 final id; 237 final id;
236 238
237 final Stream stream; 239 final Stream stream;
238 final StreamSink sink; 240 final StreamSink sink;
239 241
240 VirtualChannel._(this._parent, this.id, this.stream, this.sink); 242 VirtualChannel._(this._parent, this.id, this.stream, this.sink);
241 243
242 VirtualChannel virtualChannel([id]) => _parent.virtualChannel(id); 244 VirtualChannel virtualChannel([id]) => _parent.virtualChannel(id);
243 } 245 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698