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

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

Issue 1233553005: Fixes #254 - Better stacktrace support (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: format fix Created 5 years, 5 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/_js_helper.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 dart_library.library('dart/_isolate_helper', null, /* Imports */[ 1 dart_library.library('dart/_isolate_helper', null, /* Imports */[
2 "dart_runtime/dart", 2 "dart_runtime/dart",
3 'dart/core', 3 'dart/core',
4 'dart/_interceptors', 4 'dart/_interceptors',
5 'dart/_js_helper', 5 'dart/_js_helper',
6 'dart/isolate', 6 'dart/isolate',
7 'dart/_foreign_helper', 7 'dart/_foreign_helper',
8 'dart/collection', 8 'dart/collection',
9 'dart/async' 9 'dart/async'
10 ], /* Lazy imports */[ 10 ], /* Lazy imports */[
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 return this.serializeWorkerSendPort(dart.as(x, _WorkerSendPort)); 68 return this.serializeWorkerSendPort(dart.as(x, _WorkerSendPort));
69 if (dart.is(x, core.Function)) 69 if (dart.is(x, core.Function))
70 return this.serializeClosure(dart.as(x, core.Function)); 70 return this.serializeClosure(dart.as(x, core.Function));
71 return this.serializeDartObject(x); 71 return this.serializeDartObject(x);
72 } 72 }
73 unsupported(x, message) { 73 unsupported(x, message) {
74 if (message === void 0) 74 if (message === void 0)
75 message = null; 75 message = null;
76 if (message == null) 76 if (message == null)
77 message = "Can't transmit:"; 77 message = "Can't transmit:";
78 throw new core.UnsupportedError(`${message} ${x}`); 78 dart.throw(new core.UnsupportedError(`${message} ${x}`));
79 } 79 }
80 makeRef(serializationId) { 80 makeRef(serializationId) {
81 return ["ref", serializationId]; 81 return ["ref", serializationId];
82 } 82 }
83 isPrimitive(x) { 83 isPrimitive(x) {
84 return x == null || typeof x == 'string' || dart.is(x, core.num) || typeof x == 'boolean'; 84 return x == null || typeof x == 'string' || dart.is(x, core.num) || typeof x == 'boolean';
85 } 85 }
86 serializePrimitive(primitive) { 86 serializePrimitive(primitive) {
87 return primitive; 87 return primitive;
88 } 88 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 class _Deserializer extends core.Object { 193 class _Deserializer extends core.Object {
194 _Deserializer(opts) { 194 _Deserializer(opts) {
195 let adjustSendPorts = opts && 'adjustSendPorts' in opts ? opts.adjustSendP orts : true; 195 let adjustSendPorts = opts && 'adjustSendPorts' in opts ? opts.adjustSendP orts : true;
196 this.deserializedObjects = core.List.new(); 196 this.deserializedObjects = core.List.new();
197 this[_adjustSendPorts] = dart.as(adjustSendPorts, core.bool); 197 this[_adjustSendPorts] = dart.as(adjustSendPorts, core.bool);
198 } 198 }
199 deserialize(x) { 199 deserialize(x) {
200 if (dart.notNull(this.isPrimitive(x))) 200 if (dart.notNull(this.isPrimitive(x)))
201 return this.deserializePrimitive(x); 201 return this.deserializePrimitive(x);
202 if (!dart.is(x, _interceptors.JSArray)) 202 if (!dart.is(x, _interceptors.JSArray))
203 throw new core.ArgumentError(`Bad serialized message: ${x}`); 203 dart.throw(new core.ArgumentError(`Bad serialized message: ${x}`));
204 switch (dart.dload(x, 'first')) { 204 switch (dart.dload(x, 'first')) {
205 case "ref": 205 case "ref":
206 { 206 {
207 return this.deserializeRef(x); 207 return this.deserializeRef(x);
208 } 208 }
209 case "buffer": 209 case "buffer":
210 { 210 {
211 return this.deserializeByteBuffer(x); 211 return this.deserializeByteBuffer(x);
212 } 212 }
213 case "typed": 213 case "typed":
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 case "function": 249 case "function":
250 { 250 {
251 return this.deserializeClosure(x); 251 return this.deserializeClosure(x);
252 } 252 }
253 case "dart": 253 case "dart":
254 { 254 {
255 return this.deserializeDartObject(x); 255 return this.deserializeDartObject(x);
256 } 256 }
257 default: 257 default:
258 { 258 {
259 throw `couldn't deserialize: ${x}`; 259 dart.throw(`couldn't deserialize: ${x}`);
260 } 260 }
261 } 261 }
262 } 262 }
263 isPrimitive(x) { 263 isPrimitive(x) {
264 return x == null || typeof x == 'string' || dart.is(x, core.num) || typeof x == 'boolean'; 264 return x == null || typeof x == 'string' || dart.is(x, core.num) || typeof x == 'boolean';
265 } 265 }
266 deserializePrimitive(x) { 266 deserializePrimitive(x) {
267 return x; 267 return x;
268 } 268 }
269 deserializeRef(x) { 269 deserializeRef(x) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 dart.fn(isWorker, core.bool, []); 428 dart.fn(isWorker, core.bool, []);
429 function _currentIsolate() { 429 function _currentIsolate() {
430 return exports._globalState.currentContext; 430 return exports._globalState.currentContext;
431 } 431 }
432 dart.fn(_currentIsolate, () => dart.definiteFunctionType(_IsolateContext, [])) ; 432 dart.fn(_currentIsolate, () => dart.definiteFunctionType(_IsolateContext, [])) ;
433 function startRootIsolate(entry, args) { 433 function startRootIsolate(entry, args) {
434 args = args; 434 args = args;
435 if (args == null) 435 if (args == null)
436 args = []; 436 args = [];
437 if (!dart.is(args, core.List)) { 437 if (!dart.is(args, core.List)) {
438 throw new core.ArgumentError(`Arguments to main must be a List: ${args}`); 438 dart.throw(new core.ArgumentError(`Arguments to main must be a List: ${arg s}`));
439 } 439 }
440 exports._globalState = new _Manager(dart.as(entry, core.Function)); 440 exports._globalState = new _Manager(dart.as(entry, core.Function));
441 if (dart.notNull(exports._globalState.isWorker)) 441 if (dart.notNull(exports._globalState.isWorker))
442 return; 442 return;
443 let rootContext = new _IsolateContext(); 443 let rootContext = new _IsolateContext();
444 exports._globalState.rootContext = rootContext; 444 exports._globalState.rootContext = rootContext;
445 exports._globalState.currentContext = rootContext; 445 exports._globalState.currentContext = rootContext;
446 if (dart.is(entry, _MainFunctionArgs)) { 446 if (dart.is(entry, _MainFunctionArgs)) {
447 rootContext.eval(dart.fn(() => { 447 rootContext.eval(dart.fn(() => {
448 dart.dcall(entry, args); 448 dart.dcall(entry, args);
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 break; 750 break;
751 } 751 }
752 default: 752 default:
753 } 753 }
754 } 754 }
755 lookup(portId) { 755 lookup(portId) {
756 return this.ports.get(portId); 756 return this.ports.get(portId);
757 } 757 }
758 [_addRegistration](portId, port) { 758 [_addRegistration](portId, port) {
759 if (dart.notNull(this.ports.containsKey(portId))) { 759 if (dart.notNull(this.ports.containsKey(portId))) {
760 throw core.Exception.new("Registry: ports must be registered only once." ); 760 dart.throw(core.Exception.new("Registry: ports must be registered only o nce."));
761 } 761 }
762 this.ports.set(portId, port); 762 this.ports.set(portId, port);
763 } 763 }
764 register(portId, port) { 764 register(portId, port) {
765 this[_addRegistration](portId, port); 765 this[_addRegistration](portId, port);
766 this[_updateGlobalState](); 766 this[_updateGlobalState]();
767 } 767 }
768 registerWeak(portId, port) { 768 registerWeak(portId, port) {
769 this.weakPorts.add(portId); 769 this.weakPorts.add(portId);
770 this[_addRegistration](portId, port); 770 this[_addRegistration](portId, port);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 prequeue(event) { 838 prequeue(event) {
839 this.events.addFirst(event); 839 this.events.addFirst(event);
840 } 840 }
841 dequeue() { 841 dequeue() {
842 if (dart.notNull(this.events.isEmpty)) 842 if (dart.notNull(this.events.isEmpty))
843 return null; 843 return null;
844 return this.events.removeFirst(); 844 return this.events.removeFirst();
845 } 845 }
846 checkOpenReceivePortsFromCommandLine() { 846 checkOpenReceivePortsFromCommandLine() {
847 if (exports._globalState.rootContext != null && dart.notNull(exports._glob alState.isolates.containsKey(exports._globalState.rootContext.id)) && dart.notNu ll(exports._globalState.fromCommandLine) && dart.notNull(exports._globalState.ro otContext.ports.isEmpty)) { 847 if (exports._globalState.rootContext != null && dart.notNull(exports._glob alState.isolates.containsKey(exports._globalState.rootContext.id)) && dart.notNu ll(exports._globalState.fromCommandLine) && dart.notNull(exports._globalState.ro otContext.ports.isEmpty)) {
848 throw core.Exception.new("Program exited with open ReceivePorts."); 848 dart.throw(core.Exception.new("Program exited with open ReceivePorts.")) ;
849 } 849 }
850 } 850 }
851 runIteration() { 851 runIteration() {
852 let event = this.dequeue(); 852 let event = this.dequeue();
853 if (event == null) { 853 if (event == null) {
854 this.checkOpenReceivePortsFromCommandLine(); 854 this.checkOpenReceivePortsFromCommandLine();
855 exports._globalState.maybeCloseWorker(); 855 exports._globalState.maybeCloseWorker();
856 return false; 856 return false;
857 } 857 }
858 event.process(); 858 event.process();
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 if (stack == null) { 965 if (stack == null) {
966 stack = (function() { 966 stack = (function() {
967 try { 967 try {
968 throw new Error(); 968 throw new Error();
969 } catch (e) { 969 } catch (e) {
970 return e.stack; 970 return e.stack;
971 } 971 }
972 972
973 })(); 973 })();
974 if (stack == null) 974 if (stack == null)
975 throw new core.UnsupportedError('No stack trace'); 975 dart.throw(new core.UnsupportedError('No stack trace'));
976 } 976 }
977 let pattern = null, matches = null; 977 let pattern = null, matches = null;
978 pattern = new RegExp("^ *at [^(]*\\((.*):[0-9]*:[0-9]*\\)$", "m"); 978 pattern = new RegExp("^ *at [^(]*\\((.*):[0-9]*:[0-9]*\\)$", "m");
979 matches = stack.match(pattern); 979 matches = stack.match(pattern);
980 if (matches != null) 980 if (matches != null)
981 return matches[1]; 981 return matches[1];
982 pattern = new RegExp("^[^@]*@(.*):[0-9]*$", "m"); 982 pattern = new RegExp("^[^@]*@(.*):[0-9]*$", "m");
983 matches = stack.match(pattern); 983 matches = stack.match(pattern);
984 if (matches != null) 984 if (matches != null)
985 return matches[1]; 985 return matches[1];
986 throw new core.UnsupportedError(`Cannot extract URI from "${stack}"`); 986 dart.throw(new core.UnsupportedError(`Cannot extract URI from "${stack}"`) );
987 } 987 }
988 static _getEventData(e) { 988 static _getEventData(e) {
989 return e.data; 989 return e.data;
990 } 990 }
991 static _processWorkerMessage(sender, e) { 991 static _processWorkerMessage(sender, e) {
992 let msg = _deserializeMessage(IsolateNatives._getEventData(e)); 992 let msg = _deserializeMessage(IsolateNatives._getEventData(e));
993 switch (dart.dindex(msg, 'command')) { 993 switch (dart.dindex(msg, 'command')) {
994 case 'start': 994 case 'start':
995 { 995 {
996 exports._globalState.currentManagerId = dart.as(dart.dindex(msg, 'id') , core.int); 996 exports._globalState.currentManagerId = dart.as(dart.dindex(msg, 'id') , core.int);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 { 1040 {
1041 if (dart.notNull(exports._globalState.isWorker)) { 1041 if (dart.notNull(exports._globalState.isWorker)) {
1042 exports._globalState.mainManager.postMessage(_serializeMessage(dart. map({command: 'print', msg: msg}))); 1042 exports._globalState.mainManager.postMessage(_serializeMessage(dart. map({command: 'print', msg: msg})));
1043 } else { 1043 } else {
1044 core.print(dart.dindex(msg, 'msg')); 1044 core.print(dart.dindex(msg, 'msg'));
1045 } 1045 }
1046 break; 1046 break;
1047 } 1047 }
1048 case 'error': 1048 case 'error':
1049 { 1049 {
1050 throw dart.dindex(msg, 'msg'); 1050 dart.throw(dart.dindex(msg, 'msg'));
1051 } 1051 }
1052 } 1052 }
1053 } 1053 }
1054 static handleSpawnWorkerRequest(msg) { 1054 static handleSpawnWorkerRequest(msg) {
1055 let replyPort = dart.dindex(msg, 'replyPort'); 1055 let replyPort = dart.dindex(msg, 'replyPort');
1056 IsolateNatives.spawn(dart.as(dart.dindex(msg, 'functionName'), core.String ), dart.as(dart.dindex(msg, 'uri'), core.String), dart.as(dart.dindex(msg, 'args '), core.List$(core.String)), dart.dindex(msg, 'msg'), false, dart.as(dart.dinde x(msg, 'isSpawnUri'), core.bool), dart.as(dart.dindex(msg, 'startPaused'), core. bool)).then(dart.fn(msg => { 1056 IsolateNatives.spawn(dart.as(dart.dindex(msg, 'functionName'), core.String ), dart.as(dart.dindex(msg, 'uri'), core.String), dart.as(dart.dindex(msg, 'args '), core.List$(core.String)), dart.dindex(msg, 'msg'), false, dart.as(dart.dinde x(msg, 'isSpawnUri'), core.bool), dart.as(dart.dindex(msg, 'startPaused'), core. bool)).then(dart.fn(msg => {
1057 dart.dsend(replyPort, 'send', msg); 1057 dart.dsend(replyPort, 'send', msg);
1058 }), {onError: dart.fn(errorMessage => { 1058 }), {onError: dart.fn(errorMessage => {
1059 dart.dsend(replyPort, 'send', [_SPAWN_FAILED_SIGNAL, errorMessage]); 1059 dart.dsend(replyPort, 'send', [_SPAWN_FAILED_SIGNAL, errorMessage]);
1060 }, dart.dynamic, [core.String])}); 1060 }, dart.dynamic, [core.String])});
1061 } 1061 }
1062 static _log(msg) { 1062 static _log(msg) {
1063 if (dart.notNull(exports._globalState.isWorker)) { 1063 if (dart.notNull(exports._globalState.isWorker)) {
1064 exports._globalState.mainManager.postMessage(_serializeMessage(dart.map( {command: 'log', msg: msg}))); 1064 exports._globalState.mainManager.postMessage(_serializeMessage(dart.map( {command: 'log', msg: msg})));
1065 } else { 1065 } else {
1066 try { 1066 try {
1067 IsolateNatives._consoleLog(msg); 1067 IsolateNatives._consoleLog(msg);
1068 } catch (e) { 1068 } catch (e) {
1069 let trace = dart.stackTrace(e); 1069 let trace = dart.stackTrace(e);
1070 throw core.Exception.new(trace); 1070 dart.throw(core.Exception.new(trace));
1071 } 1071 }
1072 1072
1073 } 1073 }
1074 } 1074 }
1075 static _consoleLog(msg) { 1075 static _consoleLog(msg) {
1076 self.console.log(msg); 1076 self.console.log(msg);
1077 } 1077 }
1078 static _getJSFunctionFromName(functionName) { 1078 static _getJSFunctionFromName(functionName) {
1079 let globalFunctionsContainer = _foreign_helper.JS_EMBEDDED_GLOBAL("", _js_ embedded_names.GLOBAL_FUNCTIONS); 1079 let globalFunctionsContainer = _foreign_helper.JS_EMBEDDED_GLOBAL("", _js_ embedded_names.GLOBAL_FUNCTIONS);
1080 return globalFunctionsContainer[functionName](); 1080 return globalFunctionsContainer[functionName]();
1081 } 1081 }
1082 static _getJSFunctionName(f) { 1082 static _getJSFunctionName(f) {
1083 return dart.as(f.$name, core.String); 1083 return dart.as(f.$name, core.String);
1084 } 1084 }
1085 static _allocate(ctor) { 1085 static _allocate(ctor) {
1086 return new ctor(); 1086 return new ctor();
1087 } 1087 }
1088 static spawnFunction(topLevelFunction, message, startPaused) { 1088 static spawnFunction(topLevelFunction, message, startPaused) {
1089 IsolateNatives.enableSpawnWorker = true; 1089 IsolateNatives.enableSpawnWorker = true;
1090 let name = IsolateNatives._getJSFunctionName(topLevelFunction); 1090 let name = IsolateNatives._getJSFunctionName(topLevelFunction);
1091 if (name == null) { 1091 if (name == null) {
1092 throw new core.UnsupportedError("only top-level functions can be spawned ."); 1092 dart.throw(new core.UnsupportedError("only top-level functions can be sp awned."));
1093 } 1093 }
1094 let isLight = false; 1094 let isLight = false;
1095 let isSpawnUri = false; 1095 let isSpawnUri = false;
1096 return IsolateNatives.spawn(name, null, null, message, isLight, isSpawnUri , startPaused); 1096 return IsolateNatives.spawn(name, null, null, message, isLight, isSpawnUri , startPaused);
1097 } 1097 }
1098 static spawnUri(uri, args, message, startPaused) { 1098 static spawnUri(uri, args, message, startPaused) {
1099 IsolateNatives.enableSpawnWorker = true; 1099 IsolateNatives.enableSpawnWorker = true;
1100 let isLight = false; 1100 let isLight = false;
1101 let isSpawnUri = true; 1101 let isSpawnUri = true;
1102 return IsolateNatives.spawn(null, dart.toString(uri), args, message, isLig ht, isSpawnUri, startPaused); 1102 return IsolateNatives.spawn(null, dart.toString(uri), args, message, isLig ht, isSpawnUri, startPaused);
(...skipping 24 matching lines...) Expand all
1127 if (args != null) 1127 if (args != null)
1128 args = core.List$(core.String).from(args); 1128 args = core.List$(core.String).from(args);
1129 if (dart.notNull(exports._globalState.isWorker)) { 1129 if (dart.notNull(exports._globalState.isWorker)) {
1130 exports._globalState.mainManager.postMessage(_serializeMessage(dart.map( {command: 'spawn-worker', functionName: functionName, args: args, msg: message, uri: uri, isSpawnUri: isSpawnUri, startPaused: startPaused, replyPort: replyPort }))); 1130 exports._globalState.mainManager.postMessage(_serializeMessage(dart.map( {command: 'spawn-worker', functionName: functionName, args: args, msg: message, uri: uri, isSpawnUri: isSpawnUri, startPaused: startPaused, replyPort: replyPort })));
1131 } else { 1131 } else {
1132 IsolateNatives._spawnWorker(functionName, uri, args, message, isSpawnUri , startPaused, replyPort, onError); 1132 IsolateNatives._spawnWorker(functionName, uri, args, message, isSpawnUri , startPaused, replyPort, onError);
1133 } 1133 }
1134 } 1134 }
1135 static _startNonWorker(functionName, uri, args, message, isSpawnUri, startPa used, replyPort) { 1135 static _startNonWorker(functionName, uri, args, message, isSpawnUri, startPa used, replyPort) {
1136 if (uri != null) { 1136 if (uri != null) {
1137 throw new core.UnsupportedError("Currently spawnUri is not supported wit hout web workers."); 1137 dart.throw(new core.UnsupportedError("Currently spawnUri is not supporte d without web workers."));
1138 } 1138 }
1139 message = _clone(message); 1139 message = _clone(message);
1140 if (args != null) 1140 if (args != null)
1141 args = core.List$(core.String).from(args); 1141 args = core.List$(core.String).from(args);
1142 exports._globalState.topEventLoop.enqueue(new _IsolateContext(), dart.fn(( ) => { 1142 exports._globalState.topEventLoop.enqueue(new _IsolateContext(), dart.fn(( ) => {
1143 let func = IsolateNatives._getJSFunctionFromName(functionName); 1143 let func = IsolateNatives._getJSFunctionFromName(functionName);
1144 IsolateNatives._startIsolate(dart.as(func, core.Function), args, message , isSpawnUri, startPaused, replyPort); 1144 IsolateNatives._startIsolate(dart.as(func, core.Function), args, message , isSpawnUri, startPaused, replyPort);
1145 }), 'nonworker start'); 1145 }), 'nonworker start');
1146 } 1146 }
1147 static get currentIsolate() { 1147 static get currentIsolate() {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 return new (core.Expando$(core.int))(); 1243 return new (core.Expando$(core.int))();
1244 } 1244 }
1245 }); 1245 });
1246 let _checkReplyTo = Symbol('_checkReplyTo'); 1246 let _checkReplyTo = Symbol('_checkReplyTo');
1247 class _BaseSendPort extends core.Object { 1247 class _BaseSendPort extends core.Object {
1248 _BaseSendPort(isolateId) { 1248 _BaseSendPort(isolateId) {
1249 this[_isolateId] = isolateId; 1249 this[_isolateId] = isolateId;
1250 } 1250 }
1251 [_checkReplyTo](replyTo) { 1251 [_checkReplyTo](replyTo) {
1252 if (replyTo != null && !dart.is(replyTo, _NativeJsSendPort) && !dart.is(re plyTo, _WorkerSendPort)) { 1252 if (replyTo != null && !dart.is(replyTo, _NativeJsSendPort) && !dart.is(re plyTo, _WorkerSendPort)) {
1253 throw core.Exception.new("SendPort.send: Illegal replyTo port type"); 1253 dart.throw(core.Exception.new("SendPort.send: Illegal replyTo port type" ));
1254 } 1254 }
1255 } 1255 }
1256 } 1256 }
1257 _BaseSendPort[dart.implements] = () => [isolate.SendPort]; 1257 _BaseSendPort[dart.implements] = () => [isolate.SendPort];
1258 dart.setSignature(_BaseSendPort, { 1258 dart.setSignature(_BaseSendPort, {
1259 constructors: () => ({_BaseSendPort: [_BaseSendPort, [core.int]]}), 1259 constructors: () => ({_BaseSendPort: [_BaseSendPort, [core.int]]}),
1260 methods: () => ({[_checkReplyTo]: [dart.void, [isolate.SendPort]]}) 1260 methods: () => ({[_checkReplyTo]: [dart.void, [isolate.SendPort]]})
1261 }); 1261 });
1262 let _isClosed = Symbol('_isClosed'); 1262 let _isClosed = Symbol('_isClosed');
1263 let _add = Symbol('_add'); 1263 let _add = Symbol('_add');
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 let internalCallback = (function() { 1455 let internalCallback = (function() {
1456 this[_handle] = null; 1456 this[_handle] = null;
1457 leaveJsAsync(); 1457 leaveJsAsync();
1458 callback(); 1458 callback();
1459 }).bind(this); 1459 }).bind(this);
1460 dart.fn(internalCallback, dart.void, []); 1460 dart.fn(internalCallback, dart.void, []);
1461 enterJsAsync(); 1461 enterJsAsync();
1462 this[_handle] = self.setTimeout(internalCallback, milliseconds); 1462 this[_handle] = self.setTimeout(internalCallback, milliseconds);
1463 } else { 1463 } else {
1464 dart.assert(dart.notNull(milliseconds) > 0); 1464 dart.assert(dart.notNull(milliseconds) > 0);
1465 throw new core.UnsupportedError("Timer greater than 0."); 1465 dart.throw(new core.UnsupportedError("Timer greater than 0."));
1466 } 1466 }
1467 } 1467 }
1468 periodic(milliseconds, callback) { 1468 periodic(milliseconds, callback) {
1469 this[_once] = false; 1469 this[_once] = false;
1470 this[_inEventLoop] = false; 1470 this[_inEventLoop] = false;
1471 this[_handle] = null; 1471 this[_handle] = null;
1472 if (dart.notNull(hasTimer())) { 1472 if (dart.notNull(hasTimer())) {
1473 enterJsAsync(); 1473 enterJsAsync();
1474 this[_handle] = self.setInterval(dart.fn(() => { 1474 this[_handle] = self.setInterval(dart.fn(() => {
1475 callback(this); 1475 callback(this);
1476 }), milliseconds); 1476 }), milliseconds);
1477 } else { 1477 } else {
1478 throw new core.UnsupportedError("Periodic timer."); 1478 dart.throw(new core.UnsupportedError("Periodic timer."));
1479 } 1479 }
1480 } 1480 }
1481 cancel() { 1481 cancel() {
1482 if (dart.notNull(hasTimer())) { 1482 if (dart.notNull(hasTimer())) {
1483 if (dart.notNull(this[_inEventLoop])) { 1483 if (dart.notNull(this[_inEventLoop])) {
1484 throw new core.UnsupportedError("Timer in event loop cannot be cancele d."); 1484 dart.throw(new core.UnsupportedError("Timer in event loop cannot be ca nceled."));
1485 } 1485 }
1486 if (this[_handle] == null) 1486 if (this[_handle] == null)
1487 return; 1487 return;
1488 leaveJsAsync(); 1488 leaveJsAsync();
1489 if (dart.notNull(this[_once])) { 1489 if (dart.notNull(this[_once])) {
1490 self.clearTimeout(this[_handle]); 1490 self.clearTimeout(this[_handle]);
1491 } else { 1491 } else {
1492 self.clearInterval(this[_handle]); 1492 self.clearInterval(this[_handle]);
1493 } 1493 }
1494 this[_handle] = null; 1494 this[_handle] = null;
1495 } else { 1495 } else {
1496 throw new core.UnsupportedError("Canceling a timer."); 1496 dart.throw(new core.UnsupportedError("Canceling a timer."));
1497 } 1497 }
1498 } 1498 }
1499 get isActive() { 1499 get isActive() {
1500 return this[_handle] != null; 1500 return this[_handle] != null;
1501 } 1501 }
1502 } 1502 }
1503 TimerImpl[dart.implements] = () => [async.Timer]; 1503 TimerImpl[dart.implements] = () => [async.Timer];
1504 dart.defineNamedConstructor(TimerImpl, 'periodic'); 1504 dart.defineNamedConstructor(TimerImpl, 'periodic');
1505 dart.setSignature(TimerImpl, { 1505 dart.setSignature(TimerImpl, {
1506 constructors: () => ({ 1506 constructors: () => ({
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 exports.leaveJsAsync = leaveJsAsync; 1554 exports.leaveJsAsync = leaveJsAsync;
1555 exports.isWorker = isWorker; 1555 exports.isWorker = isWorker;
1556 exports.startRootIsolate = startRootIsolate; 1556 exports.startRootIsolate = startRootIsolate;
1557 exports.IsolateNatives = IsolateNatives; 1557 exports.IsolateNatives = IsolateNatives;
1558 exports.RawReceivePortImpl = RawReceivePortImpl; 1558 exports.RawReceivePortImpl = RawReceivePortImpl;
1559 exports.ReceivePortImpl = ReceivePortImpl; 1559 exports.ReceivePortImpl = ReceivePortImpl;
1560 exports.TimerImpl = TimerImpl; 1560 exports.TimerImpl = TimerImpl;
1561 exports.hasTimer = hasTimer; 1561 exports.hasTimer = hasTimer;
1562 exports.CapabilityImpl = CapabilityImpl; 1562 exports.CapabilityImpl = CapabilityImpl;
1563 }); 1563 });
OLDNEW
« no previous file with comments | « lib/runtime/dart/_internal.js ('k') | lib/runtime/dart/_js_helper.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698