Index: lib/dom/templates/html/dartium/html_dartium.darttemplate |
diff --git a/lib/dom/templates/html/dartium/html_dartium.darttemplate b/lib/dom/templates/html/dartium/html_dartium.darttemplate |
index 9c890e64ce98805f2a669f89380081b7271b63b7..2ea2c6915ef08281259da76a98c03411ec2b02b0 100644 |
--- a/lib/dom/templates/html/dartium/html_dartium.darttemplate |
+++ b/lib/dom/templates/html/dartium/html_dartium.darttemplate |
@@ -22,6 +22,7 @@ $!GENERATED_DART_FILES |
#source('$AUXILIARY_DIR/../../html/src/shared_FactoryProviders.dart'); |
#source('$AUXILIARY_DIR/../../html/src/dartium_FactoryProviders.dart'); |
#source('$AUXILIARY_DIR/../../html/src/IDBOpenDBRequest.dart'); |
+#source('$AUXILIARY_DIR/../../html/src/Isolates.dart'); |
#source('$AUXILIARY_DIR/../../html/src/Measurement.dart'); |
#source('$AUXILIARY_DIR/../../html/src/Device.dart'); |
#source('$AUXILIARY_DIR/../../html/src/_Testing.dart'); |
@@ -65,54 +66,27 @@ class _Null { |
final _null = const _Null(); |
-// TODO(vsm): Move this to a separate Isolates.dart file. |
-_serialize(var message) { |
- // TODO(kasperl): Specialize the serializer. |
- return new _Serializer().traverse(message); |
+int _getNewIsolateId() { |
+ // TODO(vsm): We need a Dartium native for this. |
+ return 1; |
} |
-_deserialize(var message) { |
- return new _JsDeserializer().deserialize(message); |
-} |
- |
-class _JsDeserializer extends _Deserializer { |
- |
- deserializeSendPort(List x) { |
- num id = x[1]; |
- return new _JsSendPortSync(id); |
- } |
- |
-} |
- |
-class _JsSendPortSync implements SendPortSync { |
+bool _callPortInitialized = false; |
+var _callPortLastResult = null; |
- static bool initialized = false; |
- static var lastResult = null; |
- |
- num _id; |
- _JsSendPortSync(this._id) { |
- if (initialized) return; |
+_callPortSync(num id, var message) { |
+ if (!_callPortInitialized) { |
window.on['js-result'].add((event) { |
- lastResult = JSON.parse(event.data); |
+ _callPortLastResult = JSON.parse(event.data); |
}, false); |
- initialized = true; |
- } |
- |
- callSync(var message) { |
- var serialized = _serialize(message); |
- var result = _callUsingEvent(_id, serialized); |
- return _deserialize(result); |
+ _callPortInitialized = true; |
} |
- |
- static _callUsingEvent(num id, var message) { |
- var data = JSON.stringify({ 'id': id, 'message': message }); |
- var event = document.$dom_createEvent('TextEvent'); |
- event.initTextEvent('js-sync-message', false, false, window, data); |
- assert(lastResult == null); |
- window.$dom_dispatchEvent(event); |
- var result = lastResult; |
- lastResult = null; |
- return result; |
- } |
- |
+ var data = JSON.stringify({ 'id': id, 'message': message }); |
+ var event = document.$dom_createEvent('TextEvent'); |
+ event.initTextEvent('js-sync-message', false, false, window, data); |
+ assert(_callPortLastResult == null); |
+ window.$dom_dispatchEvent(event); |
+ var result = _callPortLastResult; |
+ _callPortLastResult = null; |
+ return result; |
} |