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

Side by Side Diff: chrome/browser/profiles/profile_impl_io_data.cc

Issue 7493025: Instantiate OriginBoundCertService in relevant places and do plumbing to pass it down to HttpNetw... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/profiles/profile_impl_io_data.h" 5 #include "chrome/browser/profiles/profile_impl_io_data.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "chrome/browser/io_thread.h" 12 #include "chrome/browser/io_thread.h"
13 #include "chrome/browser/net/chrome_net_log.h" 13 #include "chrome/browser/net/chrome_net_log.h"
14 #include "chrome/browser/net/chrome_network_delegate.h" 14 #include "chrome/browser/net/chrome_network_delegate.h"
15 #include "chrome/browser/net/sqlite_origin_bound_cert_store.h"
15 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" 16 #include "chrome/browser/net/sqlite_persistent_cookie_store.h"
16 #include "chrome/browser/prefs/pref_member.h" 17 #include "chrome/browser/prefs/pref_member.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/common/chrome_constants.h" 19 #include "chrome/common/chrome_constants.h"
19 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
21 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
22 #include "content/browser/browser_thread.h" 23 #include "content/browser/browser_thread.h"
23 #include "content/browser/resource_context.h" 24 #include "content/browser/resource_context.h"
25 #include "net/base/origin_bound_cert_service.h"
24 #include "net/ftp/ftp_network_layer.h" 26 #include "net/ftp/ftp_network_layer.h"
25 #include "net/http/http_cache.h" 27 #include "net/http/http_cache.h"
26 28
27 ProfileImplIOData::Handle::Handle(Profile* profile) 29 ProfileImplIOData::Handle::Handle(Profile* profile)
28 : io_data_(new ProfileImplIOData), 30 : io_data_(new ProfileImplIOData),
29 profile_(profile), 31 profile_(profile),
30 initialized_(false) { 32 initialized_(false) {
31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
32 DCHECK(profile); 34 DCHECK(profile);
33 } 35 }
(...skipping 12 matching lines...) Expand all
46 app_request_context_getter_map_.begin(); 48 app_request_context_getter_map_.begin();
47 iter != app_request_context_getter_map_.end(); 49 iter != app_request_context_getter_map_.end();
48 ++iter) { 50 ++iter) {
49 iter->second->CleanupOnUIThread(); 51 iter->second->CleanupOnUIThread();
50 } 52 }
51 53
52 io_data_.release()->ShutdownOnUIThread(); 54 io_data_.release()->ShutdownOnUIThread();
53 } 55 }
54 56
55 void ProfileImplIOData::Handle::Init(const FilePath& cookie_path, 57 void ProfileImplIOData::Handle::Init(const FilePath& cookie_path,
58 const FilePath& origin_bound_cert_path,
56 const FilePath& cache_path, 59 const FilePath& cache_path,
57 int cache_max_size, 60 int cache_max_size,
58 const FilePath& media_cache_path, 61 const FilePath& media_cache_path,
59 int media_cache_max_size, 62 int media_cache_max_size,
60 const FilePath& extensions_cookie_path, 63 const FilePath& extensions_cookie_path,
61 const FilePath& app_path) { 64 const FilePath& app_path) {
62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
63 DCHECK(!io_data_->lazy_params_.get()); 66 DCHECK(!io_data_->lazy_params_.get());
64 LazyParams* lazy_params = new LazyParams; 67 LazyParams* lazy_params = new LazyParams;
65 68
66 lazy_params->cookie_path = cookie_path; 69 lazy_params->cookie_path = cookie_path;
70 lazy_params->origin_bound_cert_path = origin_bound_cert_path;
67 lazy_params->cache_path = cache_path; 71 lazy_params->cache_path = cache_path;
68 lazy_params->cache_max_size = cache_max_size; 72 lazy_params->cache_max_size = cache_max_size;
69 lazy_params->media_cache_path = media_cache_path; 73 lazy_params->media_cache_path = media_cache_path;
70 lazy_params->media_cache_max_size = media_cache_max_size; 74 lazy_params->media_cache_max_size = media_cache_max_size;
71 lazy_params->extensions_cookie_path = extensions_cookie_path; 75 lazy_params->extensions_cookie_path = extensions_cookie_path;
72 76
73 io_data_->lazy_params_.reset(lazy_params); 77 io_data_->lazy_params_.reset(lazy_params);
74 78
75 // Keep track of isolated app path separately so we can use it on demand. 79 // Keep track of isolated app path separately so we can use it on demand.
76 io_data_->app_path_ = app_path; 80 io_data_->app_path_ = app_path;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 io_thread_globals->http_auth_handler_factory.get()); 227 io_thread_globals->http_auth_handler_factory.get());
224 media_request_context_->set_http_auth_handler_factory( 228 media_request_context_->set_http_auth_handler_factory(
225 io_thread_globals->http_auth_handler_factory.get()); 229 io_thread_globals->http_auth_handler_factory.get());
226 230
227 main_context->set_dns_cert_checker(dns_cert_checker()); 231 main_context->set_dns_cert_checker(dns_cert_checker());
228 media_request_context_->set_dns_cert_checker(dns_cert_checker()); 232 media_request_context_->set_dns_cert_checker(dns_cert_checker());
229 233
230 main_context->set_proxy_service(proxy_service()); 234 main_context->set_proxy_service(proxy_service());
231 media_request_context_->set_proxy_service(proxy_service()); 235 media_request_context_->set_proxy_service(proxy_service());
232 236
233 net::HttpCache::DefaultBackend* main_backend =
234 new net::HttpCache::DefaultBackend(
235 net::DISK_CACHE,
236 lazy_params_->cache_path,
237 lazy_params_->cache_max_size,
238 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE));
239 net::HttpCache* main_cache = new net::HttpCache(
240 main_context->host_resolver(),
241 main_context->cert_verifier(),
242 main_context->dnsrr_resolver(),
243 main_context->dns_cert_checker(),
244 main_context->proxy_service(),
245 main_context->ssl_config_service(),
246 main_context->http_auth_handler_factory(),
247 main_context->network_delegate(),
248 main_context->net_log(),
249 main_backend);
250
251 net::HttpCache::DefaultBackend* media_backend =
252 new net::HttpCache::DefaultBackend(
253 net::MEDIA_CACHE, lazy_params_->media_cache_path,
254 lazy_params_->media_cache_max_size,
255 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE));
256 net::HttpNetworkSession* main_network_session = main_cache->GetSession();
257 net::HttpCache* media_cache =
258 new net::HttpCache(main_network_session, media_backend);
259
260 scoped_refptr<net::CookieStore> cookie_store = NULL; 237 scoped_refptr<net::CookieStore> cookie_store = NULL;
261 if (record_mode || playback_mode) { 238 if (record_mode || playback_mode) {
262 // Don't use existing cookies and use an in-memory store. 239 // Don't use existing cookies and use an in-memory store.
263 cookie_store = new net::CookieMonster( 240 cookie_store = new net::CookieMonster(
264 NULL, profile_params->cookie_monster_delegate); 241 NULL, profile_params->cookie_monster_delegate);
265 main_cache->set_mode( 242 // Don't use existing origin-bound certs and use an in-memory store.
266 record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); 243 set_origin_bound_cert_service(new net::OriginBoundCertService(
244 new net::DefaultOriginBoundCertStore(NULL)));
267 } 245 }
268 246
269 // setup cookie store 247 // setup cookie store
270 if (!cookie_store) { 248 if (!cookie_store) {
271 DCHECK(!lazy_params_->cookie_path.empty()); 249 DCHECK(!lazy_params_->cookie_path.empty());
272 250
273 scoped_refptr<SQLitePersistentCookieStore> cookie_db = 251 scoped_refptr<SQLitePersistentCookieStore> cookie_db =
274 new SQLitePersistentCookieStore(lazy_params_->cookie_path); 252 new SQLitePersistentCookieStore(lazy_params_->cookie_path);
275 cookie_db->SetClearLocalStateOnExit( 253 cookie_db->SetClearLocalStateOnExit(
276 profile_params->clear_local_state_on_exit); 254 profile_params->clear_local_state_on_exit);
277 cookie_store = 255 cookie_store =
278 new net::CookieMonster(cookie_db.get(), 256 new net::CookieMonster(cookie_db.get(),
279 profile_params->cookie_monster_delegate); 257 profile_params->cookie_monster_delegate);
280 } 258 }
281 259
282 net::CookieMonster* extensions_cookie_store = 260 net::CookieMonster* extensions_cookie_store =
283 new net::CookieMonster( 261 new net::CookieMonster(
284 new SQLitePersistentCookieStore( 262 new SQLitePersistentCookieStore(
285 lazy_params_->extensions_cookie_path), NULL); 263 lazy_params_->extensions_cookie_path), NULL);
286 // Enable cookies for devtools and extension URLs. 264 // Enable cookies for devtools and extension URLs.
287 const char* schemes[] = {chrome::kChromeDevToolsScheme, 265 const char* schemes[] = {chrome::kChromeDevToolsScheme,
288 chrome::kExtensionScheme}; 266 chrome::kExtensionScheme};
289 extensions_cookie_store->SetCookieableSchemes(schemes, 2); 267 extensions_cookie_store->SetCookieableSchemes(schemes, 2);
290 268
291 main_context->set_cookie_store(cookie_store); 269 main_context->set_cookie_store(cookie_store);
292 media_request_context_->set_cookie_store(cookie_store); 270 media_request_context_->set_cookie_store(cookie_store);
293 extensions_context->set_cookie_store(extensions_cookie_store); 271 extensions_context->set_cookie_store(extensions_cookie_store);
294 272
273 // Setup origin bound cert service.
274 if (!origin_bound_cert_service()) {
275 DCHECK(!lazy_params_->origin_bound_cert_path.empty());
276
277 scoped_refptr<SQLiteOriginBoundCertStore> origin_bound_cert_db =
278 new SQLiteOriginBoundCertStore(lazy_params_->origin_bound_cert_path);
279 origin_bound_cert_db->SetClearLocalStateOnExit(
280 profile_params->clear_local_state_on_exit);
281 set_origin_bound_cert_service(new net::OriginBoundCertService(
282 new net::DefaultOriginBoundCertStore(origin_bound_cert_db.get())));
283 }
284
285 main_context->set_origin_bound_cert_service(origin_bound_cert_service());
286 media_request_context_->set_origin_bound_cert_service(
287 origin_bound_cert_service());
288
289 net::HttpCache::DefaultBackend* main_backend =
290 new net::HttpCache::DefaultBackend(
291 net::DISK_CACHE,
292 lazy_params_->cache_path,
293 lazy_params_->cache_max_size,
294 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE));
295 net::HttpCache* main_cache = new net::HttpCache(
296 main_context->host_resolver(),
297 main_context->cert_verifier(),
298 main_context->origin_bound_cert_service(),
299 main_context->dnsrr_resolver(),
300 main_context->dns_cert_checker(),
301 main_context->proxy_service(),
302 main_context->ssl_config_service(),
303 main_context->http_auth_handler_factory(),
304 main_context->network_delegate(),
305 main_context->net_log(),
306 main_backend);
307
308 net::HttpCache::DefaultBackend* media_backend =
309 new net::HttpCache::DefaultBackend(
310 net::MEDIA_CACHE, lazy_params_->media_cache_path,
311 lazy_params_->media_cache_max_size,
312 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE));
313 net::HttpNetworkSession* main_network_session = main_cache->GetSession();
314 net::HttpCache* media_cache =
315 new net::HttpCache(main_network_session, media_backend);
316
317 if (record_mode || playback_mode) {
318 main_cache->set_mode(
319 record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK);
320 }
321
295 main_http_factory_.reset(main_cache); 322 main_http_factory_.reset(main_cache);
296 media_http_factory_.reset(media_cache); 323 media_http_factory_.reset(media_cache);
297 main_context->set_http_transaction_factory(main_cache); 324 main_context->set_http_transaction_factory(main_cache);
298 media_request_context_->set_http_transaction_factory(media_cache); 325 media_request_context_->set_http_transaction_factory(media_cache);
299 326
300 main_context->set_ftp_transaction_factory( 327 main_context->set_ftp_transaction_factory(
301 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); 328 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get()));
302 329
303 main_context->set_chrome_url_data_manager_backend( 330 main_context->set_chrome_url_data_manager_backend(
304 chrome_url_data_manager_backend()); 331 chrome_url_data_manager_backend());
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 scoped_refptr<ProfileIOData::RequestContext> 412 scoped_refptr<ProfileIOData::RequestContext>
386 ProfileImplIOData::AcquireIsolatedAppRequestContext( 413 ProfileImplIOData::AcquireIsolatedAppRequestContext(
387 scoped_refptr<ChromeURLRequestContext> main_context, 414 scoped_refptr<ChromeURLRequestContext> main_context,
388 const std::string& app_id) const { 415 const std::string& app_id) const {
389 // We create per-app contexts on demand, unlike the others above. 416 // We create per-app contexts on demand, unlike the others above.
390 scoped_refptr<RequestContext> app_request_context = 417 scoped_refptr<RequestContext> app_request_context =
391 InitializeAppRequestContext(main_context, app_id); 418 InitializeAppRequestContext(main_context, app_id);
392 DCHECK(app_request_context); 419 DCHECK(app_request_context);
393 return app_request_context; 420 return app_request_context;
394 } 421 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698