Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/storage/io.js

Issue 5693109165883392: Issue 2040 - Replaced localStorage with chrome.storage.local (Closed)
Patch Set: Re-introduces defaults mapping, added Prefs.onLoading event, made currentVersion a pref Created March 20, 2015, 1:19 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/stats.js ('k') | metadata.chrome » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/storage/io.js
===================================================================
--- a/lib/storage/io.js
+++ b/lib/storage/io.js
@@ -33,8 +33,8 @@
_setFileContents: function(path, contents, lastModified)
{
- ext.storage[path] = contents;
- ext.storage[path + "/lastModified"] = lastModified || 0;
+ safari.extension.settings[path] = contents;
+ safari.extension.settings[path + "/lastModified"] = lastModified || 0;
},
lineBreak: "\n",
@@ -50,13 +50,13 @@
Utils.runAsync(function()
{
var path = this._getFilePath(file);
- if (!(path in ext.storage))
+ if (!(path in safari.extension.settings))
{
callback(new Error("File doesn't exist"))
return;
}
- var lines = ext.storage[path].split(/[\r\n]+/);
+ var lines = safari.extension.settings[path].split(/[\r\n]+/);
for (var i = 0; i < lines.length; i++)
listener.process(lines[i]);
listener.process(null);
@@ -95,21 +95,21 @@
renameFile: function(fromFile, newName, callback)
{
var path = this._getFilePath(fromFile);
- if (!(path in ext.storage))
+ if (!(path in safari.extension.settings))
{
callback(new Error("File doesn't exist"))
return;
}
- this._setFileContents(newName, ext.storage[path], ext.storage[path + "/lastModified"]);
+ this._setFileContents(newName, safari.extension.settings[path], safari.extension.settings[path + "/lastModified"]);
this.removeFile(fromFile, callback);
},
removeFile: function(file, callback)
{
var path = this._getFilePath(file);
- delete ext.storage[path];
- delete ext.storage[path + "/lastModified"];
+ delete safari.extension.settings[path];
+ delete safari.extension.settings[path + "/lastModified"];
callback(null);
},
@@ -120,10 +120,10 @@
// This needs to use Utils.runAsync(), otherwise FilterStorage might
// initialize too early - see #337.
require("utils").Utils.runAsync(callback.bind(null, null, {
- exists: path in ext.storage,
+ exists: path in safari.extension.settings,
isDirectory: false,
isFile: true,
- lastModified: parseInt(ext.storage[path + "/lastModified"], 10) || 0
+ lastModified: parseInt(safari.extension.settings[path + "/lastModified"], 10) || 0
}));
}
};
« no previous file with comments | « lib/stats.js ('k') | metadata.chrome » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld