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

Unified Diff: content/browser/storage_partition_impl_map.cc

Issue 314293003: [Storage] Normalize storage partition path before garbage collection (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: export StoragePartitionImplMap Created 6 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/storage_partition_impl_map.cc
diff --git a/content/browser/storage_partition_impl_map.cc b/content/browser/storage_partition_impl_map.cc
index 74a212f2d1b9b1581e49fda4df51c578caeec3be..fdfb34e3ebd5ba873d25fecaabf910ad208cc174 100644
--- a/content/browser/storage_partition_impl_map.cc
+++ b/content/browser/storage_partition_impl_map.cc
@@ -266,6 +266,27 @@ void BlockingObliteratePath(
}
}
+// Ensures each path in |active_paths| is a direct child of storage_root.
+void NormalizeActivePaths(const base::FilePath& storage_root,
+ base::hash_set<base::FilePath>* active_paths) {
+ base::hash_set<base::FilePath> normalized_active_paths;
+
+ for (base::hash_set<base::FilePath>::iterator iter = active_paths->begin();
+ iter != active_paths->end(); ++iter) {
+ base::FilePath relative_path;
+ if (!storage_root.AppendRelativePath(*iter, &relative_path))
+ continue;
+
+ std::vector<base::FilePath::StringType> components;
+ relative_path.GetComponents(&components);
+
+ DCHECK(!relative_path.empty());
+ normalized_active_paths.insert(storage_root.Append(components.front()));
+ }
+
+ active_paths->swap(normalized_active_paths);
+}
+
// Deletes all entries inside the |storage_root| that are not in the
// |active_paths|. Deletion is done in 2 steps:
//
@@ -289,6 +310,8 @@ void BlockingGarbageCollect(
scoped_ptr<base::hash_set<base::FilePath> > active_paths) {
CHECK(storage_root.IsAbsolute());
+ NormalizeActivePaths(storage_root, active_paths.get());
+
base::FileEnumerator enumerator(storage_root, false, kAllFileTypes);
base::FilePath trash_directory;
if (!base::CreateTemporaryDirInDir(storage_root, kTrashDirname,
« no previous file with comments | « content/browser/storage_partition_impl_map.h ('k') | content/browser/storage_partition_impl_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698