| 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 "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "content/browser/appcache/chrome_appcache_service.h" | 9 #include "content/browser/appcache/chrome_appcache_service.h" |
| 10 #include "content/browser/dom_storage/dom_storage_context_impl.h" | 10 #include "content/browser/dom_storage/dom_storage_context_impl.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 GetStoragePartitionMap(browser_context)->GarbageCollect( | 149 GetStoragePartitionMap(browser_context)->GarbageCollect( |
| 150 active_paths.Pass(), done); | 150 active_paths.Pass(), done); |
| 151 } | 151 } |
| 152 | 152 |
| 153 DownloadManager* BrowserContext::GetDownloadManager( | 153 DownloadManager* BrowserContext::GetDownloadManager( |
| 154 BrowserContext* context) { | 154 BrowserContext* context) { |
| 155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 156 if (!context->GetUserData(kDownloadManagerKeyName)) { | 156 if (!context->GetUserData(kDownloadManagerKeyName)) { |
| 157 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); | 157 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
| 158 DCHECK(rdh); | 158 DCHECK(rdh); |
| 159 scoped_refptr<DownloadManager> download_manager = | 159 DownloadManager* download_manager = |
| 160 new DownloadManagerImpl( | 160 new DownloadManagerImpl( |
| 161 GetContentClient()->browser()->GetNetLog(), context); | 161 GetContentClient()->browser()->GetNetLog(), context); |
| 162 | 162 |
| 163 context->SetUserData( | 163 context->SetUserData( |
| 164 kDownloadManagerKeyName, | 164 kDownloadManagerKeyName, |
| 165 new UserDataAdapter<DownloadManager>(download_manager)); | 165 download_manager); |
| 166 download_manager->SetDelegate(context->GetDownloadManagerDelegate()); | 166 download_manager->SetDelegate(context->GetDownloadManagerDelegate()); |
| 167 } | 167 } |
| 168 | 168 |
| 169 return UserDataAdapter<DownloadManager>::Get( | 169 return static_cast<DownloadManager*>( |
| 170 context, kDownloadManagerKeyName); | 170 context->GetUserData(kDownloadManagerKeyName)); |
| 171 } | 171 } |
| 172 | 172 |
| 173 // static | 173 // static |
| 174 fileapi::ExternalMountPoints* BrowserContext::GetMountPoints( | 174 fileapi::ExternalMountPoints* BrowserContext::GetMountPoints( |
| 175 BrowserContext* context) { | 175 BrowserContext* context) { |
| 176 // Ensure that these methods are called on the UI thread, except for | 176 // Ensure that these methods are called on the UI thread, except for |
| 177 // unittests where a UI thread might not have been created. | 177 // unittests where a UI thread might not have been created. |
| 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || | 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
| 179 !BrowserThread::IsMessageLoopValid(BrowserThread::UI)); | 179 !BrowserThread::IsMessageLoopValid(BrowserThread::UI)); |
| 180 | 180 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 #endif // !OS_IOS | 324 #endif // !OS_IOS |
| 325 | 325 |
| 326 BrowserContext::~BrowserContext() { | 326 BrowserContext::~BrowserContext() { |
| 327 #if !defined(OS_IOS) | 327 #if !defined(OS_IOS) |
| 328 if (GetUserData(kDownloadManagerKeyName)) | 328 if (GetUserData(kDownloadManagerKeyName)) |
| 329 GetDownloadManager(this)->Shutdown(); | 329 GetDownloadManager(this)->Shutdown(); |
| 330 #endif | 330 #endif |
| 331 } | 331 } |
| 332 | 332 |
| 333 } // namespace content | 333 } // namespace content |
| OLD | NEW |