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

Side by Side Diff: lib/runtime/dart/async.js

Issue 1135543003: Fixes #178 (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Reformat Created 5 years, 7 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
« no previous file with comments | « lib/runtime/dart/_internal.js ('k') | lib/runtime/dart/core.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 var async = dart.defineLibrary(async, {}); 1 var async = dart.defineLibrary(async, {});
2 var core = dart.import(core); 2 var core = dart.import(core);
3 var _internal = dart.import(_internal); 3 var _internal = dart.import(_internal);
4 var _js_helper = dart.lazyImport(_js_helper); 4 var _js_helper = dart.lazyImport(_js_helper);
5 var _isolate_helper = dart.lazyImport(_isolate_helper); 5 var _isolate_helper = dart.lazyImport(_isolate_helper);
6 var collection = dart.import(collection); 6 var collection = dart.import(collection);
7 (function(exports, core, _internal, _js_helper, _isolate_helper, collection) { 7 (function(exports, core, _internal, _js_helper, _isolate_helper, collection) {
8 'use strict'; 8 'use strict';
9 // Function _invokeErrorHandler: (Function, Object, StackTrace) → dynamic 9 // Function _invokeErrorHandler: (Function, Object, StackTrace) → dynamic
10 function _invokeErrorHandler(errorHandler, error, stackTrace) { 10 function _invokeErrorHandler(errorHandler, error, stackTrace) {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 }, 207 },
208 onCancel: () => { 208 onCancel: () => {
209 subscription.cancel(); 209 subscription.cancel();
210 }, 210 },
211 sync: true 211 sync: true
212 }); 212 });
213 } 213 }
214 return controller.stream; 214 return controller.stream;
215 } 215 }
216 asyncExpand(convert) { 216 asyncExpand(convert) {
217 dart.as(convert, dart.functionType(Stream, [T])); 217 dart.as(convert, dart.functionType(Stream$(), [T]));
218 let controller = null; 218 let controller = null;
219 let subscription = null; 219 let subscription = null;
220 // Function onListen: () → void 220 // Function onListen: () → void
221 let onListen = (() => { 221 let onListen = (() => {
222 dart.assert(dart.is(controller, _StreamController) || dart.is(controll er, _BroadcastStreamController)); 222 dart.assert(dart.is(controller, _StreamController) || dart.is(controll er, _BroadcastStreamController));
223 let eventSink = controller; 223 let eventSink = controller;
224 subscription = this.listen(event => { 224 subscription = this.listen(event => {
225 dart.as(event, T); 225 dart.as(event, T);
226 let newStream = null; 226 let newStream = null;
227 try { 227 try {
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 dart.as(onData, dart.functionType(dart.void, [T])); 856 dart.as(onData, dart.functionType(dart.void, [T]));
857 dart.as(onDone, dart.functionType(dart.void, [])); 857 dart.as(onDone, dart.functionType(dart.void, []));
858 return this[_controller][_subscribe](onData, onError, onDone, cancelOnEr ror); 858 return this[_controller][_subscribe](onData, onError, onDone, cancelOnEr ror);
859 } 859 }
860 get hashCode() { 860 get hashCode() {
861 return dart.notNull(dart.hashCode(this[_controller])) ^ 892482866; 861 return dart.notNull(dart.hashCode(this[_controller])) ^ 892482866;
862 } 862 }
863 ['=='](other) { 863 ['=='](other) {
864 if (core.identical(this, other)) 864 if (core.identical(this, other))
865 return true; 865 return true;
866 if (!dart.is(other, _ControllerStream)) 866 if (!dart.is(other, _ControllerStream$()))
867 return false; 867 return false;
868 let otherStream = dart.as(other, _ControllerStream); 868 let otherStream = dart.as(other, _ControllerStream$());
869 return core.identical(otherStream[_controller], this[_controller]); 869 return core.identical(otherStream[_controller], this[_controller]);
870 } 870 }
871 } 871 }
872 return _ControllerStream; 872 return _ControllerStream;
873 }); 873 });
874 let _ControllerStream = _ControllerStream$(); 874 let _ControllerStream = _ControllerStream$();
875 let _BroadcastStream$ = dart.generic(function(T) { 875 let _BroadcastStream$ = dart.generic(function(T) {
876 class _BroadcastStream extends _ControllerStream$(T) { 876 class _BroadcastStream extends _ControllerStream$(T) {
877 _BroadcastStream(controller) { 877 _BroadcastStream(controller) {
878 super._ControllerStream(dart.as(controller, _StreamControllerLifecycle$( T))); 878 super._ControllerStream(dart.as(controller, _StreamControllerLifecycle$( T)));
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
1828 let remaining = 0; 1828 let remaining = 0;
1829 let error = null; 1829 let error = null;
1830 let stackTrace = null; 1830 let stackTrace = null;
1831 // Function handleError: (dynamic, dynamic) → void 1831 // Function handleError: (dynamic, dynamic) → void
1832 let handleError = (theError, theStackTrace) => { 1832 let handleError = (theError, theStackTrace) => {
1833 remaining = dart.notNull(remaining) - 1; 1833 remaining = dart.notNull(remaining) - 1;
1834 if (values != null) { 1834 if (values != null) {
1835 if (cleanUp != null) { 1835 if (cleanUp != null) {
1836 for (let value of values) { 1836 for (let value of values) {
1837 if (value != null) { 1837 if (value != null) {
1838 new Future.sync(() => { 1838 new (Future$()).sync(() => {
1839 dart.dcall(cleanUp, value); 1839 dart.dcall(cleanUp, value);
1840 }); 1840 });
1841 } 1841 }
1842 } 1842 }
1843 } 1843 }
1844 values = null; 1844 values = null;
1845 if (remaining == 0 || dart.notNull(eagerError)) { 1845 if (remaining == 0 || dart.notNull(eagerError)) {
1846 result[_completeError](theError, dart.as(theStackTrace, core.Stack Trace)); 1846 result[_completeError](theError, dart.as(theStackTrace, core.Stack Trace));
1847 } else { 1847 } else {
1848 error = theError; 1848 error = theError;
1849 stackTrace = dart.as(theStackTrace, core.StackTrace); 1849 stackTrace = dart.as(theStackTrace, core.StackTrace);
1850 } 1850 }
1851 } else if (remaining == 0 && !dart.notNull(eagerError)) { 1851 } else if (remaining == 0 && !dart.notNull(eagerError)) {
1852 result[_completeError](error, stackTrace); 1852 result[_completeError](error, stackTrace);
1853 } 1853 }
1854 }; 1854 };
1855 for (let future of futures) { 1855 for (let future of futures) {
1856 let pos = remaining; 1856 let pos = remaining;
1857 remaining = dart.notNull(pos) + 1; 1857 remaining = dart.notNull(pos) + 1;
1858 future.then(value => { 1858 future.then(value => {
1859 remaining = dart.notNull(remaining) - 1; 1859 remaining = dart.notNull(remaining) - 1;
1860 if (values != null) { 1860 if (values != null) {
1861 values[core.$set](pos, value); 1861 values[core.$set](pos, value);
1862 if (remaining == 0) { 1862 if (remaining == 0) {
1863 result[_completeWithValue](values); 1863 result[_completeWithValue](values);
1864 } 1864 }
1865 } else { 1865 } else {
1866 if (dart.notNull(cleanUp != null) && dart.notNull(value != null)) { 1866 if (dart.notNull(cleanUp != null) && dart.notNull(value != null)) {
1867 new Future.sync(() => { 1867 new (Future$()).sync(() => {
1868 dart.dcall(cleanUp, value); 1868 dart.dcall(cleanUp, value);
1869 }); 1869 });
1870 } 1870 }
1871 if (remaining == 0 && !dart.notNull(eagerError)) { 1871 if (remaining == 0 && !dart.notNull(eagerError)) {
1872 result[_completeError](error, stackTrace); 1872 result[_completeError](error, stackTrace);
1873 } 1873 }
1874 } 1874 }
1875 }, {onError: handleError}); 1875 }, {onError: handleError});
1876 } 1876 }
1877 if (remaining == 0) { 1877 if (remaining == 0) {
1878 return new (Future$(core.List)).value(dart.const([])); 1878 return new (Future$(core.List)).value(dart.const([]));
1879 } 1879 }
1880 values = new core.List(remaining); 1880 values = new core.List(remaining);
1881 return result; 1881 return result;
1882 } 1882 }
1883 static forEach(input, f) { 1883 static forEach(input, f) {
1884 dart.as(f, dart.functionType(dart.dynamic, [dart.dynamic])); 1884 dart.as(f, dart.functionType(dart.dynamic, [dart.dynamic]));
1885 let iterator = input[core.$iterator]; 1885 let iterator = input[core.$iterator];
1886 return Future.doWhile(() => { 1886 return Future.doWhile(() => {
1887 if (!dart.notNull(iterator.moveNext())) 1887 if (!dart.notNull(iterator.moveNext()))
1888 return false; 1888 return false;
1889 return new Future.sync(() => dart.dcall(f, iterator.current)).then(_ = > true); 1889 return new (Future$()).sync(() => dart.dcall(f, iterator.current)).the n(_ => true);
1890 }); 1890 });
1891 } 1891 }
1892 static doWhile(f) { 1892 static doWhile(f) {
1893 dart.as(f, dart.functionType(dart.dynamic, [])); 1893 dart.as(f, dart.functionType(dart.dynamic, []));
1894 let doneSignal = new _Future(); 1894 let doneSignal = new _Future();
1895 let nextIteration = null; 1895 let nextIteration = null;
1896 nextIteration = Zone.current.bindUnaryCallback(keepGoing => { 1896 nextIteration = Zone.current.bindUnaryCallback(keepGoing => {
1897 if (keepGoing) { 1897 if (keepGoing) {
1898 new Future.sync(f).then(dart.as(nextIteration, __CastType4), {onErro r: doneSignal[_completeError].bind(doneSignal)}); 1898 new (Future$()).sync(f).then(dart.as(nextIteration, __CastType4), {o nError: doneSignal[_completeError].bind(doneSignal)});
1899 } else { 1899 } else {
1900 doneSignal[_complete](null); 1900 doneSignal[_complete](null);
1901 } 1901 }
1902 }, {runGuarded: true}); 1902 }, {runGuarded: true});
1903 dart.dcall(nextIteration, true); 1903 dart.dcall(nextIteration, true);
1904 return doneSignal; 1904 return doneSignal;
1905 } 1905 }
1906 } 1906 }
1907 dart.defineNamedConstructor(Future, 'microtask'); 1907 dart.defineNamedConstructor(Future, 'microtask');
1908 dart.defineNamedConstructor(Future, 'sync'); 1908 dart.defineNamedConstructor(Future, 'sync');
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
2164 dart.assert(!dart.notNull(this[_isComplete])); 2164 dart.assert(!dart.notNull(this[_isComplete]));
2165 this[_state] = _Future._CHAINED; 2165 this[_state] = _Future._CHAINED;
2166 } else { 2166 } else {
2167 dart.assert(this[_isChained]); 2167 dart.assert(this[_isChained]);
2168 this[_state] = _Future._INCOMPLETE; 2168 this[_state] = _Future._INCOMPLETE;
2169 } 2169 }
2170 } 2170 }
2171 then(f, opts) { 2171 then(f, opts) {
2172 dart.as(f, dart.functionType(dart.dynamic, [T])); 2172 dart.as(f, dart.functionType(dart.dynamic, [T]));
2173 let onError = opts && 'onError' in opts ? opts.onError : null; 2173 let onError = opts && 'onError' in opts ? opts.onError : null;
2174 let result = new _Future(); 2174 let result = new (_Future$())();
2175 if (!dart.notNull(core.identical(result[_zone], _ROOT_ZONE))) { 2175 if (!dart.notNull(core.identical(result[_zone], _ROOT_ZONE))) {
2176 f = dart.as(result[_zone].registerUnaryCallback(f), __CastType6); 2176 f = dart.as(result[_zone].registerUnaryCallback(f), __CastType6);
2177 if (onError != null) { 2177 if (onError != null) {
2178 onError = _registerErrorHandler(onError, result[_zone]); 2178 onError = _registerErrorHandler(onError, result[_zone]);
2179 } 2179 }
2180 } 2180 }
2181 this[_addListener](new _FutureListener.then(result, f, onError)); 2181 this[_addListener](new _FutureListener.then(result, f, onError));
2182 return result; 2182 return result;
2183 } 2183 }
2184 catchError(onError, opts) { 2184 catchError(onError, opts) {
2185 let test = opts && 'test' in opts ? opts.test : null; 2185 let test = opts && 'test' in opts ? opts.test : null;
2186 dart.as(test, dart.functionType(core.bool, [dart.dynamic])); 2186 dart.as(test, dart.functionType(core.bool, [dart.dynamic]));
2187 let result = new _Future(); 2187 let result = new (_Future$())();
2188 if (!dart.notNull(core.identical(result[_zone], _ROOT_ZONE))) { 2188 if (!dart.notNull(core.identical(result[_zone], _ROOT_ZONE))) {
2189 onError = _registerErrorHandler(onError, result[_zone]); 2189 onError = _registerErrorHandler(onError, result[_zone]);
2190 if (test != null) 2190 if (test != null)
2191 test = dart.as(result[_zone].registerUnaryCallback(test), __CastType 8); 2191 test = dart.as(result[_zone].registerUnaryCallback(test), __CastType 8);
2192 } 2192 }
2193 this[_addListener](new _FutureListener.catchError(result, onError, test) ); 2193 this[_addListener](new _FutureListener.catchError(result, onError, test) );
2194 return result; 2194 return result;
2195 } 2195 }
2196 whenComplete(action) { 2196 whenComplete(action) {
2197 dart.as(action, dart.functionType(dart.dynamic, [])); 2197 dart.as(action, dart.functionType(dart.dynamic, []));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2251 while (current != null) { 2251 while (current != null) {
2252 let next = current[_nextListener]; 2252 let next = current[_nextListener];
2253 current[_nextListener] = prev; 2253 current[_nextListener] = prev;
2254 prev = current; 2254 prev = current;
2255 current = next; 2255 current = next;
2256 } 2256 }
2257 return prev; 2257 return prev;
2258 } 2258 }
2259 static _chainForeignFuture(source, target) { 2259 static _chainForeignFuture(source, target) {
2260 dart.assert(!dart.notNull(target[_isComplete])); 2260 dart.assert(!dart.notNull(target[_isComplete]));
2261 dart.assert(!dart.is(source, _Future)); 2261 dart.assert(!dart.is(source, _Future$()));
2262 target[_isChained] = true; 2262 target[_isChained] = true;
2263 source.then(value => { 2263 source.then(value => {
2264 dart.assert(target[_isChained]); 2264 dart.assert(target[_isChained]);
2265 target[_completeWithValue](value); 2265 target[_completeWithValue](value);
2266 }, { 2266 }, {
2267 onError: (error, stackTrace) => { 2267 onError: (error, stackTrace) => {
2268 if (stackTrace === void 0) 2268 if (stackTrace === void 0)
2269 stackTrace = null; 2269 stackTrace = null;
2270 dart.assert(target[_isChained]); 2270 dart.assert(target[_isChained]);
2271 target[_completeError](error, dart.as(stackTrace, core.StackTrace)); 2271 target[_completeError](error, dart.as(stackTrace, core.StackTrace));
2272 } 2272 }
2273 }); 2273 });
2274 } 2274 }
2275 static _chainCoreFuture(source, target) { 2275 static _chainCoreFuture(source, target) {
2276 dart.assert(!dart.notNull(target[_isComplete])); 2276 dart.assert(!dart.notNull(target[_isComplete]));
2277 dart.assert(dart.is(source, _Future)); 2277 dart.assert(dart.is(source, _Future$()));
2278 target[_isChained] = true; 2278 target[_isChained] = true;
2279 let listener = new _FutureListener.chain(target); 2279 let listener = new _FutureListener.chain(target);
2280 if (source[_isComplete]) { 2280 if (source[_isComplete]) {
2281 _Future._propagateToListeners(source, listener); 2281 _Future._propagateToListeners(source, listener);
2282 } else { 2282 } else {
2283 source[_addListener](listener); 2283 source[_addListener](listener);
2284 } 2284 }
2285 } 2285 }
2286 [_complete](value) { 2286 [_complete](value) {
2287 dart.assert(!dart.notNull(this[_isComplete])); 2287 dart.assert(!dart.notNull(this[_isComplete]));
2288 if (dart.is(value, Future)) { 2288 if (dart.is(value, Future)) {
2289 if (dart.is(value, _Future)) { 2289 if (dart.is(value, _Future$())) {
2290 _Future._chainCoreFuture(dart.as(value, _Future), this); 2290 _Future._chainCoreFuture(dart.as(value, _Future$()), this);
2291 } else { 2291 } else {
2292 _Future._chainForeignFuture(dart.as(value, Future), this); 2292 _Future._chainForeignFuture(dart.as(value, Future), this);
2293 } 2293 }
2294 } else { 2294 } else {
2295 let listeners = this[_removeListeners](); 2295 let listeners = this[_removeListeners]();
2296 this[_setValue](dart.as(value, T)); 2296 this[_setValue](dart.as(value, T));
2297 _Future._propagateToListeners(this, listeners); 2297 _Future._propagateToListeners(this, listeners);
2298 } 2298 }
2299 } 2299 }
2300 [_completeWithValue](value) { 2300 [_completeWithValue](value) {
2301 dart.assert(!dart.notNull(this[_isComplete])); 2301 dart.assert(!dart.notNull(this[_isComplete]));
2302 dart.assert(!dart.is(value, Future)); 2302 dart.assert(!dart.is(value, Future));
2303 let listeners = this[_removeListeners](); 2303 let listeners = this[_removeListeners]();
2304 this[_setValue](dart.as(value, T)); 2304 this[_setValue](dart.as(value, T));
2305 _Future._propagateToListeners(this, listeners); 2305 _Future._propagateToListeners(this, listeners);
2306 } 2306 }
2307 [_completeError](error, stackTrace) { 2307 [_completeError](error, stackTrace) {
2308 if (stackTrace === void 0) 2308 if (stackTrace === void 0)
2309 stackTrace = null; 2309 stackTrace = null;
2310 dart.assert(!dart.notNull(this[_isComplete])); 2310 dart.assert(!dart.notNull(this[_isComplete]));
2311 let listeners = this[_removeListeners](); 2311 let listeners = this[_removeListeners]();
2312 this[_setError](error, stackTrace); 2312 this[_setError](error, stackTrace);
2313 _Future._propagateToListeners(this, listeners); 2313 _Future._propagateToListeners(this, listeners);
2314 } 2314 }
2315 [_asyncComplete](value) { 2315 [_asyncComplete](value) {
2316 dart.assert(!dart.notNull(this[_isComplete])); 2316 dart.assert(!dart.notNull(this[_isComplete]));
2317 if (value == null) { 2317 if (value == null) {
2318 } else if (dart.is(value, Future)) { 2318 } else if (dart.is(value, Future)) {
2319 let typedFuture = dart.as(value, Future$(T)); 2319 let typedFuture = dart.as(value, Future$(T));
2320 if (dart.is(typedFuture, _Future)) { 2320 if (dart.is(typedFuture, _Future$())) {
2321 let coreFuture = dart.as(typedFuture, _Future$(T)); 2321 let coreFuture = dart.as(typedFuture, _Future$(T));
2322 if (dart.notNull(coreFuture[_isComplete]) && dart.notNull(coreFuture [_hasError])) { 2322 if (dart.notNull(coreFuture[_isComplete]) && dart.notNull(coreFuture [_hasError])) {
2323 this[_markPendingCompletion](); 2323 this[_markPendingCompletion]();
2324 this[_zone].scheduleMicrotask((() => { 2324 this[_zone].scheduleMicrotask((() => {
2325 _Future._chainCoreFuture(coreFuture, this); 2325 _Future._chainCoreFuture(coreFuture, this);
2326 }).bind(this)); 2326 }).bind(this));
2327 } else { 2327 } else {
2328 _Future._chainCoreFuture(coreFuture, this); 2328 _Future._chainCoreFuture(coreFuture, this);
2329 } 2329 }
2330 } else { 2330 } else {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2447 if (dart.is(completeResult, Future)) { 2447 if (dart.is(completeResult, Future)) {
2448 let result = listener.result; 2448 let result = listener.result;
2449 result[_isChained] = true; 2449 result[_isChained] = true;
2450 isPropagationAborted = true; 2450 isPropagationAborted = true;
2451 dart.dsend(completeResult, 'then', ignored => { 2451 dart.dsend(completeResult, 'then', ignored => {
2452 _Future._propagateToListeners(source, new _FutureListener.chai n(result)); 2452 _Future._propagateToListeners(source, new _FutureListener.chai n(result));
2453 }, { 2453 }, {
2454 onError: (error, stackTrace) => { 2454 onError: (error, stackTrace) => {
2455 if (stackTrace === void 0) 2455 if (stackTrace === void 0)
2456 stackTrace = null; 2456 stackTrace = null;
2457 if (!dart.is(completeResult, _Future)) { 2457 if (!dart.is(completeResult, _Future$())) {
2458 completeResult = new _Future(); 2458 completeResult = new (_Future$())();
2459 dart.dsend(completeResult, _setError, error, stackTrace); 2459 dart.dsend(completeResult, _setError, error, stackTrace);
2460 } 2460 }
2461 _Future._propagateToListeners(dart.as(completeResult, _Futur e), new _FutureListener.chain(result)); 2461 _Future._propagateToListeners(dart.as(completeResult, _Futur e$()), new _FutureListener.chain(result));
2462 } 2462 }
2463 }); 2463 });
2464 } 2464 }
2465 }; 2465 };
2466 if (!dart.notNull(hasError)) { 2466 if (!dart.notNull(hasError)) {
2467 if (listener.handlesValue) { 2467 if (listener.handlesValue) {
2468 listenerHasValue = handleValueCallback(); 2468 listenerHasValue = handleValueCallback();
2469 } 2469 }
2470 } else { 2470 } else {
2471 handleError(); 2471 handleError();
2472 } 2472 }
2473 if (listener.handlesComplete) { 2473 if (listener.handlesComplete) {
2474 handleWhenCompleteCallback(); 2474 handleWhenCompleteCallback();
2475 } 2475 }
2476 if (oldZone != null) 2476 if (oldZone != null)
2477 Zone._leave(oldZone); 2477 Zone._leave(oldZone);
2478 if (isPropagationAborted) 2478 if (isPropagationAborted)
2479 return; 2479 return;
2480 if (dart.notNull(listenerHasValue) && !dart.notNull(core.identical(s ourceValue, listenerValueOrError)) && dart.is(listenerValueOrError, Future)) { 2480 if (dart.notNull(listenerHasValue) && !dart.notNull(core.identical(s ourceValue, listenerValueOrError)) && dart.is(listenerValueOrError, Future)) {
2481 let chainSource = dart.as(listenerValueOrError, Future); 2481 let chainSource = dart.as(listenerValueOrError, Future);
2482 let result = listener.result; 2482 let result = listener.result;
2483 if (dart.is(chainSource, _Future)) { 2483 if (dart.is(chainSource, _Future$())) {
2484 if (chainSource[_isComplete]) { 2484 if (chainSource[_isComplete]) {
2485 result[_isChained] = true; 2485 result[_isChained] = true;
2486 source = chainSource; 2486 source = chainSource;
2487 listeners = new _FutureListener.chain(result); 2487 listeners = new _FutureListener.chain(result);
2488 continue; 2488 continue;
2489 } else { 2489 } else {
2490 _Future._chainCoreFuture(chainSource, result); 2490 _Future._chainCoreFuture(chainSource, result);
2491 } 2491 }
2492 } else { 2492 } else {
2493 _Future._chainForeignFuture(chainSource, result); 2493 _Future._chainForeignFuture(chainSource, result);
2494 } 2494 }
2495 return; 2495 return;
2496 } 2496 }
2497 } 2497 }
2498 let result = listener.result; 2498 let result = listener.result;
2499 listeners = result[_removeListeners](); 2499 listeners = result[_removeListeners]();
2500 if (listenerHasValue) { 2500 if (listenerHasValue) {
2501 result[_setValue](listenerValueOrError); 2501 result[_setValue](listenerValueOrError);
2502 } else { 2502 } else {
2503 let asyncError = dart.as(listenerValueOrError, AsyncError); 2503 let asyncError = dart.as(listenerValueOrError, AsyncError);
2504 result[_setErrorObject](asyncError); 2504 result[_setErrorObject](asyncError);
2505 } 2505 }
2506 source = result; 2506 source = result;
2507 } 2507 }
2508 } 2508 }
2509 timeout(timeLimit, opts) { 2509 timeout(timeLimit, opts) {
2510 let onTimeout = opts && 'onTimeout' in opts ? opts.onTimeout : null; 2510 let onTimeout = opts && 'onTimeout' in opts ? opts.onTimeout : null;
2511 dart.as(onTimeout, dart.functionType(dart.dynamic, [])); 2511 dart.as(onTimeout, dart.functionType(dart.dynamic, []));
2512 if (this[_isComplete]) 2512 if (this[_isComplete])
2513 return new _Future.immediate(this); 2513 return new (_Future$()).immediate(this);
2514 let result = new _Future(); 2514 let result = new (_Future$())();
2515 let timer = null; 2515 let timer = null;
2516 if (onTimeout == null) { 2516 if (onTimeout == null) {
2517 timer = new Timer(timeLimit, () => { 2517 timer = new Timer(timeLimit, () => {
2518 result[_completeError](new TimeoutException("Future not completed", timeLimit)); 2518 result[_completeError](new TimeoutException("Future not completed", timeLimit));
2519 }); 2519 });
2520 } else { 2520 } else {
2521 let zone = Zone.current; 2521 let zone = Zone.current;
2522 onTimeout = zone.registerCallback(onTimeout); 2522 onTimeout = zone.registerCallback(onTimeout);
2523 timer = new Timer(timeLimit, () => { 2523 timer = new Timer(timeLimit, () => {
2524 try { 2524 try {
(...skipping 2835 matching lines...) Expand 10 before | Expand all | Expand 10 after
5360 exports.ScheduleMicrotaskHandler = ScheduleMicrotaskHandler; 5360 exports.ScheduleMicrotaskHandler = ScheduleMicrotaskHandler;
5361 exports.CreateTimerHandler = CreateTimerHandler; 5361 exports.CreateTimerHandler = CreateTimerHandler;
5362 exports.CreatePeriodicTimerHandler = CreatePeriodicTimerHandler; 5362 exports.CreatePeriodicTimerHandler = CreatePeriodicTimerHandler;
5363 exports.PrintHandler = PrintHandler; 5363 exports.PrintHandler = PrintHandler;
5364 exports.ForkHandler = ForkHandler; 5364 exports.ForkHandler = ForkHandler;
5365 exports.ZoneSpecification = ZoneSpecification; 5365 exports.ZoneSpecification = ZoneSpecification;
5366 exports.ZoneDelegate = ZoneDelegate; 5366 exports.ZoneDelegate = ZoneDelegate;
5367 exports.Zone = Zone; 5367 exports.Zone = Zone;
5368 exports.runZoned = runZoned; 5368 exports.runZoned = runZoned;
5369 })(async, core, _internal, _js_helper, _isolate_helper, collection); 5369 })(async, core, _internal, _js_helper, _isolate_helper, collection);
OLDNEW
« no previous file with comments | « lib/runtime/dart/_internal.js ('k') | lib/runtime/dart/core.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698