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

Side by Side Diff: chrome/renderer/resources/extensions/entry_id_manager.js

Issue 17451011: Make the externally connectable browser test clobber all of the builtins, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var fileSystemNatives = requireNative('file_system_natives'); 5 var fileSystemNatives = requireNative('file_system_natives');
6 6
7 var nameToIds = {}; 7 var nameToIds = {};
8 var idsToEntries = {}; 8 var idsToEntries = {};
9 9
10 function computeName(entry) { 10 function computeName(entry) {
11 return entry.filesystem.name + ':' + entry.fullPath; 11 return entry.filesystem.name + ':' + entry.fullPath;
12 } 12 }
13 13
14 function computeId(entry) { 14 function computeId(entry) {
15 var fileSystemId = fileSystemNatives.CrackIsolatedFileSystemName( 15 var fileSystemId = fileSystemNatives.CrackIsolatedFileSystemName(
16 entry.filesystem.name); 16 entry.filesystem.name);
17 if (!fileSystemId) 17 if (!fileSystemId)
18 return null; 18 return null;
19 // Strip the leading '/' from the path. 19 // Strip the leading '/' from the path.
20 return fileSystemId + ':' + entry.fullPath.slice(1); 20 return fileSystemId + ':' + $String.slice(entry.fullPath, 1);
21 } 21 }
22 22
23 function registerEntry(id, entry) { 23 function registerEntry(id, entry) {
24 var name = computeName(entry); 24 var name = computeName(entry);
25 nameToIds[name] = id; 25 nameToIds[name] = id;
26 idsToEntries[id] = entry; 26 idsToEntries[id] = entry;
27 } 27 }
28 28
29 function getEntryId(entry) { 29 function getEntryId(entry) {
30 var name = null; 30 var name = null;
(...skipping 12 matching lines...) Expand all
43 return id; 43 return id;
44 } 44 }
45 45
46 function getEntryById(id) { 46 function getEntryById(id) {
47 return idsToEntries[id]; 47 return idsToEntries[id];
48 } 48 }
49 49
50 exports.registerEntry = registerEntry; 50 exports.registerEntry = registerEntry;
51 exports.getEntryId = getEntryId; 51 exports.getEntryId = getEntryId;
52 exports.getEntryById = getEntryById; 52 exports.getEntryById = getEntryById;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698