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

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

Issue 10344024: Rewrite download manager unit to be actual unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync'd to LKGR. Created 8 years, 6 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
« no previous file with comments | « no previous file | content/browser/download/download_item_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "content/browser/appcache/chrome_appcache_service.h" 7 #include "content/browser/appcache/chrome_appcache_service.h"
8 #include "content/browser/dom_storage/dom_storage_context_impl.h" 8 #include "content/browser/dom_storage/dom_storage_context_impl.h"
9 #include "content/browser/download/download_file_manager.h"
9 #include "content/browser/download/download_manager_impl.h" 10 #include "content/browser/download/download_manager_impl.h"
10 #include "content/browser/fileapi/browser_file_system_helper.h" 11 #include "content/browser/fileapi/browser_file_system_helper.h"
11 #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"
12 #include "content/browser/resource_context_impl.h" 14 #include "content/browser/resource_context_impl.h"
13 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/content_browser_client.h" 16 #include "content/public/browser/content_browser_client.h"
15 #include "content/public/common/content_constants.h" 17 #include "content/public/common/content_constants.h"
16 #include "net/base/server_bound_cert_service.h" 18 #include "net/base/server_bound_cert_service.h"
17 #include "net/base/server_bound_cert_store.h" 19 #include "net/base/server_bound_cert_store.h"
18 #include "net/cookies/cookie_monster.h" 20 #include "net/cookies/cookie_monster.h"
19 #include "net/cookies/cookie_store.h" 21 #include "net/cookies/cookie_store.h"
20 #include "net/url_request/url_request_context.h" 22 #include "net/url_request/url_request_context.h"
21 #include "webkit/database/database_tracker.h" 23 #include "webkit/database/database_tracker.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 context->GetPath(), context->IsOffTheRecord(), 70 context->GetPath(), context->IsOffTheRecord(),
69 context->GetSpecialStoragePolicy(), quota_manager->proxy()); 71 context->GetSpecialStoragePolicy(), quota_manager->proxy());
70 context->SetUserData( 72 context->SetUserData(
71 kFileSystemContextKeyName, 73 kFileSystemContextKeyName,
72 new UserDataAdapter<FileSystemContext>(filesystem_context)); 74 new UserDataAdapter<FileSystemContext>(filesystem_context));
73 75
74 scoped_refptr<DatabaseTracker> db_tracker = new DatabaseTracker( 76 scoped_refptr<DatabaseTracker> db_tracker = new DatabaseTracker(
75 context->GetPath(), context->IsOffTheRecord(), 77 context->GetPath(), context->IsOffTheRecord(),
76 context->GetSpecialStoragePolicy(), quota_manager->proxy(), 78 context->GetSpecialStoragePolicy(), quota_manager->proxy(),
77 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); 79 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
78 context->SetUserData(kDatabaseTrackerKeyName, 80 context->SetUserData(kDatabaseTrackerKeyName,
79 new UserDataAdapter<DatabaseTracker>(db_tracker)); 81 new UserDataAdapter<DatabaseTracker>(db_tracker));
80 82
81 FilePath path = context->IsOffTheRecord() ? FilePath() : context->GetPath(); 83 FilePath path = context->IsOffTheRecord() ? FilePath() : context->GetPath();
82 scoped_refptr<DOMStorageContextImpl> dom_storage_context = 84 scoped_refptr<DOMStorageContextImpl> dom_storage_context =
83 new DOMStorageContextImpl(path, context->GetSpecialStoragePolicy()); 85 new DOMStorageContextImpl(path, context->GetSpecialStoragePolicy());
84 context->SetUserData( 86 context->SetUserData(
85 kDOMStorageContextKeyName, 87 kDOMStorageContextKeyName,
86 new UserDataAdapter<DOMStorageContextImpl>(dom_storage_context)); 88 new UserDataAdapter<DOMStorageContextImpl>(dom_storage_context));
87 89
88 scoped_refptr<IndexedDBContext> indexed_db_context = new IndexedDBContextImpl( 90 scoped_refptr<IndexedDBContext> indexed_db_context = new IndexedDBContextImpl(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 DOMStorageContextImpl* GetDOMStorageContextImpl(BrowserContext* context) { 137 DOMStorageContextImpl* GetDOMStorageContextImpl(BrowserContext* context) {
136 return static_cast<DOMStorageContextImpl*>( 138 return static_cast<DOMStorageContextImpl*>(
137 BrowserContext::GetDOMStorageContext(context)); 139 BrowserContext::GetDOMStorageContext(context));
138 } 140 }
139 141
140 } // namespace 142 } // namespace
141 143
142 DownloadManager* BrowserContext::GetDownloadManager( 144 DownloadManager* BrowserContext::GetDownloadManager(
143 BrowserContext* context) { 145 BrowserContext* context) {
144 if (!context->GetUserData(kDownloadManagerKeyName)) { 146 if (!context->GetUserData(kDownloadManagerKeyName)) {
145 scoped_refptr<DownloadManager> download_manager = new DownloadManagerImpl( 147 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get();
146 GetContentClient()->browser()->GetNetLog()); 148 DCHECK(rdh);
149 DownloadFileManager* file_manager = rdh->download_file_manager();
150 DCHECK(file_manager);
151 scoped_refptr<DownloadManager> download_manager =
152 new DownloadManagerImpl(
153 file_manager,
154 scoped_ptr<DownloadItemFactory>(),
155 GetContentClient()->browser()->GetNetLog());
156
147 context->SetUserData( 157 context->SetUserData(
148 kDownloadManagerKeyName, 158 kDownloadManagerKeyName,
149 new UserDataAdapter<DownloadManager>(download_manager)); 159 new UserDataAdapter<DownloadManager>(download_manager));
150 download_manager->SetDelegate(context->GetDownloadManagerDelegate()); 160 download_manager->SetDelegate(context->GetDownloadManagerDelegate());
151 download_manager->Init(context); 161 download_manager->Init(context);
152 } 162 }
153 163
154 return UserDataAdapter<DownloadManager>::Get( 164 return UserDataAdapter<DownloadManager>::Get(
155 context, kDownloadManagerKeyName); 165 context, kDownloadManagerKeyName);
156 } 166 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 257 }
248 258
249 if (GetUserData(kDOMStorageContextKeyName)) 259 if (GetUserData(kDOMStorageContextKeyName))
250 GetDOMStorageContextImpl(this)->Shutdown(); 260 GetDOMStorageContextImpl(this)->Shutdown();
251 261
252 if (GetUserData(kDownloadManagerKeyName)) 262 if (GetUserData(kDownloadManagerKeyName))
253 GetDownloadManager(this)->Shutdown(); 263 GetDownloadManager(this)->Shutdown();
254 } 264 }
255 265
256 } // namespace content 266 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/download/download_item_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698