mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
Phase out local storage usage in PortSync code
Review URL: https://codereview.chromium.org//11415064 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@15151 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
547cbf9da6
commit
43851494a8
|
@ -159,11 +159,21 @@ function ReceivePortSync() {
|
|||
|
||||
window.registerPort = function(name, port) {
|
||||
var stringified = JSON.stringify(serialize(port));
|
||||
window.localStorage['dart-port:' + name] = stringified;
|
||||
var attrName = 'dart-port:' + name;
|
||||
document.documentElement.setAttribute(attrName, stringified);
|
||||
// TODO(vsm): Phase out usage of localStorage. We're leaving it in
|
||||
// temporarily for backwards compatibility.
|
||||
window.localStorage[attrName] = stringified;
|
||||
};
|
||||
|
||||
window.lookupPort = function(name) {
|
||||
var stringified = window.localStorage['dart-port:' + name];
|
||||
var attrName = 'dart-port:' + name;
|
||||
var stringified = document.documentElement.getAttribute(attrName);
|
||||
// TODO(vsm): Phase out usage of localStorage. We're leaving it in
|
||||
// temporarily for backwards compatibility.
|
||||
if (!stringified) {
|
||||
stringified = window.localStorage[attrName];
|
||||
}
|
||||
return deserialize(JSON.parse(stringified));
|
||||
};
|
||||
|
||||
|
|
|
@ -12001,7 +12001,7 @@ class LocalWindow extends EventTarget implements Window native "@*DOMWindow" {
|
|||
* registered under [name].
|
||||
*/
|
||||
SendPortSync lookupPort(String name) {
|
||||
var port = JSON.parse(localStorage['dart-port:$name']);
|
||||
var port = JSON.parse(document.documentElement.attributes['dart-port:$name']);
|
||||
return _deserialize(port);
|
||||
}
|
||||
|
||||
|
@ -12012,7 +12012,7 @@ class LocalWindow extends EventTarget implements Window native "@*DOMWindow" {
|
|||
*/
|
||||
void registerPort(String name, var port) {
|
||||
var serialized = _serialize(port);
|
||||
localStorage['dart-port:$name'] = JSON.stringify(serialized);
|
||||
document.documentElement.attributes['dart-port:$name'] = JSON.stringify(serialized);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15385,7 +15385,7 @@ class LocalWindow extends EventTarget implements Window {
|
|||
* registered under [name].
|
||||
*/
|
||||
lookupPort(String name) {
|
||||
var port = JSON.parse(localStorage['dart-port:$name']);
|
||||
var port = JSON.parse(document.documentElement.attributes['dart-port:$name']);
|
||||
return _deserialize(port);
|
||||
}
|
||||
|
||||
|
@ -15396,7 +15396,7 @@ class LocalWindow extends EventTarget implements Window {
|
|||
*/
|
||||
registerPort(String name, var port) {
|
||||
var serialized = _serialize(port);
|
||||
localStorage['dart-port:$name'] = JSON.stringify(serialized);
|
||||
document.documentElement.attributes['dart-port:$name'] = JSON.stringify(serialized);
|
||||
}
|
||||
|
||||
LocalWindow.internal(): super.internal();
|
||||
|
|
|
@ -131,7 +131,7 @@ class $CLASSNAME$EXTENDS$IMPLEMENTS native "@*DOMWindow" {
|
|||
* registered under [name].
|
||||
*/
|
||||
SendPortSync lookupPort(String name) {
|
||||
var port = JSON.parse(localStorage['dart-port:$name']);
|
||||
var port = JSON.parse(document.documentElement.attributes['dart-port:$name']);
|
||||
return _deserialize(port);
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ class $CLASSNAME$EXTENDS$IMPLEMENTS native "@*DOMWindow" {
|
|||
*/
|
||||
void registerPort(String name, var port) {
|
||||
var serialized = _serialize(port);
|
||||
localStorage['dart-port:$name'] = JSON.stringify(serialized);
|
||||
document.documentElement.attributes['dart-port:$name'] = JSON.stringify(serialized);
|
||||
}
|
||||
|
||||
$!MEMBERS
|
||||
|
|
|
@ -20,7 +20,7 @@ class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
|||
* registered under [name].
|
||||
*/
|
||||
lookupPort(String name) {
|
||||
var port = JSON.parse(localStorage['dart-port:$name']);
|
||||
var port = JSON.parse(document.documentElement.attributes['dart-port:$name']);
|
||||
return _deserialize(port);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
|||
*/
|
||||
registerPort(String name, var port) {
|
||||
var serialized = _serialize(port);
|
||||
localStorage['dart-port:$name'] = JSON.stringify(serialized);
|
||||
document.documentElement.attributes['dart-port:$name'] = JSON.stringify(serialized);
|
||||
}
|
||||
|
||||
$!MEMBERS
|
||||
|
|
Loading…
Reference in a new issue