Chromium Code Reviews| 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..ac8ccc2a4de43ec30dce297c8a32f9081ae13721 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,61 @@ StoragePartitionImplMap::~StoragePartitionImplMap() { |
| } |
| StoragePartitionImpl* StoragePartitionImplMap::Get( |
| - const std::string& partition_id) { |
| + const std::string& partition_domain, |
| + const std::string& partition_name, |
| + const bool& in_memory) { |
| + if (!resource_context_initialized_) { |
|
awong
2012/11/02 21:56:13
If you're planning on moving out this, add TODO?
nasko
2012/11/03 00:36:24
Meant to keep the original TODO. Thanks for the ca
|
| + resource_context_initialized_ = true; |
| + InitializeResourceContext(browser_context_); |
| + } |
| + |
| + bool in_memory_only = false; |
|
awong
2012/11/02 21:56:13
why not:
bool in_memory_only = in_memory || brows
nasko
2012/11/03 00:36:24
Done.
|
| + if (in_memory || browser_context_->IsOffTheRecord()) |
| + in_memory_only = true; |
| + |
| + // TODO(nasko): Webview tags with named partitions will have both |
| + // partition_domain and partition_name set. In this case, mark them in-memory |
| + // until the on-disk storage code has landed. |
| + if (!partition_domain.empty() && !partition_name.empty()) |
|
awong
2012/11/02 21:56:13
Maybe move this into the calling function?
That w
nasko
2012/11/03 00:36:24
The caller of this is BrowserContext. Since the ch
awong
2012/11/05 18:00:33
But this way the API is more complicated because t
awong
2012/11/05 20:11:18
For instance, doesn't content browser client ultim
nasko
2012/11/05 23:06:58
This is temporary until you fix the on-disk code,
|
| + in_memory_only = true; |
| + |
| // 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); |
| } |
| } |