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

Side by Side Diff: tools/dom/src/native_DOMImplementation.dart

Issue 23868034: Remove spawnDomFunction from dart:html (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 | « tests/html/js_interop_4_test.dart ('k') | tools/dom/src/native_DOMPublic.dart » ('j') | 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 part of html; 5 part of html;
6 6
7 class _ConsoleVariables { 7 class _ConsoleVariables {
8 Map<String, Object> _data = new Map<String, Object>(); 8 Map<String, Object> _data = new Map<String, Object>();
9 9
10 /** 10 /**
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 static Map createMap() => {}; 88 static Map createMap() => {};
89 89
90 static makeUnimplementedError(String fileName, int lineNo) { 90 static makeUnimplementedError(String fileName, int lineNo) {
91 return new UnsupportedError('[info: $fileName:$lineNo]'); 91 return new UnsupportedError('[info: $fileName:$lineNo]');
92 } 92 }
93 93
94 static window() native "Utils_window"; 94 static window() native "Utils_window";
95 static forwardingPrint(String message) native "Utils_forwardingPrint"; 95 static forwardingPrint(String message) native "Utils_forwardingPrint";
96 static void spawnDomFunction(Function f, int replyTo) native "Utils_spawnDomFu nction"; 96 static void spawnDomFunction(Function f, int replyTo) native "Utils_spawnDomFu nction";
97 static void spawnDomUri(String uri, int replyTo) native "Utils_spawnDomUri";
98 static int _getNewIsolateId() native "Utils_getNewIsolateId"; 97 static int _getNewIsolateId() native "Utils_getNewIsolateId";
99 98
100 // The following methods were added for debugger integration to make working 99 // The following methods were added for debugger integration to make working
101 // with the Dart C mirrors API simpler. 100 // with the Dart C mirrors API simpler.
102 // TODO(jacobr): consider moving them to a separate library. 101 // TODO(jacobr): consider moving them to a separate library.
103 // If Dart supported dynamic code injection, we would only inject this code 102 // If Dart supported dynamic code injection, we would only inject this code
104 // when the debugger is invoked. 103 // when the debugger is invoked.
105 104
106 /** 105 /**
107 * Strips the private secret prefix from member names of the form 106 * Strips the private secret prefix from member names of the form
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 String remove(String key) native "DOMStringMap_remove_Callback"; 358 String remove(String key) native "DOMStringMap_remove_Callback";
360 void clear() => Maps.clear(this); 359 void clear() => Maps.clear(this);
361 void forEach(void f(String key, String value)) => Maps.forEach(this, f); 360 void forEach(void f(String key, String value)) => Maps.forEach(this, f);
362 Iterable<String> get keys native "DOMStringMap_getKeys_Callback"; 361 Iterable<String> get keys native "DOMStringMap_getKeys_Callback";
363 Iterable<String> get values => Maps.getValues(this); 362 Iterable<String> get values => Maps.getValues(this);
364 int get length => Maps.length(this); 363 int get length => Maps.length(this);
365 bool get isEmpty => Maps.isEmpty(this); 364 bool get isEmpty => Maps.isEmpty(this);
366 bool get isNotEmpty => Maps.isNotEmpty(this); 365 bool get isNotEmpty => Maps.isNotEmpty(this);
367 } 366 }
368 367
368 // TODO(vsm): Remove DOM isolate code. This is only used to support
369 // printing and timers in background isolates. Background isolates
370 // should just forward to the main DOM isolate instead of requiring a
371 // special DOM isolate.
372
373 _makeSendPortFuture(spawnRequest) {
374 final completer = new Completer<SendPort>.sync();
375 final port = new ReceivePort();
376 port.receive((result, _) {
377 completer.complete(result);
378 port.close();
379 });
380 // TODO: SendPort.hashCode is ugly way to access port id.
381 spawnRequest(port.toSendPort().hashCode);
382 return completer.future;
383 }
384
385 Future<SendPort> _spawnDomFunction(Function f) =>
386 _makeSendPortFuture((portId) { _Utils.spawnDomFunction(f, portId); });
387
369 final Future<SendPort> __HELPER_ISOLATE_PORT = 388 final Future<SendPort> __HELPER_ISOLATE_PORT =
370 spawnDomFunction(_helperIsolateMain); 389 _spawnDomFunction(_helperIsolateMain);
371 390
372 // Tricky part. 391 // Tricky part.
373 // Once __HELPER_ISOLATE_PORT gets resolved, it will still delay in .then 392 // Once __HELPER_ISOLATE_PORT gets resolved, it will still delay in .then
374 // and to delay Timer.run is used. However, Timer.run will try to register 393 // and to delay Timer.run is used. However, Timer.run will try to register
375 // another Timer and here we got stuck: event cannot be posted as then 394 // another Timer and here we got stuck: event cannot be posted as then
376 // callback is not executed because it's delayed with timer. 395 // callback is not executed because it's delayed with timer.
377 // Therefore once future is resolved, it's unsafe to call .then on it 396 // Therefore once future is resolved, it's unsafe to call .then on it
378 // in Timer code. 397 // in Timer code.
379 SendPort __SEND_PORT; 398 SendPort __SEND_PORT;
380 399
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 _send(msg) { 509 _send(msg) {
491 _sendToHelperIsolate(msg, _sendPort); 510 _sendToHelperIsolate(msg, _sendPort);
492 } 511 }
493 512
494 bool get isActive => _isActive; 513 bool get isActive => _isActive;
495 } 514 }
496 515
497 get _pureIsolateTimerFactoryClosure => 516 get _pureIsolateTimerFactoryClosure =>
498 ((int milliSeconds, void callback(Timer time), bool repeating) => 517 ((int milliSeconds, void callback(Timer time), bool repeating) =>
499 new _PureIsolateTimer(milliSeconds, callback, repeating)); 518 new _PureIsolateTimer(milliSeconds, callback, repeating));
OLDNEW
« no previous file with comments | « tests/html/js_interop_4_test.dart ('k') | tools/dom/src/native_DOMPublic.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698