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

Unified Diff: lib/dom/templates/html/dartium/html_dartium.darttemplate

Issue 10702110: Added Dartium support for JS to Dart PortSync calls (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed tabbing Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/dart.js ('k') | lib/dom/templates/html/dartium/impl_Window.darttemplate » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « client/dart.js ('k') | lib/dom/templates/html/dartium/impl_Window.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698