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

Unified Diff: chrome/renderer/resources/extensions/entry_id_manager.js

Issue 14607023: Add support for persistent file access in apps. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/resources/extensions/entry_id_manager.js
diff --git a/chrome/renderer/resources/extensions/entry_id_manager.js b/chrome/renderer/resources/extensions/entry_id_manager.js
index 743165097938494ffb08d033a7cd267f1cdd2ebb..89332395d54f75f6ffb7a837344321d0c004d298 100644
--- a/chrome/renderer/resources/extensions/entry_id_manager.js
+++ b/chrome/renderer/resources/extensions/entry_id_manager.js
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+var fileSystemNatives = requireNative('file_system_natives');
+
var nameToIds = {};
var idsToEntries = {};
@@ -9,11 +11,20 @@ function computeName(entry) {
return entry.filesystem.name + ':' + entry.fullPath;
}
+function computeId(entry) {
+ var fileSystemId = fileSystemNatives.CrackIsolatedFileSystemName(
+ entry.filesystem.name);
+ if (!fileSystemId)
+ return null;
+ // Strip the leading '/' from the path.
+ return fileSystemId + ':' + entry.fullPath.slice(1);
+}
+
function registerEntry(id, entry) {
var name = computeName(entry);
nameToIds[name] = id;
idsToEntries[id] = entry;
-};
+}
function getEntryId(entry) {
var name = null;
@@ -22,7 +33,14 @@ function getEntryId(entry) {
} catch(e) {
return null;
}
- return nameToIds[name];
+ var id = nameToIds[name];
+ if (id != null)
+ return id;
+
+ // If an entry has not been registered, compute its id and register it.
+ id = computeId(entry);
+ registerEntry(id, entry);
+ return id;
}
function getEntryById(id) {

Powered by Google App Engine
This is Rietveld 408576698