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

Side by Side Diff: utils/pub/utils.dart

Issue 12150006: Fix a few breakages with Pub's oauth2 test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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
« no previous file with comments | « no previous file | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 /// Generic utility functions. Stuff that should possibly be in core. 5 /// Generic utility functions. Stuff that should possibly be in core.
6 library utils; 6 library utils;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:crypto'; 9 import 'dart:crypto';
10 import 'dart:isolate'; 10 import 'dart:isolate';
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 }, 130 },
131 onError: (e) => completer.completeError(e.error, e.stackTrace), 131 onError: (e) => completer.completeError(e.error, e.stackTrace),
132 onDone: () => completer.completeError(new StateError("No elements")), 132 onDone: () => completer.completeError(new StateError("No elements")),
133 unsubscribeOnError: true); 133 unsubscribeOnError: true);
134 return completer.future; 134 return completer.future;
135 } 135 }
136 136
137 /// Returns a wrapped version of [stream] along with a [StreamSubscription] that 137 /// Returns a wrapped version of [stream] along with a [StreamSubscription] that
138 /// can be used to control the wrapped stream. 138 /// can be used to control the wrapped stream.
139 Pair<Stream, StreamSubscription> streamWithSubscription(Stream stream) { 139 Pair<Stream, StreamSubscription> streamWithSubscription(Stream stream) {
140 var controller = stream.isSingleSubscription ? 140 var controller = stream.isBroadcast ?
141 new StreamController() : 141 new StreamController.broadcast() :
142 new StreamController.multiSubscription(); 142 new StreamController();
143 var subscription = stream.listen(controller.add, 143 var subscription = stream.listen(controller.add,
144 onError: controller.signalError, 144 onError: controller.signalError,
145 onDone: controller.close); 145 onDone: controller.close);
146 return new Pair<Stream, StreamSubscription>(controller.stream, subscription); 146 return new Pair<Stream, StreamSubscription>(controller.stream, subscription);
147 } 147 }
148 148
149 // TODO(nweiz): remove this when issue 7787 is fixed. 149 // TODO(nweiz): remove this when issue 7787 is fixed.
150 /// Creates two single-subscription [Stream]s that each emit all values and 150 /// Creates two single-subscription [Stream]s that each emit all values and
151 /// errors from [stream]. This is useful if [stream] is single-subscription but 151 /// errors from [stream]. This is useful if [stream] is single-subscription but
152 /// multiple subscribers are necessary. 152 /// multiple subscribers are necessary.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 259
260 /// Add all key/value pairs from [source] to [destination], overwriting any 260 /// Add all key/value pairs from [source] to [destination], overwriting any
261 /// pre-existing values. 261 /// pre-existing values.
262 void mapAddAll(Map destination, Map source) => 262 void mapAddAll(Map destination, Map source) =>
263 source.forEach((key, value) => destination[key] = value); 263 source.forEach((key, value) => destination[key] = value);
264 264
265 /// Decodes a URL-encoded string. Unlike [decodeUriComponent], this includes 265 /// Decodes a URL-encoded string. Unlike [decodeUriComponent], this includes
266 /// replacing `+` with ` `. 266 /// replacing `+` with ` `.
267 String urlDecode(String encoded) => 267 String urlDecode(String encoded) =>
268 decodeUriComponent(encoded.replaceAll("+", " ")); 268 decodeUriComponent(encoded.replaceAll("+", " "));
OLDNEW
« no previous file with comments | « no previous file | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698