| 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 "webkit/database/database_tracker.h" |
| 25 | 26 |
| 26 using base::UserDataAdapter; | 27 using base::UserDataAdapter; |
| 27 | 28 |
| 28 // Key names on BrowserContext. | 29 // Key names on BrowserContext. |
| 29 static const char* kDownloadManagerKeyName = "download_manager"; | 30 static const char* kDownloadManagerKeyName = "download_manager"; |
| 30 static const char* kStorageParitionMapKeyName = "content_storage_partition_map"; | 31 static const char* kStorageParitionMapKeyName = "content_storage_partition_map"; |
| 31 | 32 |
| 32 namespace content { | 33 namespace content { |
| 33 | 34 |
| 34 namespace { | 35 namespace { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 74 } |
| 74 | 75 |
| 75 } // namespace | 76 } // namespace |
| 76 | 77 |
| 77 DownloadManager* BrowserContext::GetDownloadManager( | 78 DownloadManager* BrowserContext::GetDownloadManager( |
| 78 BrowserContext* context) { | 79 BrowserContext* context) { |
| 79 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 80 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 80 if (!context->GetUserData(kDownloadManagerKeyName)) { | 81 if (!context->GetUserData(kDownloadManagerKeyName)) { |
| 81 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); | 82 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
| 82 DCHECK(rdh); | 83 DCHECK(rdh); |
| 83 DownloadFileManager* file_manager = rdh->download_file_manager(); | |
| 84 DCHECK(file_manager); | |
| 85 scoped_refptr<DownloadManager> download_manager = | 84 scoped_refptr<DownloadManager> download_manager = |
| 86 new DownloadManagerImpl( | 85 new DownloadManagerImpl( |
| 87 file_manager, | |
| 88 scoped_ptr<DownloadItemFactory>(), | 86 scoped_ptr<DownloadItemFactory>(), |
| 87 scoped_ptr<DownloadFileFactory>(), |
| 89 GetContentClient()->browser()->GetNetLog()); | 88 GetContentClient()->browser()->GetNetLog()); |
| 90 | 89 |
| 91 context->SetUserData( | 90 context->SetUserData( |
| 92 kDownloadManagerKeyName, | 91 kDownloadManagerKeyName, |
| 93 new UserDataAdapter<DownloadManager>(download_manager)); | 92 new UserDataAdapter<DownloadManager>(download_manager)); |
| 94 download_manager->SetDelegate(context->GetDownloadManagerDelegate()); | 93 download_manager->SetDelegate(context->GetDownloadManagerDelegate()); |
| 95 download_manager->Init(context); | 94 download_manager->Init(context); |
| 96 } | 95 } |
| 97 | 96 |
| 98 return UserDataAdapter<DownloadManager>::Get( | 97 return UserDataAdapter<DownloadManager>::Get( |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 ForEachStoragePartition(browser_context, | 207 ForEachStoragePartition(browser_context, |
| 209 base::Bind(&PurgeDOMStorageContextInPartition)); | 208 base::Bind(&PurgeDOMStorageContextInPartition)); |
| 210 } | 209 } |
| 211 | 210 |
| 212 BrowserContext::~BrowserContext() { | 211 BrowserContext::~BrowserContext() { |
| 213 if (GetUserData(kDownloadManagerKeyName)) | 212 if (GetUserData(kDownloadManagerKeyName)) |
| 214 GetDownloadManager(this)->Shutdown(); | 213 GetDownloadManager(this)->Shutdown(); |
| 215 } | 214 } |
| 216 | 215 |
| 217 } // namespace content | 216 } // namespace content |
| OLD | NEW |