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

Unified Diff: content/browser/storage_partition_impl.cc

Issue 11234032: Webview tag creation should be using storage partitions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added IndexedDB test. Created 8 years, 1 month 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.cc
diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc
index 7ba19db086d3e608d288eec93a9530ff70a6b603..35166e4a8568ef1e2eba51b52a1167c80af8d6d6 100644
--- a/content/browser/storage_partition_impl.cc
+++ b/content/browser/storage_partition_impl.cc
@@ -4,6 +4,7 @@
#include "content/browser/storage_partition_impl.h"
+#include "base/utf_string_conversions.h"
#include "content/browser/fileapi/browser_file_system_helper.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
@@ -39,18 +40,29 @@ const FilePath::CharType kDefaultPartitionDirname[] =
} // 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.
+FilePath StoragePartitionImpl::GetStoragePartitionPath(
+ const StoragePartitionDescriptor& descriptor) {
+ if (descriptor.partition_domain.empty())
return FilePath();
+
+#if defined(OS_POSIX)
+ FilePath::StringType domain = descriptor.partition_domain;
awong 2012/11/02 21:56:13 Do we know if partition_domain, etc., are UTF-8?
nasko 2012/11/03 00:36:24 Yes, the partition_domain is even ASCII, since it
awong 2012/11/05 18:00:33 Do we have a check that enforces ascii and is it i
+ FilePath::StringType name = descriptor.partition_name;
+#elif defined(OS_WIN)
+ FilePath::StringType domain = UTF8ToUTF16(descriptor.partition_domain);
+ FilePath::StringType name = UTF8ToUTF16(descriptor.partition_name);
+#endif // OS_WIN
+
+ FilePath path = FilePath(kStoragePartitionDirname).Append(kExtensionsDirname)
+ .Append(domain);
+ if (!name.empty()) {
+ return path.Append(name);
+ } else {
+ return path.Append(kDefaultPartitionDirname);
awong 2012/11/02 21:56:13 Drop this out of the else {} clause and remove the
nasko 2012/11/03 00:36:24 Done.
}
- // 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);
+ NOTREACHED();
+ return FilePath();
}
StoragePartitionImpl::StoragePartitionImpl(
@@ -88,7 +100,7 @@ StoragePartitionImpl::~StoragePartitionImpl() {
// need 3 pieces of info from it.
StoragePartitionImpl* StoragePartitionImpl::Create(
BrowserContext* context,
- const std::string& partition_id,
+ const StoragePartitionDescriptor& partition_descriptor,
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.
@@ -96,7 +108,7 @@ StoragePartitionImpl* StoragePartitionImpl::Create(
!BrowserThread::IsMessageLoopValid(BrowserThread::UI));
FilePath partition_path =
- profile_path.Append(GetPartitionPath(partition_id));
+ profile_path.Append(GetStoragePartitionPath(partition_descriptor));
// All of the clients have to be created and registered with the
// QuotaManager prior to the QuotaManger being used. We do them
@@ -104,7 +116,7 @@ StoragePartitionImpl* StoragePartitionImpl::Create(
// that utilizes the QuotaManager.
scoped_refptr<quota::QuotaManager> quota_manager =
new quota::QuotaManager(
- context->IsOffTheRecord(), partition_path,
+ partition_descriptor.in_memory, partition_path,
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB),
context->GetSpecialStoragePolicy());
@@ -112,17 +124,17 @@ StoragePartitionImpl* StoragePartitionImpl::Create(
// Each consumer is responsible for registering its QuotaClient during
// its construction.
scoped_refptr<fileapi::FileSystemContext> filesystem_context =
- CreateFileSystemContext(partition_path, context->IsOffTheRecord(),
+ CreateFileSystemContext(partition_path, partition_descriptor.in_memory,
context->GetSpecialStoragePolicy(),
quota_manager->proxy());
scoped_refptr<webkit_database::DatabaseTracker> database_tracker =
new webkit_database::DatabaseTracker(
- partition_path, context->IsOffTheRecord(),
+ partition_path, partition_descriptor.in_memory,
context->GetSpecialStoragePolicy(), quota_manager->proxy(),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
- FilePath path = context->IsOffTheRecord() ? FilePath() : partition_path;
+ FilePath path = partition_descriptor.in_memory ? FilePath() : partition_path;
scoped_refptr<DOMStorageContextImpl> dom_storage_context =
new DOMStorageContextImpl(path, context->GetSpecialStoragePolicy());

Powered by Google App Engine
This is Rietveld 408576698