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/public/browser/browser_context.h" | 5 #include "content/public/browser/browser_context.h" |
6 | 6 |
7 #if !defined(OS_IOS) | 7 #if !defined(OS_IOS) |
8 #include "content/browser/download/download_manager_impl.h" | 8 #include "content/browser/download/download_manager_impl.h" |
9 #include "content/browser/fileapi/chrome_blob_storage_context.h" | 9 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
10 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 10 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 using base::UserDataAdapter; | 29 using base::UserDataAdapter; |
30 | 30 |
31 namespace content { | 31 namespace content { |
32 | 32 |
33 // Only ~BrowserContext() is needed on iOS. | 33 // Only ~BrowserContext() is needed on iOS. |
34 #if !defined(OS_IOS) | 34 #if !defined(OS_IOS) |
35 namespace { | 35 namespace { |
36 | 36 |
37 // Key names on BrowserContext. | 37 // Key names on BrowserContext. |
38 const char kDownloadManagerKeyName[] = "download_manager"; | 38 const char kDownloadManagerKeyName[] = "download_manager"; |
39 const char kStorageParitionMapKeyName[] = "content_storage_partition_map"; | 39 const char kStoragePartitionMapKeyName[] = "content_storage_partition_map"; |
40 | 40 |
41 #if defined(OS_CHROMEOS) | 41 #if defined(OS_CHROMEOS) |
42 const char kMountPointsKey[] = "mount_points"; | 42 const char kMountPointsKey[] = "mount_points"; |
43 #endif // defined(OS_CHROMEOS) | 43 #endif // defined(OS_CHROMEOS) |
44 | 44 |
45 StoragePartitionImplMap* GetStoragePartitionMap( | 45 StoragePartitionImplMap* GetStoragePartitionMap( |
46 BrowserContext* browser_context) { | 46 BrowserContext* browser_context) { |
47 StoragePartitionImplMap* partition_map = | 47 StoragePartitionImplMap* partition_map = |
48 static_cast<StoragePartitionImplMap*>( | 48 static_cast<StoragePartitionImplMap*>( |
49 browser_context->GetUserData(kStorageParitionMapKeyName)); | 49 browser_context->GetUserData(kStoragePartitionMapKeyName)); |
50 if (!partition_map) { | 50 if (!partition_map) { |
51 partition_map = new StoragePartitionImplMap(browser_context); | 51 partition_map = new StoragePartitionImplMap(browser_context); |
52 browser_context->SetUserData(kStorageParitionMapKeyName, partition_map); | 52 browser_context->SetUserData(kStoragePartitionMapKeyName, partition_map); |
53 } | 53 } |
54 return partition_map; | 54 return partition_map; |
55 } | 55 } |
56 | 56 |
57 StoragePartition* GetStoragePartitionFromConfig( | 57 StoragePartition* GetStoragePartitionFromConfig( |
58 BrowserContext* browser_context, | 58 BrowserContext* browser_context, |
59 const std::string& partition_domain, | 59 const std::string& partition_domain, |
60 const std::string& partition_name, | 60 const std::string& partition_name, |
61 bool in_memory) { | 61 bool in_memory) { |
62 StoragePartitionImplMap* partition_map = | 62 StoragePartitionImplMap* partition_map = |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 192 |
193 return GetStoragePartitionFromConfig( | 193 return GetStoragePartitionFromConfig( |
194 browser_context, partition_domain, partition_name, in_memory); | 194 browser_context, partition_domain, partition_name, in_memory); |
195 } | 195 } |
196 | 196 |
197 void BrowserContext::ForEachStoragePartition( | 197 void BrowserContext::ForEachStoragePartition( |
198 BrowserContext* browser_context, | 198 BrowserContext* browser_context, |
199 const StoragePartitionCallback& callback) { | 199 const StoragePartitionCallback& callback) { |
200 StoragePartitionImplMap* partition_map = | 200 StoragePartitionImplMap* partition_map = |
201 static_cast<StoragePartitionImplMap*>( | 201 static_cast<StoragePartitionImplMap*>( |
202 browser_context->GetUserData(kStorageParitionMapKeyName)); | 202 browser_context->GetUserData(kStoragePartitionMapKeyName)); |
203 if (!partition_map) | 203 if (!partition_map) |
204 return; | 204 return; |
205 | 205 |
206 partition_map->ForEach(callback); | 206 partition_map->ForEach(callback); |
207 } | 207 } |
208 | 208 |
209 StoragePartition* BrowserContext::GetDefaultStoragePartition( | 209 StoragePartition* BrowserContext::GetDefaultStoragePartition( |
210 BrowserContext* browser_context) { | 210 BrowserContext* browser_context) { |
211 return GetStoragePartition(browser_context, NULL); | 211 return GetStoragePartition(browser_context, NULL); |
212 } | 212 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 #endif // !OS_IOS | 321 #endif // !OS_IOS |
322 | 322 |
323 BrowserContext::~BrowserContext() { | 323 BrowserContext::~BrowserContext() { |
324 #if !defined(OS_IOS) | 324 #if !defined(OS_IOS) |
325 if (GetUserData(kDownloadManagerKeyName)) | 325 if (GetUserData(kDownloadManagerKeyName)) |
326 GetDownloadManager(this)->Shutdown(); | 326 GetDownloadManager(this)->Shutdown(); |
327 #endif | 327 #endif |
328 } | 328 } |
329 | 329 |
330 } // namespace content | 330 } // namespace content |
OLD | NEW |