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

Unified Diff: content/browser/storage_partition_impl_map.cc

Issue 11234032: Webview tag creation should be using storage partitions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More fixes on Albert's comments. 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_map.cc
diff --git a/content/browser/storage_partition_impl_map.cc b/content/browser/storage_partition_impl_map.cc
index 89f39e5a408d83fe9fe728f0eaa48b5f8ca4e6f2..270eeab0ca6831783ccb64928bc1eebba4d8892d 100644
--- a/content/browser/storage_partition_impl_map.cc
+++ b/content/browser/storage_partition_impl_map.cc
@@ -187,7 +187,8 @@ void InitializeURLRequestContext(
StoragePartitionImplMap::StoragePartitionImplMap(
BrowserContext* browser_context)
- : browser_context_(browser_context) {
+ : browser_context_(browser_context),
+ resource_context_initialized_(false) {
}
StoragePartitionImplMap::~StoragePartitionImplMap() {
@@ -196,51 +197,57 @@ StoragePartitionImplMap::~StoragePartitionImplMap() {
}
StoragePartitionImpl* StoragePartitionImplMap::Get(
- const std::string& partition_id) {
+ const std::string& partition_domain,
+ const std::string& partition_name,
+ bool in_memory) {
+ // TODO(ajwong): ResourceContexts no longer have any storage related state.
+ // We should move this into a place where it is called once per
+ // BrowserContext creation rather than piggybacking off the default context
+ // creation.
+ if (!resource_context_initialized_) {
+ resource_context_initialized_ = true;
+ InitializeResourceContext(browser_context_);
+ }
+
+ bool in_memory_only = in_memory || browser_context_->IsOffTheRecord();
awong 2012/11/05 23:48:37 I would move this out too...
nasko 2012/11/06 01:21:52 Done.
+
// Find the previously created partition if it's available.
- std::map<std::string, StoragePartitionImpl*>::const_iterator it =
- partitions_.find(partition_id);
+ StoragePartitionImpl::StoragePartitionDescriptor partition_descriptor(
+ partition_domain, partition_name, in_memory_only);
+
+ PartitionsMap::const_iterator it = partitions_.find(partition_descriptor);
if (it != partitions_.end())
return it->second;
// There was no previous partition, so let's make a new one.
StoragePartitionImpl* partition =
- StoragePartitionImpl::Create(browser_context_, partition_id,
+ StoragePartitionImpl::Create(browser_context_, partition_descriptor,
browser_context_->GetPath());
- partitions_[partition_id] = partition;
+ partitions_[partition_descriptor] = partition;
// These calls must happen after StoragePartitionImpl::Create().
partition->SetURLRequestContext(
- partition_id.empty() ?
+ partition_domain.empty() ?
browser_context_->GetRequestContext() :
browser_context_->GetRequestContextForStoragePartition(
- partition->GetPath(), false));
+ partition->GetPath(), in_memory_only));
partition->SetMediaURLRequestContext(
- partition_id.empty() ?
+ partition_domain.empty() ?
browser_context_->GetMediaRequestContext() :
browser_context_->GetMediaRequestContextForStoragePartition(
- partition->GetPath(), false));
+ partition->GetPath(), in_memory_only));
PostCreateInitialization(partition);
- // TODO(ajwong): ResourceContexts no longer have any storage related state.
- // We should move this into a place where it is called once per
- // BrowserContext creation rather than piggybacking off the default context
- // creation.
- if (partition_id.empty()) {
- InitializeResourceContext(browser_context_);
- }
-
return partition;
}
void StoragePartitionImplMap::ForEach(
const BrowserContext::StoragePartitionCallback& callback) {
- for (std::map<std::string, StoragePartitionImpl*>::const_iterator it =
- partitions_.begin();
+ for (PartitionsMap::const_iterator it = partitions_.begin();
it != partitions_.end();
++it) {
- callback.Run(it->first, it->second);
+ callback.Run(it->second);
}
}

Powered by Google App Engine
This is Rietveld 408576698