Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2033)

Side by Side Diff: content/browser/browser_context.cc

Issue 10912173: Replace the DownloadFileManager with direct ownership of DownloadFileImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync'd to LKGR. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/appcache/chrome_appcache_service.h" 8 #include "content/browser/appcache/chrome_appcache_service.h"
9 #include "webkit/database/database_tracker.h"
10 #include "content/browser/dom_storage/dom_storage_context_impl.h" 9 #include "content/browser/dom_storage/dom_storage_context_impl.h"
11 #include "content/browser/download/download_file_manager.h" 10 #include "content/browser/download/download_file_factory.h"
11 #include "content/browser/download/download_item_factory.h"
12 #include "content/browser/download/download_manager_impl.h" 12 #include "content/browser/download/download_manager_impl.h"
13 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" 13 #include "content/browser/in_process_webkit/indexed_db_context_impl.h"
14 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" 14 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
15 #include "content/public/browser/resource_context.h"
16 #include "content/public/browser/site_instance.h" 15 #include "content/public/browser/site_instance.h"
17 #include "content/browser/storage_partition_impl.h" 16 #include "content/browser/storage_partition_impl.h"
18 #include "content/browser/storage_partition_impl_map.h" 17 #include "content/browser/storage_partition_impl_map.h"
19 #include "content/common/child_process_host_impl.h" 18 #include "content/common/child_process_host_impl.h"
20 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/content_browser_client.h" 20 #include "content/public/browser/content_browser_client.h"
22 #include "net/base/server_bound_cert_service.h" 21 #include "net/base/server_bound_cert_service.h"
23 #include "net/base/server_bound_cert_store.h" 22 #include "net/base/server_bound_cert_store.h"
24 #include "net/cookies/cookie_monster.h" 23 #include "net/cookies/cookie_monster.h"
25 #include "net/cookies/cookie_store.h" 24 #include "net/cookies/cookie_store.h"
26 #include "net/url_request/url_request_context.h" 25 #include "net/url_request/url_request_context.h"
27 #include "net/url_request/url_request_context_getter.h" 26 #include "net/url_request/url_request_context_getter.h"
27 #include "webkit/database/database_tracker.h"
28 #endif // !OS_IOS 28 #endif // !OS_IOS
29 29
30 using base::UserDataAdapter; 30 using base::UserDataAdapter;
31 31
32 namespace content { 32 namespace content {
33 33
34 // Only ~BrowserContext() is needed on iOS. 34 // Only ~BrowserContext() is needed on iOS.
35 #if !defined(OS_IOS) 35 #if !defined(OS_IOS)
36 namespace { 36 namespace {
37 37
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 81 }
82 82
83 } // namespace 83 } // namespace
84 84
85 DownloadManager* BrowserContext::GetDownloadManager( 85 DownloadManager* BrowserContext::GetDownloadManager(
86 BrowserContext* context) { 86 BrowserContext* context) {
87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
88 if (!context->GetUserData(kDownloadManagerKeyName)) { 88 if (!context->GetUserData(kDownloadManagerKeyName)) {
89 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); 89 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get();
90 DCHECK(rdh); 90 DCHECK(rdh);
91 DownloadFileManager* file_manager = rdh->download_file_manager();
92 DCHECK(file_manager);
93 scoped_refptr<DownloadManager> download_manager = 91 scoped_refptr<DownloadManager> download_manager =
94 new DownloadManagerImpl( 92 new DownloadManagerImpl(
95 file_manager,
96 scoped_ptr<DownloadItemFactory>(), 93 scoped_ptr<DownloadItemFactory>(),
benjhayden 2012/09/24 17:43:27 Would it make more sense to not pass the factories
Randy Smith (Not in Mondays) 2012/09/26 21:01:05 Yeah, I think this makes sense. Done.
94 scoped_ptr<DownloadFileFactory>(),
97 GetContentClient()->browser()->GetNetLog()); 95 GetContentClient()->browser()->GetNetLog());
98 96
99 context->SetUserData( 97 context->SetUserData(
100 kDownloadManagerKeyName, 98 kDownloadManagerKeyName,
101 new UserDataAdapter<DownloadManager>(download_manager)); 99 new UserDataAdapter<DownloadManager>(download_manager));
102 download_manager->SetDelegate(context->GetDownloadManagerDelegate()); 100 download_manager->SetDelegate(context->GetDownloadManagerDelegate());
103 download_manager->Init(context); 101 download_manager->Init(context);
104 } 102 }
105 103
106 return UserDataAdapter<DownloadManager>::Get( 104 return UserDataAdapter<DownloadManager>::Get(
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 #endif // !OS_IOS 204 #endif // !OS_IOS
207 205
208 BrowserContext::~BrowserContext() { 206 BrowserContext::~BrowserContext() {
209 #if !defined(OS_IOS) 207 #if !defined(OS_IOS)
210 if (GetUserData(kDownloadManagerKeyName)) 208 if (GetUserData(kDownloadManagerKeyName))
211 GetDownloadManager(this)->Shutdown(); 209 GetDownloadManager(this)->Shutdown();
212 #endif 210 #endif
213 } 211 }
214 212
215 } // namespace content 213 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698