Chromium Code Reviews| Index: content/browser/browser_context.cc |
| diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc |
| index 25ffaf2d835cb527c2b10d10cb43f773d4283433..90f9f03378a1542365340e7c3058930e34d4d016 100644 |
| --- a/content/browser/browser_context.cc |
| +++ b/content/browser/browser_context.cc |
| @@ -35,21 +35,22 @@ namespace content { |
| namespace { |
| // Key names on BrowserContext. |
| -const char kDownloadManagerKeyName[] = "download_manager"; |
| -const char kStorageParitionMapKeyName[] = "content_storage_partition_map"; |
| - |
| +const char *KeyNames[] { "download_manager", "content_storage_partition_map" |
|
davidben
2015/08/14 20:24:39
Style: * hugs the type
davidben
2015/08/14 20:24:39
Style: kKeyNames
|
| #if defined(OS_CHROMEOS) |
| -const char kMountPointsKey[] = "mount_points"; |
| + , "mount_points" |
|
davidben
2015/08/14 20:24:39
No reason to do the comma like this. Trailing comm
|
| #endif // defined(OS_CHROMEOS) |
| +}; |
| +enum KeyNameIndex { DOWNLOAD_MANAGER, STORAGE_PARTITION, MOUNT_POINTS }; |
| + |
| StoragePartitionImplMap* GetStoragePartitionMap( |
| BrowserContext* browser_context) { |
| StoragePartitionImplMap* partition_map = |
| static_cast<StoragePartitionImplMap*>( |
| - browser_context->GetUserData(kStorageParitionMapKeyName)); |
| + browser_context->GetUserData(KeyNames[STORAGE_PARTITION])); |
| if (!partition_map) { |
| partition_map = new StoragePartitionImplMap(browser_context); |
| - browser_context->SetUserData(kStorageParitionMapKeyName, partition_map); |
| + browser_context->SetUserData(KeyNames[STORAGE_PARTITION], partition_map); |
| } |
| return partition_map; |
| } |
| @@ -95,7 +96,7 @@ void SetDownloadManager(BrowserContext* context, |
| content::DownloadManager* download_manager) { |
| DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| DCHECK(download_manager); |
| - context->SetUserData(kDownloadManagerKeyName, download_manager); |
| + context->SetUserData(KeyNames[DOWNLOAD_MANAGER], download_manager); |
| } |
| } // namespace |
| @@ -121,7 +122,7 @@ void BrowserContext::GarbageCollectStoragePartitions( |
| DownloadManager* BrowserContext::GetDownloadManager( |
| BrowserContext* context) { |
| DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| - if (!context->GetUserData(kDownloadManagerKeyName)) { |
| + if (!context->GetUserData(KeyNames[DOWNLOAD_MANAGER])) { |
| ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
| DCHECK(rdh); |
| DownloadManager* download_manager = |
| @@ -133,7 +134,7 @@ DownloadManager* BrowserContext::GetDownloadManager( |
| } |
| return static_cast<DownloadManager*>( |
| - context->GetUserData(kDownloadManagerKeyName)); |
| + context->GetUserData(KeyNames[DOWNLOAD_MANAGER])); |
| } |
| // static |
| @@ -145,16 +146,16 @@ storage::ExternalMountPoints* BrowserContext::GetMountPoints( |
| !BrowserThread::IsMessageLoopValid(BrowserThread::UI)); |
| #if defined(OS_CHROMEOS) |
| - if (!context->GetUserData(kMountPointsKey)) { |
| + if (!context->GetUserData(KeyNames[MOUNT_POINTS])) { |
| scoped_refptr<storage::ExternalMountPoints> mount_points = |
| storage::ExternalMountPoints::CreateRefCounted(); |
| context->SetUserData( |
| - kMountPointsKey, |
| + KeyNames[MOUNT_POINTS], |
| new UserDataAdapter<storage::ExternalMountPoints>(mount_points.get())); |
| } |
| return UserDataAdapter<storage::ExternalMountPoints>::Get(context, |
| - kMountPointsKey); |
| + KeyNames[MOUNT_POINTS]); |
|
davidben
2015/08/14 20:24:39
Style: 80 column limit.
|
| #else |
| return NULL; |
| #endif |
| @@ -199,7 +200,7 @@ void BrowserContext::ForEachStoragePartition( |
| const StoragePartitionCallback& callback) { |
| StoragePartitionImplMap* partition_map = |
| static_cast<StoragePartitionImplMap*>( |
| - browser_context->GetUserData(kStorageParitionMapKeyName)); |
| + browser_context->GetUserData(KeyNames[STORAGE_PARTITION])); |
| if (!partition_map) |
| return; |
| @@ -322,7 +323,7 @@ void BrowserContext::SetDownloadManagerForTesting( |
| BrowserContext::~BrowserContext() { |
| #if !defined(OS_IOS) |
| - if (GetUserData(kDownloadManagerKeyName)) |
| + if (GetUserData(KeyNames[DOWNLOAD_MANAGER])) |
| GetDownloadManager(this)->Shutdown(); |
| #endif |
| } |