Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 main_context->set_http_auth_handler_factory( | 226 main_context->set_http_auth_handler_factory( |
| 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 |
|
rkn
2011/08/03 00:39:35
I moved the below block of code farther down becau
| |
| 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; |
| 238 net::OriginBoundCertService* origin_bound_cert_service = NULL; | |
|
wtc
2011/08/04 00:56:20
IMPORTANT: we should use a scoped_refptr or a scop
| |
| 261 if (record_mode || playback_mode) { | 239 if (record_mode || playback_mode) { |
| 262 // Don't use existing cookies and use an in-memory store. | 240 // Don't use existing cookies and use an in-memory store. |
| 263 cookie_store = new net::CookieMonster( | 241 cookie_store = new net::CookieMonster( |
| 264 NULL, profile_params->cookie_monster_delegate); | 242 NULL, profile_params->cookie_monster_delegate); |
| 265 main_cache->set_mode( | 243 // Don't use existing origin-bound certs and use an in-memory store. |
| 266 record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); | 244 origin_bound_cert_service = new net::OriginBoundCertService( |
| 245 new net::DefaultOriginBoundCertStore(NULL)); | |
| 267 } | 246 } |
| 268 | 247 |
| 269 // setup cookie store | 248 // setup cookie store |
| 270 if (!cookie_store) { | 249 if (!cookie_store) { |
| 271 DCHECK(!lazy_params_->cookie_path.empty()); | 250 DCHECK(!lazy_params_->cookie_path.empty()); |
| 272 | 251 |
| 273 scoped_refptr<SQLitePersistentCookieStore> cookie_db = | 252 scoped_refptr<SQLitePersistentCookieStore> cookie_db = |
| 274 new SQLitePersistentCookieStore(lazy_params_->cookie_path); | 253 new SQLitePersistentCookieStore(lazy_params_->cookie_path); |
| 275 cookie_db->SetClearLocalStateOnExit( | 254 cookie_db->SetClearLocalStateOnExit( |
| 276 profile_params->clear_local_state_on_exit); | 255 profile_params->clear_local_state_on_exit); |
| 277 cookie_store = | 256 cookie_store = |
| 278 new net::CookieMonster(cookie_db.get(), | 257 new net::CookieMonster(cookie_db.get(), |
| 279 profile_params->cookie_monster_delegate); | 258 profile_params->cookie_monster_delegate); |
| 280 } | 259 } |
| 281 | 260 |
| 261 // Setup origin bound cert service. | |
| 262 if (!origin_bound_cert_service) { | |
| 263 DCHECK(!lazy_params_->origin_bound_cert_path.empty()); | |
| 264 | |
| 265 scoped_refptr<SQLiteOriginBoundCertStore> origin_bound_cert_db = | |
| 266 new SQLiteOriginBoundCertStore(lazy_params_->origin_bound_cert_path); | |
| 267 origin_bound_cert_db->SetClearLocalStateOnExit( | |
| 268 profile_params->clear_local_state_on_exit); | |
| 269 origin_bound_cert_service = | |
| 270 new net::OriginBoundCertService( | |
| 271 new net::DefaultOriginBoundCertStore(origin_bound_cert_db.get())); | |
| 272 } | |
|
wtc
2011/08/04 00:56:20
I suggest moving this block of code to line 287 be
| |
| 273 | |
| 282 net::CookieMonster* extensions_cookie_store = | 274 net::CookieMonster* extensions_cookie_store = |
| 283 new net::CookieMonster( | 275 new net::CookieMonster( |
| 284 new SQLitePersistentCookieStore( | 276 new SQLitePersistentCookieStore( |
| 285 lazy_params_->extensions_cookie_path), NULL); | 277 lazy_params_->extensions_cookie_path), NULL); |
| 286 // Enable cookies for devtools and extension URLs. | 278 // Enable cookies for devtools and extension URLs. |
| 287 const char* schemes[] = {chrome::kChromeDevToolsScheme, | 279 const char* schemes[] = {chrome::kChromeDevToolsScheme, |
| 288 chrome::kExtensionScheme}; | 280 chrome::kExtensionScheme}; |
| 289 extensions_cookie_store->SetCookieableSchemes(schemes, 2); | 281 extensions_cookie_store->SetCookieableSchemes(schemes, 2); |
| 290 | 282 |
| 291 main_context->set_cookie_store(cookie_store); | 283 main_context->set_cookie_store(cookie_store); |
| 292 media_request_context_->set_cookie_store(cookie_store); | 284 media_request_context_->set_cookie_store(cookie_store); |
| 293 extensions_context->set_cookie_store(extensions_cookie_store); | 285 extensions_context->set_cookie_store(extensions_cookie_store); |
| 294 | 286 |
| 287 main_context->set_origin_bound_cert_service(origin_bound_cert_service); | |
| 288 media_request_context_->set_origin_bound_cert_service( | |
| 289 origin_bound_cert_service); | |
|
wtc
2011/08/04 00:56:20
NOTE: this code implies that OriginBoundCertServic
willchan no longer on Chromium
2011/08/05 04:01:18
We're generally moving toward the ProfileIOData ow
| |
| 290 | |
| 291 net::HttpCache::DefaultBackend* main_backend = | |
| 292 new net::HttpCache::DefaultBackend( | |
| 293 net::DISK_CACHE, | |
| 294 lazy_params_->cache_path, | |
| 295 lazy_params_->cache_max_size, | |
| 296 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); | |
| 297 net::HttpCache* main_cache = new net::HttpCache( | |
| 298 main_context->host_resolver(), | |
| 299 main_context->cert_verifier(), | |
| 300 main_context->origin_bound_cert_service(), | |
| 301 main_context->dnsrr_resolver(), | |
| 302 main_context->dns_cert_checker(), | |
| 303 main_context->proxy_service(), | |
| 304 main_context->ssl_config_service(), | |
| 305 main_context->http_auth_handler_factory(), | |
| 306 main_context->network_delegate(), | |
| 307 main_context->net_log(), | |
| 308 main_backend); | |
| 309 | |
| 310 net::HttpCache::DefaultBackend* media_backend = | |
| 311 new net::HttpCache::DefaultBackend( | |
| 312 net::MEDIA_CACHE, lazy_params_->media_cache_path, | |
| 313 lazy_params_->media_cache_max_size, | |
| 314 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); | |
| 315 net::HttpNetworkSession* main_network_session = main_cache->GetSession(); | |
| 316 net::HttpCache* media_cache = | |
| 317 new net::HttpCache(main_network_session, media_backend); | |
| 318 | |
| 319 if (record_mode || playback_mode) { | |
| 320 main_cache->set_mode( | |
| 321 record_mode ? net::HttpCache::RECORD : net::HttpCache::PLAYBACK); | |
| 322 } | |
| 323 | |
| 295 main_http_factory_.reset(main_cache); | 324 main_http_factory_.reset(main_cache); |
| 296 media_http_factory_.reset(media_cache); | 325 media_http_factory_.reset(media_cache); |
| 297 main_context->set_http_transaction_factory(main_cache); | 326 main_context->set_http_transaction_factory(main_cache); |
| 298 media_request_context_->set_http_transaction_factory(media_cache); | 327 media_request_context_->set_http_transaction_factory(media_cache); |
| 299 | 328 |
| 300 main_context->set_ftp_transaction_factory( | 329 main_context->set_ftp_transaction_factory( |
| 301 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); | 330 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); |
| 302 | 331 |
| 303 main_context->set_chrome_url_data_manager_backend( | 332 main_context->set_chrome_url_data_manager_backend( |
| 304 chrome_url_data_manager_backend()); | 333 chrome_url_data_manager_backend()); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 scoped_refptr<ProfileIOData::RequestContext> | 414 scoped_refptr<ProfileIOData::RequestContext> |
| 386 ProfileImplIOData::AcquireIsolatedAppRequestContext( | 415 ProfileImplIOData::AcquireIsolatedAppRequestContext( |
| 387 scoped_refptr<ChromeURLRequestContext> main_context, | 416 scoped_refptr<ChromeURLRequestContext> main_context, |
| 388 const std::string& app_id) const { | 417 const std::string& app_id) const { |
| 389 // We create per-app contexts on demand, unlike the others above. | 418 // We create per-app contexts on demand, unlike the others above. |
| 390 scoped_refptr<RequestContext> app_request_context = | 419 scoped_refptr<RequestContext> app_request_context = |
| 391 InitializeAppRequestContext(main_context, app_id); | 420 InitializeAppRequestContext(main_context, app_id); |
| 392 DCHECK(app_request_context); | 421 DCHECK(app_request_context); |
| 393 return app_request_context; | 422 return app_request_context; |
| 394 } | 423 } |
| OLD | NEW |