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 | |
41 #if defined(OS_CHROMEOS) | |
42 const char kMountPointsKey[] = "mount_points"; | |
43 #endif // defined(OS_CHROMEOS) | |
44 | 40 |
45 StoragePartitionImplMap* GetStoragePartitionMap( | 41 StoragePartitionImplMap* GetStoragePartitionMap( |
46 BrowserContext* browser_context) { | 42 BrowserContext* browser_context) { |
47 StoragePartitionImplMap* partition_map = | 43 StoragePartitionImplMap* partition_map = |
48 static_cast<StoragePartitionImplMap*>( | 44 static_cast<StoragePartitionImplMap*>( |
49 browser_context->GetUserData(kStorageParitionMapKeyName)); | 45 browser_context->GetUserData(kStoragePartitionMapKeyName)); |
50 if (!partition_map) { | 46 if (!partition_map) { |
51 partition_map = new StoragePartitionImplMap(browser_context); | 47 partition_map = new StoragePartitionImplMap(browser_context); |
52 browser_context->SetUserData(kStorageParitionMapKeyName, partition_map); | 48 browser_context->SetUserData(kStoragePartitionMapKeyName, partition_map); |
53 } | 49 } |
54 return partition_map; | 50 return partition_map; |
55 } | 51 } |
56 | 52 |
57 StoragePartition* GetStoragePartitionFromConfig( | 53 StoragePartition* GetStoragePartitionFromConfig( |
58 BrowserContext* browser_context, | 54 BrowserContext* browser_context, |
59 const std::string& partition_domain, | 55 const std::string& partition_domain, |
60 const std::string& partition_name, | 56 const std::string& partition_name, |
61 bool in_memory) { | 57 bool in_memory) { |
62 StoragePartitionImplMap* partition_map = | 58 StoragePartitionImplMap* partition_map = |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 | 134 |
139 // static | 135 // static |
140 storage::ExternalMountPoints* BrowserContext::GetMountPoints( | 136 storage::ExternalMountPoints* BrowserContext::GetMountPoints( |
141 BrowserContext* context) { | 137 BrowserContext* context) { |
142 // Ensure that these methods are called on the UI thread, except for | 138 // Ensure that these methods are called on the UI thread, except for |
143 // unittests where a UI thread might not have been created. | 139 // unittests where a UI thread might not have been created. |
144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || | 140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
145 !BrowserThread::IsMessageLoopValid(BrowserThread::UI)); | 141 !BrowserThread::IsMessageLoopValid(BrowserThread::UI)); |
146 | 142 |
147 #if defined(OS_CHROMEOS) | 143 #if defined(OS_CHROMEOS) |
144 const char kMountPointsKey[] = "mount_points"; | |
davidben
2015/08/14 21:18:34
This miiiiight accidentally work, but only because
| |
148 if (!context->GetUserData(kMountPointsKey)) { | 145 if (!context->GetUserData(kMountPointsKey)) { |
149 scoped_refptr<storage::ExternalMountPoints> mount_points = | 146 scoped_refptr<storage::ExternalMountPoints> mount_points = |
150 storage::ExternalMountPoints::CreateRefCounted(); | 147 storage::ExternalMountPoints::CreateRefCounted(); |
151 context->SetUserData( | 148 context->SetUserData( |
152 kMountPointsKey, | 149 kMountPointsKey, |
153 new UserDataAdapter<storage::ExternalMountPoints>(mount_points.get())); | 150 new UserDataAdapter<storage::ExternalMountPoints>(mount_points.get())); |
154 } | 151 } |
155 | 152 |
156 return UserDataAdapter<storage::ExternalMountPoints>::Get(context, | 153 return UserDataAdapter<storage::ExternalMountPoints>::Get(context, |
157 kMountPointsKey); | 154 kMountPointsKey); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 | 189 |
193 return GetStoragePartitionFromConfig( | 190 return GetStoragePartitionFromConfig( |
194 browser_context, partition_domain, partition_name, in_memory); | 191 browser_context, partition_domain, partition_name, in_memory); |
195 } | 192 } |
196 | 193 |
197 void BrowserContext::ForEachStoragePartition( | 194 void BrowserContext::ForEachStoragePartition( |
198 BrowserContext* browser_context, | 195 BrowserContext* browser_context, |
199 const StoragePartitionCallback& callback) { | 196 const StoragePartitionCallback& callback) { |
200 StoragePartitionImplMap* partition_map = | 197 StoragePartitionImplMap* partition_map = |
201 static_cast<StoragePartitionImplMap*>( | 198 static_cast<StoragePartitionImplMap*>( |
202 browser_context->GetUserData(kStorageParitionMapKeyName)); | 199 browser_context->GetUserData(kStoragePartitionMapKeyName)); |
203 if (!partition_map) | 200 if (!partition_map) |
204 return; | 201 return; |
205 | 202 |
206 partition_map->ForEach(callback); | 203 partition_map->ForEach(callback); |
207 } | 204 } |
208 | 205 |
209 StoragePartition* BrowserContext::GetDefaultStoragePartition( | 206 StoragePartition* BrowserContext::GetDefaultStoragePartition( |
210 BrowserContext* browser_context) { | 207 BrowserContext* browser_context) { |
211 return GetStoragePartition(browser_context, NULL); | 208 return GetStoragePartition(browser_context, NULL); |
212 } | 209 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 #endif // !OS_IOS | 318 #endif // !OS_IOS |
322 | 319 |
323 BrowserContext::~BrowserContext() { | 320 BrowserContext::~BrowserContext() { |
324 #if !defined(OS_IOS) | 321 #if !defined(OS_IOS) |
325 if (GetUserData(kDownloadManagerKeyName)) | 322 if (GetUserData(kDownloadManagerKeyName)) |
326 GetDownloadManager(this)->Shutdown(); | 323 GetDownloadManager(this)->Shutdown(); |
327 #endif | 324 #endif |
328 } | 325 } |
329 | 326 |
330 } // namespace content | 327 } // namespace content |
OLD | NEW |