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

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

Issue 12380019: Timer callback doesn't take an argument anymore. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 /// Helper functionality to make working with IO easier. 5 /// Helper functionality to make working with IO easier.
6 library io; 6 library io;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:isolate'; 10 import 'dart:isolate';
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 /// [milliseconds] have passed, then the return value completes in the same way. 586 /// [milliseconds] have passed, then the return value completes in the same way.
587 /// However, if [milliseconds] pass before [input] has completed, it completes 587 /// However, if [milliseconds] pass before [input] has completed, it completes
588 /// with a [TimeoutException] with [description] (which should be a fragment 588 /// with a [TimeoutException] with [description] (which should be a fragment
589 /// describing the action that timed out). 589 /// describing the action that timed out).
590 /// 590 ///
591 /// Note that timing out will not cancel the asynchronous operation behind 591 /// Note that timing out will not cancel the asynchronous operation behind
592 /// [input]. 592 /// [input].
593 Future timeout(Future input, int milliseconds, String description) { 593 Future timeout(Future input, int milliseconds, String description) {
594 bool completed = false; 594 bool completed = false;
595 var completer = new Completer(); 595 var completer = new Completer();
596 var timer = new Timer(new Duration(milliseconds: milliseconds), (_) { 596 var timer = new Timer(new Duration(milliseconds: milliseconds), () {
597 completed = true; 597 completed = true;
598 completer.completeError(new TimeoutException( 598 completer.completeError(new TimeoutException(
599 'Timed out while $description.')); 599 'Timed out while $description.'));
600 }); 600 });
601 input.then((value) { 601 input.then((value) {
602 if (completed) return; 602 if (completed) return;
603 timer.cancel(); 603 timer.cancel();
604 completer.complete(value); 604 completer.complete(value);
605 }).catchError((e) { 605 }).catchError((e) {
606 if (completed) return; 606 if (completed) return;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 const PubProcessResult(this.stdout, this.stderr, this.exitCode); 804 const PubProcessResult(this.stdout, this.stderr, this.exitCode);
805 805
806 bool get success => exitCode == 0; 806 bool get success => exitCode == 0;
807 } 807 }
808 808
809 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. 809 /// Gets a [Uri] for [uri], which can either already be one, or be a [String].
810 Uri _getUri(uri) { 810 Uri _getUri(uri) {
811 if (uri is Uri) return uri; 811 if (uri is Uri) return uri;
812 return Uri.parse(uri); 812 return Uri.parse(uri);
813 } 813 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698