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

Side by Side Diff: tools/dom/src/native_DOMImplementation.dart

Issue 13350002: Revert r20668. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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 | « tools/dom/src/Timer.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of html; 5 part of html;
6 6
7 class _Utils { 7 class _Utils {
8 static double dateTimeToDouble(DateTime dateTime) => 8 static double dateTimeToDouble(DateTime dateTime) =>
9 dateTime.millisecondsSinceEpoch.toDouble(); 9 dateTime.millisecondsSinceEpoch.toDouble();
10 static DateTime doubleToDateTime(double dateTime) { 10 static DateTime doubleToDateTime(double dateTime) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 static bool isMap(obj) => obj is Map; 52 static bool isMap(obj) => obj is Map;
53 53
54 static Map createMap() => {}; 54 static Map createMap() => {};
55 55
56 static makeUnimplementedError(String fileName, int lineNo) { 56 static makeUnimplementedError(String fileName, int lineNo) {
57 return new UnsupportedError('[info: $fileName:$lineNo]'); 57 return new UnsupportedError('[info: $fileName:$lineNo]');
58 } 58 }
59 59
60 static window() native "Utils_window"; 60 static window() native "Utils_window";
61 static print(String message) native "Utils_print";
61 static forwardingPrint(String message) native "Utils_forwardingPrint"; 62 static forwardingPrint(String message) native "Utils_forwardingPrint";
62 static void spawnDomFunction(Function topLevelFunction, int replyTo) native "U tils_spawnDomFunction"; 63 static void spawnDomFunction(Function topLevelFunction, int replyTo) native "U tils_spawnDomFunction";
63 static int _getNewIsolateId() native "Utils_getNewIsolateId"; 64 static int _getNewIsolateId() native "Utils_getNewIsolateId";
64 static bool shadowRootSupported(Document document) native "Utils_shadowRootSup ported"; 65 static bool shadowRootSupported(Document document) native "Utils_shadowRootSup ported";
65 } 66 }
66 67
67 class _NPObject extends NativeFieldWrapperClass1 { 68 class _NPObject extends NativeFieldWrapperClass1 {
68 _NPObject.internal(); 69 _NPObject.internal();
69 static _NPObject retrieve(String key) native "NPObject_retrieve"; 70 static _NPObject retrieve(String key) native "NPObject_retrieve";
70 property(String propertyName) native "NPObject_property"; 71 property(String propertyName) native "NPObject_property";
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 String putIfAbsent(String key, String ifAbsent()) => Maps.putIfAbsent(this, ke y, ifAbsent); 125 String putIfAbsent(String key, String ifAbsent()) => Maps.putIfAbsent(this, ke y, ifAbsent);
125 String remove(String key) native "DOMStringMap_remove_Callback"; 126 String remove(String key) native "DOMStringMap_remove_Callback";
126 void clear() => Maps.clear(this); 127 void clear() => Maps.clear(this);
127 void forEach(void f(String key, String value)) => Maps.forEach(this, f); 128 void forEach(void f(String key, String value)) => Maps.forEach(this, f);
128 Collection<String> get keys native "DOMStringMap_getKeys_Callback"; 129 Collection<String> get keys native "DOMStringMap_getKeys_Callback";
129 Collection<String> get values => Maps.getValues(this); 130 Collection<String> get values => Maps.getValues(this);
130 int get length => Maps.length(this); 131 int get length => Maps.length(this);
131 bool get isEmpty => Maps.isEmpty(this); 132 bool get isEmpty => Maps.isEmpty(this);
132 } 133 }
133 134
134 final Future<SendPort> _HELPER_ISOLATE_PORT = 135 get _printClosure => (s) {
135 spawnDomFunction(_helperIsolateMain); 136 try {
136 137 window.console.log(s);
137 final _TIMER_REGISTRY = new Map<SendPort, Timer>(); 138 } catch (_) {
138 139 _Utils.print(s);
139 const _NEW_TIMER = 'NEW_TIMER'; 140 }
140 const _CANCEL_TIMER = 'CANCEL_TIMER';
141 const _TIMER_PING = 'TIMER_PING';
142 const _PRINT = 'PRINT';
143
144 _helperIsolateMain() {
145 port.receive((msg, replyTo) {
146 final cmd = msg[0];
147 if (cmd == _NEW_TIMER) {
148 final duration = new Duration(milliseconds: msg[1]);
149 bool periodic = msg[2];
150 final callback = () { replyTo.send(_TIMER_PING); };
151 _TIMER_REGISTRY[replyTo] = periodic ?
152 new Timer.periodic(duration, callback) :
153 new Timer(duration, callback);
154 } else if (cmd == _CANCEL_TIMER) {
155 _TIMER_REGISTRY.remove(replyTo).cancel();
156 } else if (cmd == _PRINT) {
157 final message = msg[1];
158 // TODO(antonm): we need somehow identify those isolates.
159 print('[From isolate] $message');
160 }
161 });
162 }
163
164 final _printClosure = window.console.log;
165 final _pureIsolatePrintClosure = (s) {
166 _HELPER_ISOLATE_PORT.then((sendPort) {
167 sendPort.send([_PRINT, s]);
168 });
169 }; 141 };
170 142
171 final _forwardingPrintClosure = _Utils.forwardingPrint; 143 final _forwardingPrintClosure = _Utils.forwardingPrint;
OLDNEW
« no previous file with comments | « tools/dom/src/Timer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698