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

Unified Diff: sdk/lib/_internal/compiler/implementation/lib/async_patch.dart

Issue 16538002: Move lib from sdk/lib/_internal/compiler/implementation to _internal root. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/lib/collection_dev_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/lib/async_patch.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/lib/async_patch.dart (revision 23664)
+++ sdk/lib/_internal/compiler/implementation/lib/async_patch.dart (working copy)
@@ -1,85 +0,0 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// Patch file for the dart:async library.
-
-import 'dart:_isolate_helper' show IsolateNatives, TimerImpl;
-import 'dart:_foreign_helper' show JS, DART_CLOSURE_TO_JS;
-
-patch class Timer {
- patch factory Timer(Duration duration, void callback()) {
- int milliseconds = duration.inMilliseconds;
- if (milliseconds < 0) milliseconds = 0;
- return new TimerImpl(milliseconds, callback);
- }
-
- patch factory Timer.periodic(Duration duration, void callback(Timer timer)) {
- int milliseconds = duration.inMilliseconds;
- if (milliseconds < 0) milliseconds = 0;
- return new TimerImpl.periodic(milliseconds, callback);
- }
-}
-
-patch class _AsyncRun {
- patch static void _enqueueImmediate(void callback()) {
- // TODO(9002): don't use the Timer to enqueue the immediate callback.
- Timer.run(callback);
- }
-}
-
-patch class DeferredLibrary {
- patch Future<bool> load() {
- return _load(libraryName, uri);
- }
-}
-
-// TODO(ahe): This should not only apply to this isolate.
-final _loadedLibraries = <String, Completer<bool>>{};
-
-Future<bool> _load(String libraryName, String uri) {
- // TODO(ahe): Validate libraryName. Kasper points out that you want
- // to be able to experiment with the effect of toggling @DeferLoad,
- // so perhaps we should silently ignore "bad" library names.
- Completer completer = new Completer<bool>();
- Future<bool> future = _loadedLibraries[libraryName];
- if (future != null) {
- future.then((_) { completer.complete(false); });
- return completer.future;
- }
- _loadedLibraries[libraryName] = completer.future;
-
- if (uri == null) {
- uri = IsolateNatives.thisScript;
- int index = uri.lastIndexOf('/');
- uri = '${uri.substring(0, index + 1)}part.js';
- }
-
- if (_hasDocument) {
- // Inject a script tag.
- var script = JS('', 'document.createElement("script")');
- JS('', '#.type = "text/javascript"', script);
- JS('', '#.async = "async"', script);
- JS('', '#.src = #', script, uri);
- var onLoad = JS('', '#.bind(null, #)',
- DART_CLOSURE_TO_JS(_onDeferredLibraryLoad), completer);
- JS('', '#.addEventListener("load", #, false)', script, onLoad);
- JS('', 'document.body.appendChild(#)', script);
- } else if (JS('String', 'typeof load') == 'function') {
- Timer.run(() {
- JS('void', 'load(#)', uri);
- completer.complete(true);
- });
- } else {
- throw new UnsupportedError('load not supported');
- }
- return completer.future;
-}
-
-/// Used to implement deferred loading. Used as callback on "load"
-/// event above in [load].
-_onDeferredLibraryLoad(Completer<bool> completer, event) {
- completer.complete(true);
-}
-
-bool get _hasDocument => JS('String', 'typeof document') == 'object';
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/lib/collection_dev_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698