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); |
} |
} |