| 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 #include "content/browser/appcache/chrome_appcache_service.h" | 7 #include "content/browser/appcache/chrome_appcache_service.h" |
| 8 #include "webkit/database/database_tracker.h" | |
| 9 #include "content/browser/dom_storage/dom_storage_context_impl.h" | 8 #include "content/browser/dom_storage/dom_storage_context_impl.h" |
| 10 #include "content/browser/download/download_file_manager.h" | 9 #include "content/browser/download/download_file_factory.h" |
| 10 #include "content/browser/download/download_item_factory.h" |
| 11 #include "content/browser/download/download_manager_impl.h" | 11 #include "content/browser/download/download_manager_impl.h" |
| 12 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" | 12 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" |
| 13 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" | 13 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" |
| 14 #include "content/public/browser/resource_context.h" | |
| 15 #include "content/browser/storage_partition_impl.h" | 14 #include "content/browser/storage_partition_impl.h" |
| 16 #include "content/browser/storage_partition_impl_map.h" | 15 #include "content/browser/storage_partition_impl_map.h" |
| 17 #include "content/common/child_process_host_impl.h" | 16 #include "content/common/child_process_host_impl.h" |
| 18 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/content_browser_client.h" | 18 #include "content/public/browser/content_browser_client.h" |
| 19 #include "content/public/browser/resource_context.h" |
| 20 #include "net/base/server_bound_cert_service.h" | 20 #include "net/base/server_bound_cert_service.h" |
| 21 #include "net/base/server_bound_cert_store.h" | 21 #include "net/base/server_bound_cert_store.h" |
| 22 #include "net/cookies/cookie_monster.h" | 22 #include "net/cookies/cookie_monster.h" |
| 23 #include "net/cookies/cookie_store.h" | 23 #include "net/cookies/cookie_store.h" |
| 24 #include "net/url_request/url_request_context.h" | 24 #include "net/url_request/url_request_context.h" |
| 25 #include "net/url_request/url_request_context_getter.h" | 25 #include "net/url_request/url_request_context_getter.h" |
| 26 #include "webkit/database/database_tracker.h" |
| 26 | 27 |
| 27 using base::UserDataAdapter; | 28 using base::UserDataAdapter; |
| 28 | 29 |
| 29 // Key names on BrowserContext. | 30 // Key names on BrowserContext. |
| 30 static const char* kDownloadManagerKeyName = "download_manager"; | 31 static const char* kDownloadManagerKeyName = "download_manager"; |
| 31 static const char* kStorageParitionMapKeyName = "content_storage_partition_map"; | 32 static const char* kStorageParitionMapKeyName = "content_storage_partition_map"; |
| 32 | 33 |
| 33 namespace content { | 34 namespace content { |
| 34 | 35 |
| 35 namespace { | 36 namespace { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 } | 77 } |
| 77 | 78 |
| 78 } // namespace | 79 } // namespace |
| 79 | 80 |
| 80 DownloadManager* BrowserContext::GetDownloadManager( | 81 DownloadManager* BrowserContext::GetDownloadManager( |
| 81 BrowserContext* context) { | 82 BrowserContext* context) { |
| 82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 83 if (!context->GetUserData(kDownloadManagerKeyName)) { | 84 if (!context->GetUserData(kDownloadManagerKeyName)) { |
| 84 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); | 85 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
| 85 DCHECK(rdh); | 86 DCHECK(rdh); |
| 86 DownloadFileManager* file_manager = rdh->download_file_manager(); | |
| 87 DCHECK(file_manager); | |
| 88 scoped_refptr<DownloadManager> download_manager = | 87 scoped_refptr<DownloadManager> download_manager = |
| 89 new DownloadManagerImpl( | 88 new DownloadManagerImpl( |
| 90 file_manager, | |
| 91 scoped_ptr<DownloadItemFactory>(), | 89 scoped_ptr<DownloadItemFactory>(), |
| 90 scoped_ptr<DownloadFileFactory>(), |
| 92 GetContentClient()->browser()->GetNetLog()); | 91 GetContentClient()->browser()->GetNetLog()); |
| 93 | 92 |
| 94 context->SetUserData( | 93 context->SetUserData( |
| 95 kDownloadManagerKeyName, | 94 kDownloadManagerKeyName, |
| 96 new UserDataAdapter<DownloadManager>(download_manager)); | 95 new UserDataAdapter<DownloadManager>(download_manager)); |
| 97 download_manager->SetDelegate(context->GetDownloadManagerDelegate()); | 96 download_manager->SetDelegate(context->GetDownloadManagerDelegate()); |
| 98 download_manager->Init(context); | 97 download_manager->Init(context); |
| 99 } | 98 } |
| 100 | 99 |
| 101 return UserDataAdapter<DownloadManager>::Get( | 100 return UserDataAdapter<DownloadManager>::Get( |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 ForEachStoragePartition(browser_context, | 215 ForEachStoragePartition(browser_context, |
| 217 base::Bind(&PurgeDOMStorageContextInPartition)); | 216 base::Bind(&PurgeDOMStorageContextInPartition)); |
| 218 } | 217 } |
| 219 | 218 |
| 220 BrowserContext::~BrowserContext() { | 219 BrowserContext::~BrowserContext() { |
| 221 if (GetUserData(kDownloadManagerKeyName)) | 220 if (GetUserData(kDownloadManagerKeyName)) |
| 222 GetDownloadManager(this)->Shutdown(); | 221 GetDownloadManager(this)->Shutdown(); |
| 223 } | 222 } |
| 224 | 223 |
| 225 } // namespace content | 224 } // namespace content |
| OLD | NEW |