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..e9a08f3fbebaa23e4e90b7fae4c252bff684fd0c 100644 |
--- a/content/browser/storage_partition_impl.cc |
+++ b/content/browser/storage_partition_impl.cc |
@@ -12,6 +12,40 @@ |
namespace content { |
+// 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 subdivided into an extensions |
Charlie Reis
2012/09/14 21:03:13
nit: is subdivided into -> contains
(Not much of a
awong
2012/09/14 22:26:06
Done.
|
+// 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. Example: |
Charlie Reis
2012/09/14 21:03:13
nit: browser tag -> persistent browser tag partiti
awong
2012/09/14 22:26:06
Done.
|
+// |
+// {kStoragePartitionDirname}/extensions/ABCEDF/default |
Charlie Reis
2012/09/14 21:03:13
nit: ABCDEF? :)
awong
2012/09/14 22:26:06
Done.
|
+// {kStoragePartitionDirname}/extensions/ABCEDF/{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 kDefaultDirname[] = "default"; |
Charlie Reis
2012/09/14 21:03:13
kDefaultDirname is pretty vague for something in t
awong
2012/09/14 22:26:07
moved all these into an anonymous namespace. Tec
|
+ |
+FilePath StoragePartition::GetPartitionPath(const FilePath& profile_path, |
+ const std::string& partition_id) { |
+ if (partition_id.empty()) { |
+ // The default profile just sits inside the top-level directory. |
Charlie Reis
2012/09/14 21:03:13
nit: top-level profile directory.
awong
2012/09/14 22:26:07
Done.
|
+ return profile_path; |
+ } |
+ |
+ // TODO(ajwong): This should check the path is valid? |
Charlie Reis
2012/09/14 21:03:13
Valid in what sense? We don't want to go to disk
awong
2012/09/14 22:26:07
Done.
|
+ CHECK(IsStringASCII(partition_id)); |
+ return profile_path.Append(kStoragePartitionDirname) |
+ .AppendASCII(kExtensionsDirname) |
+ .AppendASCII(partition_id) |
+ .AppendASCII(kDefaultDirname); |
Charlie Reis
2012/09/14 21:03:13
Do we expect to have something like a separate Get
awong
2012/09/14 22:26:07
Nope. I expect this function to get more complicat
|
+} |
+ |
StoragePartitionImpl::StoragePartitionImpl( |
const FilePath& partition_path, |
quota::QuotaManager* quota_manager, |
@@ -47,12 +81,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 +138,10 @@ StoragePartitionImpl* StoragePartitionImpl::Create( |
indexed_db_context); |
} |
+FilePath StoragePartitionImpl::GetPath() { |
+ return partition_path_; |
+} |
+ |
quota::QuotaManager* StoragePartitionImpl::GetQuotaManager() { |
return quota_manager_; |
} |