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

Side by Side Diff: pkg/scheduled_test/lib/scheduled_server.dart

Issue 14070010: Refactor Future constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added co19 issue number. Created 7 years, 8 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 scheduled_test.scheduled_server; 5 library scheduled_test.scheduled_server;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:uri'; 10 import 'dart:uri';
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 throw e; 84 throw e;
85 }); 85 });
86 }, "'$description' waiting for $method $path"); 86 }, "'$description' waiting for $method $path");
87 } 87 }
88 88
89 /// The handler for incoming [HttpRequest]s to this server. This dispatches 89 /// The handler for incoming [HttpRequest]s to this server. This dispatches
90 /// the request to the first handler in the queue. It's that handler's 90 /// the request to the first handler in the queue. It's that handler's
91 /// responsibility to check that the method/path are correct and that it's 91 /// responsibility to check that the method/path are correct and that it's
92 /// being run at the correct time. 92 /// being run at the correct time.
93 void _handleRequest(HttpRequest request) { 93 void _handleRequest(HttpRequest request) {
94 wrapFuture(new Future.of(() { 94 wrapFuture(new Future.sync(() {
95 if (_handlers.isEmpty) { 95 if (_handlers.isEmpty) {
96 throw "'$description' received ${request.method} ${request.uri.path} " 96 throw "'$description' received ${request.method} ${request.uri.path} "
97 "when no more requests were expected."; 97 "when no more requests were expected.";
98 } 98 }
99 return _handlers.removeFirst().fn(request); 99 return _handlers.removeFirst().fn(request);
100 }).catchError((e) { 100 }).catchError((e) {
101 // Close the server so that we don't leave a dangling request. 101 // Close the server so that we don't leave a dangling request.
102 _server.then((s) => s.close()); 102 _server.then((s) => s.close());
103 throw e; 103 throw e;
104 }), 'receiving ${request.method} ${request.uri}'); 104 }), 'receiving ${request.method} ${request.uri}');
105 } 105 }
106 } 106 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/lib/scheduled_process.dart ('k') | pkg/scheduled_test/lib/src/descriptor/directory_descriptor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698