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

Unified Diff: content/browser/storage_partition_impl.cc

Issue 10913265: Redo the Storage Partition directory layout to support guest tags and origin based partitions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: redo the layout. Created 8 years, 3 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
« no previous file with comments | « content/browser/storage_partition_impl.h ('k') | content/browser/storage_partition_impl_map.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/storage_partition_impl.cc
diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc
index e906a6acb8dc22a68ba429db5a1370496b5a01d4..3dad1a4f2c5aeadbfe7dd5e6a6cee1a99a4e2afe 100644
--- a/content/browser/storage_partition_impl.cc
+++ b/content/browser/storage_partition_impl.cc
@@ -12,6 +12,44 @@
namespace content {
+namespace {
+
+// These constants are used to create the directory structure under the profile
+// where renderers with a non-default storage partition keep their persistent
+// state. This will contain a set of directories that partially mirror the
+// directory structure of BrowserContext::GetPath().
+//
+// The kStoragePartitionDirname is contains an extensions directory which is
+// further partitioned by extension id, followed by another level of directories
+// for the "default" extension storage partition and one directory for each
+// browser tag with persistent storage. Example:
Charlie Reis 2012/09/14 22:37:31 nit: This still isn't quite right, since you can h
awong 2012/09/14 23:01:22 reworded.
+//
+// {kStoragePartitionDirname}/extensions/ABCDEF/default
+// {kStoragePartitionDirname}/extensions/ABCDEF/{hash(guest partition)}
+//
+// The code in GetPartitionPath() constructs these path names.
+const FilePath::CharType kStoragePartitionDirname[] =
+ FILE_PATH_LITERAL("Storage Partitions");
+const char kExtensionsDirname[] = "extensions";
+const char kDefaultPartitionDirname[] = "default";
+
+} // namespace
+
+FilePath StoragePartition::GetPartitionPath(const FilePath& profile_path,
Charlie Reis 2012/09/14 22:37:31 nit: // static
awong 2012/09/14 23:01:22 Done.
+ const std::string& partition_id) {
+ if (partition_id.empty()) {
+ // The default profile just sits inside the top-level profile directory.
+ return profile_path;
+ }
+
+ // TODO(ajwong): This should check we create a valid path name.
+ CHECK(IsStringASCII(partition_id));
+ return profile_path.Append(kStoragePartitionDirname)
+ .AppendASCII(kExtensionsDirname)
+ .AppendASCII(partition_id)
+ .AppendASCII(kDefaultPartitionDirname);
+}
+
StoragePartitionImpl::StoragePartitionImpl(
const FilePath& partition_path,
quota::QuotaManager* quota_manager,
@@ -47,12 +85,17 @@ StoragePartitionImpl::~StoragePartitionImpl() {
// need 3 pieces of info from it.
StoragePartitionImpl* StoragePartitionImpl::Create(
BrowserContext* context,
- const FilePath& partition_path) {
+ const std::string& partition_id,
+ const FilePath& profile_path) {
// Ensure that these methods are called on the UI thread, except for
// unittests where a UI thread might not have been created.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
!BrowserThread::IsMessageLoopValid(BrowserThread::UI));
+ FilePath partition_path =
+ StoragePartition::GetPartitionPath(context->GetPath(),
+ partition_id);
+
// All of the clients have to be created and registered with the
// QuotaManager prior to the QuotaManger being used. We do them
// all together here prior to handing out a reference to anything
@@ -99,6 +142,10 @@ StoragePartitionImpl* StoragePartitionImpl::Create(
indexed_db_context);
}
+FilePath StoragePartitionImpl::GetPath() {
+ return partition_path_;
+}
+
quota::QuotaManager* StoragePartitionImpl::GetQuotaManager() {
return quota_manager_;
}
« no previous file with comments | « content/browser/storage_partition_impl.h ('k') | content/browser/storage_partition_impl_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698