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

Side by Side Diff: third_party/pkg/barback-0.13.0/lib/src/serialize.dart

Issue 291843011: Run pub tests against older versions of barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 barback.serialize; 5 library barback.serialize;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:isolate'; 8 import 'dart:isolate';
9 9
10 import 'package:stack_trace/stack_trace.dart'; 10 import 'package:stack_trace/stack_trace.dart';
11 11
12 import 'asset/asset_id.dart'; 12 import 'asset_id.dart';
13 import 'utils.dart'; 13 import 'utils.dart';
14 14
15 /// Converts [id] into a serializable map. 15 /// Converts [id] into a serializable map.
16 Map serializeId(AssetId id) => {'package': id.package, 'path': id.path}; 16 Map serializeId(AssetId id) => {'package': id.package, 'path': id.path};
17 17
18 /// Converts [stream] into a [SendPort] with which another isolate can request 18 /// Converts [stream] into a [SendPort] with which another isolate can request
19 /// the data from [stream]. 19 /// the data from [stream].
20 SendPort serializeStream(Stream stream) { 20 SendPort serializeStream(Stream stream) {
21 var receivePort = new ReceivePort(); 21 var receivePort = new ReceivePort();
22 receivePort.first.then((sendPort) { 22 receivePort.first.then((sendPort) {
(...skipping 15 matching lines...) Expand all
38 38
39 /// Convert a [SendPort] whose opposite is waiting to send us a stream into a 39 /// Convert a [SendPort] whose opposite is waiting to send us a stream into a
40 /// [Stream]. 40 /// [Stream].
41 /// 41 ///
42 /// No stream data will actually be sent across the isolate boundary until 42 /// No stream data will actually be sent across the isolate boundary until
43 /// someone subscribes to the returned stream. 43 /// someone subscribes to the returned stream.
44 Stream deserializeStream(SendPort sendPort) { 44 Stream deserializeStream(SendPort sendPort) {
45 return callbackStream(() { 45 return callbackStream(() {
46 var receivePort = new ReceivePort(); 46 var receivePort = new ReceivePort();
47 sendPort.send(receivePort.sendPort); 47 sendPort.send(receivePort.sendPort);
48 // TODO(nweiz): use a const constructor for StreamTransformer when issue
49 // 14971 is fixed.
48 return receivePort.transform( 50 return receivePort.transform(
49 const StreamTransformer(_deserializeTransformer)); 51 new StreamTransformer(_deserializeTransformer));
50 }); 52 });
51 } 53 }
52 54
53 /// The body of a [StreamTransformer] that deserializes the values in a stream 55 /// The body of a [StreamTransformer] that deserializes the values in a stream
54 /// sent by [serializeStream]. 56 /// sent by [serializeStream].
55 StreamSubscription _deserializeTransformer(Stream input, bool cancelOnError) { 57 StreamSubscription _deserializeTransformer(Stream input, bool cancelOnError) {
56 var subscription; 58 var subscription;
57 var transformed = input.transform(new StreamTransformer.fromHandlers( 59 var transformed = input.transform(new StreamTransformer.fromHandlers(
58 handleData: (data, sink) { 60 handleData: (data, sink) {
59 if (data['type'] == 'data') { 61 if (data['type'] == 'data') {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 /// A regular expression to match the exception prefix that some exceptions' 117 /// A regular expression to match the exception prefix that some exceptions'
116 /// [Object.toString] values contain. 118 /// [Object.toString] values contain.
117 final _exceptionPrefix = new RegExp(r'^([A-Z][a-zA-Z]*)?(Exception|Error): '); 119 final _exceptionPrefix = new RegExp(r'^([A-Z][a-zA-Z]*)?(Exception|Error): ');
118 120
119 /// Get a string description of an exception. 121 /// Get a string description of an exception.
120 /// 122 ///
121 /// Many exceptions include the exception class name at the beginning of their 123 /// Many exceptions include the exception class name at the beginning of their
122 /// [toString], so we remove that if it exists. 124 /// [toString], so we remove that if it exists.
123 String _getErrorMessage(error) => 125 String _getErrorMessage(error) =>
124 error.toString().replaceFirst(_exceptionPrefix, ''); 126 error.toString().replaceFirst(_exceptionPrefix, '');
OLDNEW
« no previous file with comments | « third_party/pkg/barback-0.13.0/lib/src/pool.dart ('k') | third_party/pkg/barback-0.13.0/lib/src/stream_pool.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698