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

Unified Diff: lib/html/dartium/html_dartium.dart

Side-by-side diff isn't available for this file because of its large size.
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 | « no previous file | lib/html/frog/html_frog.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/html/dartium/html_dartium.dart
diff --git a/lib/html/dartium/html_dartium.dart b/lib/html/dartium/html_dartium.dart
index 1b54e82164675deb88eb58fb009a748d781aa4a6..9e08b0a94a159b1e241188f26c8c5c73938208c7 100644
--- a/lib/html/dartium/html_dartium.dart
+++ b/lib/html/dartium/html_dartium.dart
@@ -49,10 +49,7 @@ class _Null {
final _null = const _Null();
-int _getNewIsolateId() {
- // TODO(vsm): We need a Dartium native for this.
- return 1;
-}
+int _getNewIsolateId() => _Utils._getNewIsolateId();
bool _callPortInitialized = false;
var _callPortLastResult = null;
@@ -64,11 +61,8 @@ _callPortSync(num id, var message) {
}, false);
_callPortInitialized = true;
}
- 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);
+ _dispatchEvent('js-sync-message', {'id': id, 'message': message});
var result = _callPortLastResult;
_callPortLastResult = null;
return result;
@@ -41080,28 +41074,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() {
@@ -41651,6 +41639,7 @@ class _Utils {
static window() native "Utils_window";
static SendPort spawnDomIsolateImpl(Window window, String entryPoint) native "Utils_spawnDomIsolate";
+ static int _getNewIsolateId() native "Utils_getNewIsolateId";
}
Utils_print(String message) native "Utils_print";
« no previous file with comments | « no previous file | lib/html/frog/html_frog.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698