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

Unified Diff: sdk/lib/js/dartium/js_dartium.dart

Issue 26092003: Maintain referential integrity of proxy instances in dart:js (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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
Index: sdk/lib/js/dartium/js_dartium.dart
diff --git a/sdk/lib/js/dartium/js_dartium.dart b/sdk/lib/js/dartium/js_dartium.dart
index a0c48ea0d93ed32372e0262d46effebb8c054aef..1f8359329d17a0f7499e29b2e694b9e2f78845d5 100644
--- a/sdk/lib/js/dartium/js_dartium.dart
+++ b/sdk/lib/js/dartium/js_dartium.dart
@@ -283,9 +283,9 @@ class _ProxiedObjectTable {
}
// Adds a new object to the table and return a new ID for it.
- String add(x) {
+ String add(x, {String id}) {
// TODO(vsm): Cache x and reuse id.
- final id = '$_name-${_nextId++}';
+ id = (id != null) ? id : '$_name-${_nextId++}';
_registry[id] = x;
return id;
}
@@ -347,8 +347,13 @@ _deserialize(var message) {
// Local function.
return _proxiedObjectTable.get(id);
} else {
- // Remote function. Forward to its port.
- return new JsFunction._internal(port, id);
+ // Remote function.
alexandre.ardhuin 2013/10/07 08:56:54 _proxiedObjectTable currently contains only Dart l
justinfagnani 2013/10/07 17:49:13 I'm ok with the name, since it's either holding pr
+ var jsFunction = _proxiedObjectTable.get(id);
+ if (jsFunction == null) {
+ jsFunction = new JsFunction._internal(port, id);
+ _proxiedObjectTable.add(jsFunction, id: id);
+ }
+ return jsFunction;
}
}
@@ -360,7 +365,12 @@ _deserialize(var message) {
return _proxiedObjectTable.get(id);
} else {
// Remote object.
- return new JsObject._internal(port, id);
+ var jsObject = _proxiedObjectTable.get(id);
+ if (jsObject == null) {
+ jsObject = new JsObject._internal(port, id);
+ _proxiedObjectTable.add(jsObject, id: id);
+ }
+ return jsObject;
}
}

Powered by Google App Engine
This is Rietveld 408576698