OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/storage_partition_impl_map.h" | 5 #include "content/browser/storage_partition_impl_map.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 197 } |
198 | 198 |
199 StoragePartitionImpl* StoragePartitionImplMap::Get( | 199 StoragePartitionImpl* StoragePartitionImplMap::Get( |
200 const std::string& partition_id) { | 200 const std::string& partition_id) { |
201 // Find the previously created partition if it's available. | 201 // Find the previously created partition if it's available. |
202 std::map<std::string, StoragePartitionImpl*>::const_iterator it = | 202 std::map<std::string, StoragePartitionImpl*>::const_iterator it = |
203 partitions_.find(partition_id); | 203 partitions_.find(partition_id); |
204 if (it != partitions_.end()) | 204 if (it != partitions_.end()) |
205 return it->second; | 205 return it->second; |
206 | 206 |
207 // There was no previous partition, so let's make a new one. | 207 // There was no previous partition, so let's make a new one. The storage |
| 208 // partition should be in memory for guest processes and OTR profiles. |
| 209 bool in_memory = browser_context_->IsOffTheRecord() || |
| 210 StartsWithASCII(partition_id, "guest-", true); |
| 211 |
208 StoragePartitionImpl* partition = | 212 StoragePartitionImpl* partition = |
209 StoragePartitionImpl::Create(browser_context_, partition_id, | 213 StoragePartitionImpl::Create(browser_context_, partition_id, |
210 browser_context_->GetPath()); | 214 browser_context_->GetPath(), |
| 215 in_memory); |
211 partitions_[partition_id] = partition; | 216 partitions_[partition_id] = partition; |
212 | 217 |
213 // These calls must happen after StoragePartitionImpl::Create(). | 218 // These calls must happen after StoragePartitionImpl::Create(). |
214 partition->SetURLRequestContext( | 219 partition->SetURLRequestContext( |
215 partition_id.empty() ? | 220 partition_id.empty() ? |
216 browser_context_->GetRequestContext() : | 221 browser_context_->GetRequestContext() : |
217 browser_context_->GetRequestContextForStoragePartition(partition_id)); | 222 browser_context_->GetRequestContextForStoragePartition(partition_id)); |
218 partition->SetMediaURLRequestContext( | 223 partition->SetMediaURLRequestContext( |
219 partition_id.empty() ? | 224 partition_id.empty() ? |
220 browser_context_->GetMediaRequestContext() : | 225 browser_context_->GetMediaRequestContext() : |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 277 |
273 // We do not call InitializeURLRequestContext() for media contexts because, | 278 // We do not call InitializeURLRequestContext() for media contexts because, |
274 // other than the HTTP cache, the media contexts share the same backing | 279 // other than the HTTP cache, the media contexts share the same backing |
275 // objects as their associated "normal" request context. Thus, the previous | 280 // objects as their associated "normal" request context. Thus, the previous |
276 // call serves to initialize the media request context for this storage | 281 // call serves to initialize the media request context for this storage |
277 // partition as well. | 282 // partition as well. |
278 } | 283 } |
279 } | 284 } |
280 | 285 |
281 } // namespace content | 286 } // namespace content |
OLD | NEW |