OLD | NEW |
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 // NOTE: Do not import 'dart:io' in builtin. | 6 // NOTE: Do not import 'dart:io' in builtin. |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
10 | 10 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 _finishedOneLoadRequest(uri); | 288 _finishedOneLoadRequest(uri); |
289 } | 289 } |
290 | 290 |
291 | 291 |
292 _loadDataAsyncLoadPort(int tag, | 292 _loadDataAsyncLoadPort(int tag, |
293 String uri, | 293 String uri, |
294 String libraryUri, | 294 String libraryUri, |
295 Uri resourceUri) { | 295 Uri resourceUri) { |
296 var receivePort = new ReceivePort(); | 296 var receivePort = new ReceivePort(); |
297 receivePort.first.then((dataOrError) { | 297 receivePort.first.then((dataOrError) { |
| 298 receivePort.close(); |
298 if (dataOrError is List<int>) { | 299 if (dataOrError is List<int>) { |
299 _loadScript(tag, uri, libraryUri, dataOrError); | 300 _loadScript(tag, uri, libraryUri, dataOrError); |
300 } else { | 301 } else { |
301 assert(dataOrError is String); | 302 assert(dataOrError is String); |
302 var error = new LoadError(dataOrError.toString()); | 303 var error = new LoadError(dataOrError.toString()); |
303 _asyncLoadError(tag, uri, libraryUri, error); | 304 _asyncLoadError(tag, uri, libraryUri, error); |
304 } | 305 } |
305 }).catchError((e) { | 306 }).catchError((e) { |
| 307 receivePort.close(); |
306 // Wrap inside a LoadError unless we are already propagating a previously | 308 // Wrap inside a LoadError unless we are already propagating a previously |
307 // seen LoadError. | 309 // seen LoadError. |
308 var error = (e is LoadError) ? e : new LoadError(e.toString); | 310 var error = (e is LoadError) ? e : new LoadError(e.toString); |
309 _asyncLoadError(tag, uri, libraryUri, error); | 311 _asyncLoadError(tag, uri, libraryUri, error); |
310 }); | 312 }); |
311 | 313 |
312 try { | 314 try { |
313 var msg = [receivePort.sendPort, resourceUri.toString()]; | 315 var msg = [receivePort.sendPort, resourceUri.toString()]; |
314 _loadPort.send(msg); | 316 _loadPort.send(msg); |
315 _startingOneLoadRequest(uri); | 317 _startingOneLoadRequest(uri); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 } else { | 405 } else { |
404 name = userUri.substring(index + 1); | 406 name = userUri.substring(index + 1); |
405 path = userUri.substring(0, index + 1); | 407 path = userUri.substring(0, index + 1); |
406 } | 408 } |
407 | 409 |
408 path = _filePathFromUri(path); | 410 path = _filePathFromUri(path); |
409 var filename = _platformExtensionFileName(name); | 411 var filename = _platformExtensionFileName(name); |
410 | 412 |
411 return [path, filename, name]; | 413 return [path, filename, name]; |
412 } | 414 } |
OLD | NEW |