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

Side by Side Diff: sdk/lib/html/dart2js/html_dart2js.dart

Issue 11824053: Implement port equality on SendPortSync (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 80 char fix Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 library html; 1 library html;
2 2
3 import 'dart:async'; 3 import 'dart:async';
4 import 'dart:collection'; 4 import 'dart:collection';
5 import 'dart:html_common'; 5 import 'dart:html_common';
6 import 'dart:indexed_db'; 6 import 'dart:indexed_db';
7 import 'dart:isolate'; 7 import 'dart:isolate';
8 import 'dart:json' as json; 8 import 'dart:json' as json;
9 import 'dart:math'; 9 import 'dart:math';
10 import 'dart:svg' as svg; 10 import 'dart:svg' as svg;
(...skipping 25680 matching lines...) Expand 10 before | Expand all | Expand 10 after
25691 25691
25692 num _id; 25692 num _id;
25693 _JsSendPortSync(this._id); 25693 _JsSendPortSync(this._id);
25694 25694
25695 callSync(var message) { 25695 callSync(var message) {
25696 var serialized = _serialize(message); 25696 var serialized = _serialize(message);
25697 var result = _callPortSync(_id, serialized); 25697 var result = _callPortSync(_id, serialized);
25698 return _deserialize(result); 25698 return _deserialize(result);
25699 } 25699 }
25700 25700
25701 bool operator==(var other) {
25702 return (other is _JsSendPortSync) && (_id == other._id);
25703 }
25704
25705 int get hashCode => _id;
25701 } 25706 }
25702 25707
25703 // TODO(vsm): Differentiate between Dart2Js and Dartium isolates. 25708 // TODO(vsm): Differentiate between Dart2Js and Dartium isolates.
25704 // The receiver is a different Dart isolate, compiled to JS. 25709 // The receiver is a different Dart isolate, compiled to JS.
25705 class _RemoteSendPortSync implements SendPortSync { 25710 class _RemoteSendPortSync implements SendPortSync {
25706 25711
25707 int _isolateId; 25712 int _isolateId;
25708 int _portId; 25713 int _portId;
25709 _RemoteSendPortSync(this._isolateId, this._portId); 25714 _RemoteSendPortSync(this._isolateId, this._portId);
25710 25715
(...skipping 10 matching lines...) Expand all
25721 var source = '$target-result'; 25726 var source = '$target-result';
25722 var result = null; 25727 var result = null;
25723 var listener = (Event e) { 25728 var listener = (Event e) {
25724 result = json.parse(_getPortSyncEventData(e)); 25729 result = json.parse(_getPortSyncEventData(e));
25725 }; 25730 };
25726 window.on[source].add(listener); 25731 window.on[source].add(listener);
25727 _dispatchEvent(target, [source, message]); 25732 _dispatchEvent(target, [source, message]);
25728 window.on[source].remove(listener); 25733 window.on[source].remove(listener);
25729 return result; 25734 return result;
25730 } 25735 }
25736
25737 bool operator==(var other) {
25738 return (other is _RemoteSendPortSync) && (_isolateId == other._isolateId)
25739 && (_portId == other._portId);
25740 }
25741
25742 int get hashCode => _isolateId >> 16 + _portId;
25731 } 25743 }
25732 25744
25733 // The receiver is in the same Dart isolate, compiled to JS. 25745 // The receiver is in the same Dart isolate, compiled to JS.
25734 class _LocalSendPortSync implements SendPortSync { 25746 class _LocalSendPortSync implements SendPortSync {
25735 25747
25736 ReceivePortSync _receivePort; 25748 ReceivePortSync _receivePort;
25737 25749
25738 _LocalSendPortSync._internal(this._receivePort); 25750 _LocalSendPortSync._internal(this._receivePort);
25739 25751
25740 callSync(var message) { 25752 callSync(var message) {
25741 // TODO(vsm): Do a more efficient deep copy. 25753 // TODO(vsm): Do a more efficient deep copy.
25742 var copy = _deserialize(_serialize(message)); 25754 var copy = _deserialize(_serialize(message));
25743 var result = _receivePort._callback(copy); 25755 var result = _receivePort._callback(copy);
25744 return _deserialize(_serialize(result)); 25756 return _deserialize(_serialize(result));
25745 } 25757 }
25758
25759 bool operator==(var other) {
25760 return (other is _LocalSendPortSync)
25761 && (_receivePort == other._receivePort);
25762 }
25763
25764 int get hashCode => _receivePort.hashCode;
25746 } 25765 }
25747 25766
25748 // TODO(vsm): Move this to dart:isolate. This will take some 25767 // TODO(vsm): Move this to dart:isolate. This will take some
25749 // refactoring as there are dependences here on the DOM. Users 25768 // refactoring as there are dependences here on the DOM. Users
25750 // interact with this class (or interface if we change it) directly - 25769 // interact with this class (or interface if we change it) directly -
25751 // new ReceivePortSync. I think most of the DOM logic could be 25770 // new ReceivePortSync. I think most of the DOM logic could be
25752 // delayed until the corresponding SendPort is registered on the 25771 // delayed until the corresponding SendPort is registered on the
25753 // window. 25772 // window.
25754 25773
25755 // A Dart ReceivePortSync (tagged 'dart' when serialized) is 25774 // A Dart ReceivePortSync (tagged 'dart' when serialized) is
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after
26898 _position = nextPosition; 26917 _position = nextPosition;
26899 return true; 26918 return true;
26900 } 26919 }
26901 _current = null; 26920 _current = null;
26902 _position = _array.length; 26921 _position = _array.length;
26903 return false; 26922 return false;
26904 } 26923 }
26905 26924
26906 T get current => _current; 26925 T get current => _current;
26907 } 26926 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698