summaryrefslogtreecommitdiffstats
path: root/content/browser/storage_partition_impl.cc
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-16 04:01:08 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-16 04:01:08 +0000
commit71ace01735e041c2633dca68de83f59946d60b00 (patch)
treefcb901ec49437b5a161805958b2fd096c743d12d /content/browser/storage_partition_impl.cc
parent84ed2976c5e799f3eaa79cc938f6cd4b3a730477 (diff)
downloadchromium_src-71ace01735e041c2633dca68de83f59946d60b00.zip
chromium_src-71ace01735e041c2633dca68de83f59946d60b00.tar.gz
chromium_src-71ace01735e041c2633dca68de83f59946d60b00.tar.bz2
Redo the Storage Partition directory layout to support guest tags and origin based partitions.
The new layout is (1) ProfileDir/Default/Storage Partitions/extensions/{ extension_id }/default/ (2) ProfileDir/Default/Storage Partitions/extensions/{ extension_id }/{ hash(BrowserTag.partition) }/ In the future, after we add support for browser tags in webui or add support for server administrators of websites to opt into storage isolation, we will also need: (3) ProfileDir/Default/Storage Partitions/origins/{ hash(origin) }/default/ (4) ProfileDir/Default/Storage Partitions/origins/{ hash(origin) }/{ hash(BrowserTag.partition) }/ TBR=willchan BUG=85121 Review URL: https://chromiumcodereview.appspot.com/10913265 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157039 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/storage_partition_impl.cc')
-rw-r--r--content/browser/storage_partition_impl.cc50
1 files changed, 49 insertions, 1 deletions
diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc
index e906a6a..02cb5d7 100644
--- a/content/browser/storage_partition_impl.cc
+++ b/content/browser/storage_partition_impl.cc
@@ -12,6 +12,46 @@
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
+// persistent partition used by an extension's browser tags. Example:
+//
+// {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 FilePath::CharType kExtensionsDirname[] =
+ FILE_PATH_LITERAL("extensions");
+const FilePath::CharType kDefaultPartitionDirname[] =
+ FILE_PATH_LITERAL("default");
+
+} // namespace
+
+// static
+FilePath StoragePartition::GetPartitionPath(const std::string& partition_id) {
+ if (partition_id.empty()) {
+ // The default profile just sits inside the top-level profile directory.
+ return FilePath();
+ }
+
+ // TODO(ajwong): This should check that we create a valid path name.
+ CHECK(IsStringASCII(partition_id));
+ return FilePath(kStoragePartitionDirname)
+ .Append(kExtensionsDirname)
+ .AppendASCII(partition_id)
+ .Append(kDefaultPartitionDirname);
+}
+
StoragePartitionImpl::StoragePartitionImpl(
const FilePath& partition_path,
quota::QuotaManager* quota_manager,
@@ -47,12 +87,16 @@ 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 =
+ profile_path.Append(GetPartitionPath(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 +143,10 @@ StoragePartitionImpl* StoragePartitionImpl::Create(
indexed_db_context);
}
+FilePath StoragePartitionImpl::GetPath() {
+ return partition_path_;
+}
+
quota::QuotaManager* StoragePartitionImpl::GetQuotaManager() {
return quota_manager_;
}