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

Side by Side Diff: runtime/bin/builtin.dart

Issue 203213002: Make http-imports faster to load, by hinting persistent connection on request. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 library builtin; 5 library builtin;
6 import 'dart:io'; 6 import 'dart:io';
7 import 'dart:async'; 7 import 'dart:async';
8 // import 'root_library'; happens here from C Code 8 // import 'root_library'; happens here from C Code
9 9
10 // The root library (aka the script) is imported into this library. The 10 // The root library (aka the script) is imported into this library. The
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 73
74 void _makeHttpRequest(String uri) { 74 void _makeHttpRequest(String uri) {
75 var _client = new HttpClient(); 75 var _client = new HttpClient();
76 _httpRequestResponseCode = 0; 76 _httpRequestResponseCode = 0;
77 _httpRequestStatusString = null; 77 _httpRequestStatusString = null;
78 _httpRequestResponse = null; 78 _httpRequestResponse = null;
79 try { 79 try {
80 Uri requestUri = Uri.parse(uri); 80 Uri requestUri = Uri.parse(uri);
81 _client.getUrl(requestUri) 81 _client.getUrl(requestUri)
82 .then((HttpClientRequest request) => request.close()) 82 .then((HttpClientRequest request) {
83 request.persistentConnection = false;
84 return request.close();
85 })
83 .then((HttpClientResponse response) { 86 .then((HttpClientResponse response) {
84 return response 87 // Only create a ByteBuilder, if multiple chunks is received.
floitsch 2014/03/18 12:26:24 are received.
Anders Johnsen 2014/03/18 12:33:24 Done.
85 .fold(new BytesBuilder(), (b, d) => b..add(d)) 88 var bufferOrBuilder;
86 .then((builder) { 89 response.listen(
87 _requestCompleted(builder.takeBytes(), response); 90 (data) {
88 // This client is only used for a single request. Force closing 91 if (bufferOrBuilder == null) {
89 // it now otherwise we wait around until it times out. 92 bufferOrBuilder = data;
Ivan Posva 2014/03/18 12:13:43 This comment was crucial in understanding why the
Anders Johnsen 2014/03/18 12:22:33 No, it was crucial to why we were using `force: tr
90 _client.close(force:true); 93 } else {
91 }); 94 if (bufferOrBuilder is! BytesBuilder) {
95 bufferOrBuilder = new BytesBuilder()
96 ..add(bufferOrBuilder);
97 }
98 bufferOrBuilder.add(data);
99 }
100 },
101 onDone: () {
102 var data = bufferOrBuilder;
103 if (data is BytesBuilder) data = data.takeBytes();
104 _requestCompleted(data, response);
105 _client.close();
106 },
107 onError: _requestFailed);
92 }).catchError((error) { 108 }).catchError((error) {
93 _requestFailed(error); 109 _requestFailed(error);
94 }); 110 });
95 } catch (error) { 111 } catch (error) {
96 _requestFailed(error); 112 _requestFailed(error);
97 } 113 }
98 // TODO(floitsch): remove this line. It's just here to push an event on the 114 // TODO(floitsch): remove this line. It's just here to push an event on the
99 // event loop so that we invoke the scheduled microtasks. Also remove the 115 // event loop so that we invoke the scheduled microtasks. Also remove the
100 // import of dart:async when this line is not needed anymore. 116 // import of dart:async when this line is not needed anymore.
101 Timer.run(() {}); 117 Timer.run(() {});
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } else if (Platform.isWindows) { 315 } else if (Platform.isWindows) {
300 filename = '$name.dll'; 316 filename = '$name.dll';
301 } else { 317 } else {
302 _logResolution( 318 _logResolution(
303 'Native extensions not supported on ${Platform.operatingSystem}'); 319 'Native extensions not supported on ${Platform.operatingSystem}');
304 throw 'Native extensions not supported on ${Platform.operatingSystem}'; 320 throw 'Native extensions not supported on ${Platform.operatingSystem}';
305 } 321 }
306 322
307 return [path, filename, name]; 323 return [path, filename, name];
308 } 324 }
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