Index: tools/dom/src/native_DOMImplementation.dart |
diff --git a/tools/dom/src/native_DOMImplementation.dart b/tools/dom/src/native_DOMImplementation.dart |
index 8991ee140adbac41c3e9300cdc05b3dc95839f99..bba784b2d5026c9092ec504077abcb61ac06883c 100644 |
--- a/tools/dom/src/native_DOMImplementation.dart |
+++ b/tools/dom/src/native_DOMImplementation.dart |
@@ -106,7 +106,6 @@ class _Utils { |
static window() native "Utils_window"; |
static forwardingPrint(String message) native "Utils_forwardingPrint"; |
- static void spawnDomFunction(Function f, int replyTo) native "Utils_spawnDomFunction"; |
static int _getNewIsolateId() native "Utils_getNewIsolateId"; |
// The following methods were added for debugger integration to make working |
@@ -366,79 +365,10 @@ class _DOMStringMap extends NativeFieldWrapperClass1 implements Map<String, Stri |
bool get isNotEmpty => Maps.isNotEmpty(this); |
} |
-// TODO(vsm): Remove DOM isolate code. This is only used to support |
-// printing and timers in background isolates. Background isolates |
-// should just forward to the main DOM isolate instead of requiring a |
-// special DOM isolate. |
- |
-_makeSendPortFuture(spawnRequest) { |
- final completer = new Completer<SendPort>.sync(); |
- final port = new ReceivePort(); |
- port.receive((result, _) { |
- completer.complete(result); |
- port.close(); |
- }); |
- // TODO: SendPort.hashCode is ugly way to access port id. |
- spawnRequest(port.toSendPort().hashCode); |
- return completer.future; |
-} |
- |
-Future<SendPort> _spawnDomFunction(Function f) => |
- _makeSendPortFuture((portId) { _Utils.spawnDomFunction(f, portId); }); |
- |
-final Future<SendPort> __HELPER_ISOLATE_PORT = |
- _spawnDomFunction(_helperIsolateMain); |
- |
-// Tricky part. |
-// Once __HELPER_ISOLATE_PORT gets resolved, it will still delay in .then |
-// and to delay Timer.run is used. However, Timer.run will try to register |
-// another Timer and here we got stuck: event cannot be posted as then |
-// callback is not executed because it's delayed with timer. |
-// Therefore once future is resolved, it's unsafe to call .then on it |
-// in Timer code. |
-SendPort __SEND_PORT; |
- |
-_sendToHelperIsolate(msg, SendPort replyTo) { |
- if (__SEND_PORT != null) { |
- __SEND_PORT.send(msg, replyTo); |
- } else { |
- __HELPER_ISOLATE_PORT.then((port) { |
- __SEND_PORT = port; |
- __SEND_PORT.send(msg, replyTo); |
- }); |
- } |
-} |
- |
-final _TIMER_REGISTRY = new Map<SendPort, Timer>(); |
- |
-const _NEW_TIMER = 'NEW_TIMER'; |
-const _CANCEL_TIMER = 'CANCEL_TIMER'; |
-const _TIMER_PING = 'TIMER_PING'; |
-const _PRINT = 'PRINT'; |
- |
-_helperIsolateMain() { |
- port.receive((msg, replyTo) { |
- final cmd = msg[0]; |
- if (cmd == _NEW_TIMER) { |
- final duration = new Duration(milliseconds: msg[1]); |
- bool periodic = msg[2]; |
- ping() { replyTo.send(_TIMER_PING); }; |
- _TIMER_REGISTRY[replyTo] = periodic ? |
- new Timer.periodic(duration, (_) { ping(); }) : |
- new Timer(duration, ping); |
- } else if (cmd == _CANCEL_TIMER) { |
- _TIMER_REGISTRY.remove(replyTo).cancel(); |
- } else if (cmd == _PRINT) { |
- final message = msg[1]; |
- // TODO(antonm): we need somehow identify those isolates. |
- print('[From isolate] $message'); |
- } |
- }); |
-} |
- |
final _printClosure = window.console.log; |
final _pureIsolatePrintClosure = (s) { |
- _sendToHelperIsolate([_PRINT, s], null); |
+ throw new UnimplementedError("Printing from a background isolate " |
+ "is not supported in the browser"); |
}; |
final _forwardingPrintClosure = _Utils.forwardingPrint; |
@@ -477,43 +407,7 @@ get _timerFactoryClosure => |
return new _Timer(milliSeconds, callback, repeating); |
}; |
- |
-class _PureIsolateTimer implements Timer { |
- bool _isActive = true; |
- final ReceivePort _port = new ReceivePort(); |
- SendPort _sendPort; // Effectively final. |
- |
- static SendPort _SEND_PORT; |
- |
- _PureIsolateTimer(int milliSeconds, callback, repeating) { |
- _sendPort = _port.toSendPort(); |
- _port.receive((msg, replyTo) { |
- assert(msg == _TIMER_PING); |
- _isActive = repeating; |
- callback(this); |
- if (!repeating) _cancel(); |
- }); |
- |
- _send([_NEW_TIMER, milliSeconds, repeating]); |
- } |
- |
- void cancel() { |
- _cancel(); |
- _send([_CANCEL_TIMER]); |
- } |
- |
- void _cancel() { |
- _isActive = false; |
- _port.close(); |
- } |
- |
- _send(msg) { |
- _sendToHelperIsolate(msg, _sendPort); |
- } |
- |
- bool get isActive => _isActive; |
-} |
- |
get _pureIsolateTimerFactoryClosure => |
((int milliSeconds, void callback(Timer time), bool repeating) => |
- new _PureIsolateTimer(milliSeconds, callback, repeating)); |
+ throw new UnimplementedError("Timers on background isolates " |
+ "are not supported in the browser")); |