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

Side by Side Diff: client/dart.js

Issue 11415064: Phase out local storage usage in PortSync code (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge Created 8 years, 1 month 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/dart2js/html_dart2js.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 // 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 // Bootstrap support for Dart scripts on the page as this script. 5 // Bootstrap support for Dart scripts on the page as this script.
6 if (navigator.webkitStartDart) { 6 if (navigator.webkitStartDart) {
7 if (!navigator.webkitStartDart()) { 7 if (!navigator.webkitStartDart()) {
8 document.body.innerHTML = 'This build has expired. Please download a new Da rtium at http://www.dartlang.org/dartium/index.html'; 8 document.body.innerHTML = 'This build has expired. Please download a new Da rtium at http://www.dartlang.org/dartium/index.html';
9 } 9 }
10 } else { 10 } else {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 var length = values.length; 152 var length = values.length;
153 var result = new Array(length); 153 var result = new Array(length);
154 for (var i = 0; i < length; i++) { 154 for (var i = 0; i < length; i++) {
155 result[i] = deserializeHelper(values[i]); 155 result[i] = deserializeHelper(values[i]);
156 } 156 }
157 return result; 157 return result;
158 } 158 }
159 159
160 window.registerPort = function(name, port) { 160 window.registerPort = function(name, port) {
161 var stringified = JSON.stringify(serialize(port)); 161 var stringified = JSON.stringify(serialize(port));
162 window.localStorage['dart-port:' + name] = stringified; 162 var attrName = 'dart-port:' + name;
163 document.documentElement.setAttribute(attrName, stringified);
164 // TODO(vsm): Phase out usage of localStorage. We're leaving it in
165 // temporarily for backwards compatibility.
166 window.localStorage[attrName] = stringified;
163 }; 167 };
164 168
165 window.lookupPort = function(name) { 169 window.lookupPort = function(name) {
166 var stringified = window.localStorage['dart-port:' + name]; 170 var attrName = 'dart-port:' + name;
171 var stringified = document.documentElement.getAttribute(attrName);
172 // TODO(vsm): Phase out usage of localStorage. We're leaving it in
173 // temporarily for backwards compatibility.
174 if (!stringified) {
175 stringified = window.localStorage[attrName];
176 }
167 return deserialize(JSON.parse(stringified)); 177 return deserialize(JSON.parse(stringified));
168 }; 178 };
169 179
170 ReceivePortSync.id = 0; 180 ReceivePortSync.id = 0;
171 ReceivePortSync.map = {}; 181 ReceivePortSync.map = {};
172 182
173 ReceivePortSync.dispatchCall = function(id, message) { 183 ReceivePortSync.dispatchCall = function(id, message) {
174 // TODO(vsm): Handle and propagate exceptions. 184 // TODO(vsm): Handle and propagate exceptions.
175 var deserialized = deserialize(message); 185 var deserialized = deserialize(message);
176 var result = ReceivePortSync.map[id].callback(deserialized); 186 var result = ReceivePortSync.map[id].callback(deserialized);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 var result = null; 248 var result = null;
239 var listener = function (e) { 249 var listener = function (e) {
240 result = JSON.parse(getPortSyncEventData(e)); 250 result = JSON.parse(getPortSyncEventData(e));
241 }; 251 };
242 window.addEventListener(source, listener, false); 252 window.addEventListener(source, listener, false);
243 dispatchEvent(target, [source, serialized]); 253 dispatchEvent(target, [source, serialized]);
244 window.removeEventListener(source, listener, false); 254 window.removeEventListener(source, listener, false);
245 return deserialize(result); 255 return deserialize(result);
246 } 256 }
247 })(); 257 })();
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/html/dart2js/html_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698