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

Unified Diff: lib/html/frog/html_frog.dart

Issue 10701153: Refresh dart:html (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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:
Download patch
« no previous file with comments | « lib/html/dartium/html_dartium.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/html/frog/html_frog.dart
diff --git a/lib/html/frog/html_frog.dart b/lib/html/frog/html_frog.dart
index bf9c664370c772d6bf7f57a593fcd769c6f5ac64..4c35299bcdaf565da0e1855ef2373d767113625f 100644
--- a/lib/html/frog/html_frog.dart
+++ b/lib/html/frog/html_frog.dart
@@ -36922,28 +36922,22 @@ class ReceivePortSync {
String get _listenerName() => _getListenerName(_isolateId, _portId);
void receive(callback(var message)) {
- // Clear old listener.
- if (_callback != null) {
- window.on[_listenerName].remove(_listener);
- }
-
_callback = callback;
-
- // Install new listener.
- var sendport = toSendPort();
- _listener = (TextEvent e) {
- var data = JSON.parse(e.data);
- var replyTo = data[0];
- var message = _deserialize(data[1]);
- var result = sendport.callSync(message);
- _dispatchEvent(replyTo, _serialize(result));
- };
- window.on[_listenerName].add(_listener);
+ if (_listener === null) {
+ _listener = (TextEvent e) {
+ var data = JSON.parse(e.data);
+ var replyTo = data[0];
+ var message = _deserialize(data[1]);
+ var result = _callback(message);
+ _dispatchEvent(replyTo, _serialize(result));
+ };
+ window.on[_listenerName].add(_listener);
+ }
}
void close() {
_portMap.remove(_portId);
- window.on[_listenerName].remove(_listener);
+ if (_listener !== null) window.on[_listenerName].remove(_listener);
}
SendPortSync toSendPort() {
« no previous file with comments | « lib/html/dartium/html_dartium.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698