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; |
} |
} |