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/connect_interceptor.h" | |
| 16 #include "chrome/browser/net/predictor.h" | |
| 15 #include "chrome/browser/net/sqlite_origin_bound_cert_store.h" | 17 #include "chrome/browser/net/sqlite_origin_bound_cert_store.h" |
| 16 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" | 18 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" |
| 17 #include "chrome/browser/prefs/pref_member.h" | 19 #include "chrome/browser/prefs/pref_member.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
| 20 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
| 23 #include "content/browser/browser_thread.h" | 25 #include "content/browser/browser_thread.h" |
| 24 #include "content/browser/resource_context.h" | 26 #include "content/browser/resource_context.h" |
| 25 #include "net/base/origin_bound_cert_service.h" | 27 #include "net/base/origin_bound_cert_service.h" |
| 26 #include "net/ftp/ftp_network_layer.h" | 28 #include "net/ftp/ftp_network_layer.h" |
| 27 #include "net/http/http_cache.h" | 29 #include "net/http/http_cache.h" |
| 30 #include "net/url_request/url_request_job_factory.h" | |
| 28 | 31 |
| 29 ProfileImplIOData::Handle::Handle(Profile* profile) | 32 ProfileImplIOData::Handle::Handle(Profile* profile) |
| 30 : io_data_(new ProfileImplIOData), | 33 : io_data_(new ProfileImplIOData), |
| 31 profile_(profile), | 34 profile_(profile), |
| 32 initialized_(false) { | 35 initialized_(false) { |
| 33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 34 DCHECK(profile); | 37 DCHECK(profile); |
| 35 } | 38 } |
| 36 | 39 |
| 37 ProfileImplIOData::Handle::~Handle() { | 40 ProfileImplIOData::Handle::~Handle() { |
| 38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 39 if (main_request_context_getter_) | 42 if (main_request_context_getter_) |
| 40 main_request_context_getter_->CleanupOnUIThread(); | 43 main_request_context_getter_->CleanupOnUIThread(); |
| 41 if (media_request_context_getter_) | 44 if (media_request_context_getter_) |
| 42 media_request_context_getter_->CleanupOnUIThread(); | 45 media_request_context_getter_->CleanupOnUIThread(); |
| 43 if (extensions_request_context_getter_) | 46 if (extensions_request_context_getter_) |
| 44 extensions_request_context_getter_->CleanupOnUIThread(); | 47 extensions_request_context_getter_->CleanupOnUIThread(); |
| 45 | 48 |
| 49 io_data_->predictor_->ShutdownOnUIThread(profile_->GetPrefs()); | |
| 50 | |
| 46 // Clean up all isolated app request contexts. | 51 // Clean up all isolated app request contexts. |
| 47 for (ChromeURLRequestContextGetterMap::iterator iter = | 52 for (ChromeURLRequestContextGetterMap::iterator iter = |
| 48 app_request_context_getter_map_.begin(); | 53 app_request_context_getter_map_.begin(); |
| 49 iter != app_request_context_getter_map_.end(); | 54 iter != app_request_context_getter_map_.end(); |
| 50 ++iter) { | 55 ++iter) { |
| 51 iter->second->CleanupOnUIThread(); | 56 iter->second->CleanupOnUIThread(); |
| 52 } | 57 } |
| 53 | 58 |
| 54 io_data_->ShutdownOnUIThread(); | 59 io_data_->ShutdownOnUIThread(); |
| 55 } | 60 } |
| 56 | 61 |
| 57 void ProfileImplIOData::Handle::Init(const FilePath& cookie_path, | 62 void ProfileImplIOData::Handle::Init( |
| 58 const FilePath& origin_bound_cert_path, | 63 const FilePath& cookie_path, |
| 59 const FilePath& cache_path, | 64 const FilePath& origin_bound_cert_path, |
| 60 int cache_max_size, | 65 const FilePath& cache_path, |
| 61 const FilePath& media_cache_path, | 66 int cache_max_size, |
| 62 int media_cache_max_size, | 67 const FilePath& media_cache_path, |
| 63 const FilePath& extensions_cookie_path, | 68 int media_cache_max_size, |
| 64 const FilePath& app_path) { | 69 const FilePath& extensions_cookie_path, |
| 70 const FilePath& app_path, | |
| 71 chrome_browser_net::Predictor* predictor) { | |
| 65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 66 DCHECK(!io_data_->lazy_params_.get()); | 73 DCHECK(!io_data_->lazy_params_.get()); |
| 74 DCHECK(predictor); | |
| 75 | |
| 67 LazyParams* lazy_params = new LazyParams; | 76 LazyParams* lazy_params = new LazyParams; |
| 68 | 77 |
| 69 lazy_params->cookie_path = cookie_path; | 78 lazy_params->cookie_path = cookie_path; |
| 70 lazy_params->origin_bound_cert_path = origin_bound_cert_path; | 79 lazy_params->origin_bound_cert_path = origin_bound_cert_path; |
| 71 lazy_params->cache_path = cache_path; | 80 lazy_params->cache_path = cache_path; |
| 72 lazy_params->cache_max_size = cache_max_size; | 81 lazy_params->cache_max_size = cache_max_size; |
| 73 lazy_params->media_cache_path = media_cache_path; | 82 lazy_params->media_cache_path = media_cache_path; |
| 74 lazy_params->media_cache_max_size = media_cache_max_size; | 83 lazy_params->media_cache_max_size = media_cache_max_size; |
| 75 lazy_params->extensions_cookie_path = extensions_cookie_path; | 84 lazy_params->extensions_cookie_path = extensions_cookie_path; |
| 76 | 85 |
| 77 io_data_->lazy_params_.reset(lazy_params); | 86 io_data_->lazy_params_.reset(lazy_params); |
| 78 | 87 |
| 79 // Keep track of isolated app path separately so we can use it on demand. | 88 // Keep track of isolated app path separately so we can use it on demand. |
| 80 io_data_->app_path_ = app_path; | 89 io_data_->app_path_ = app_path; |
| 90 | |
| 91 io_data_->predictor_.reset(predictor); | |
| 92 io_data_->predictor_->InitNetworkPredictor(profile_->GetPrefs()); | |
| 81 } | 93 } |
| 82 | 94 |
| 83 base::Callback<ChromeURLDataManagerBackend*(void)> | 95 base::Callback<ChromeURLDataManagerBackend*(void)> |
| 84 ProfileImplIOData::Handle::GetChromeURLDataManagerBackendGetter() const { | 96 ProfileImplIOData::Handle::GetChromeURLDataManagerBackendGetter() const { |
| 85 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 86 LazyInitialize(); | 98 LazyInitialize(); |
| 87 return base::Bind(&ProfileIOData::GetChromeURLDataManagerBackend, | 99 return base::Bind(&ProfileIOData::GetChromeURLDataManagerBackend, |
| 88 base::Unretained(io_data_)); | 100 base::Unretained(io_data_)); |
| 89 } | 101 } |
| 90 | 102 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 } | 185 } |
| 174 | 186 |
| 175 ProfileImplIOData::LazyParams::LazyParams() | 187 ProfileImplIOData::LazyParams::LazyParams() |
| 176 : cache_max_size(0), | 188 : cache_max_size(0), |
| 177 media_cache_max_size(0) {} | 189 media_cache_max_size(0) {} |
| 178 ProfileImplIOData::LazyParams::~LazyParams() {} | 190 ProfileImplIOData::LazyParams::~LazyParams() {} |
| 179 | 191 |
| 180 ProfileImplIOData::ProfileImplIOData() | 192 ProfileImplIOData::ProfileImplIOData() |
| 181 : ProfileIOData(false), | 193 : ProfileIOData(false), |
| 182 clear_local_state_on_exit_(false) {} | 194 clear_local_state_on_exit_(false) {} |
| 183 ProfileImplIOData::~ProfileImplIOData() {} | 195 ProfileImplIOData::~ProfileImplIOData() { |
|
willchan no longer on Chromium
2011/08/12 21:17:29
The rest of the file uses {}, can you keep it like
rpetterson
2011/08/13 00:55:17
Done.
| |
| 196 } | |
| 184 | 197 |
| 185 void ProfileImplIOData::LazyInitializeInternal( | 198 void ProfileImplIOData::LazyInitializeInternal( |
| 186 ProfileParams* profile_params) const { | 199 ProfileParams* profile_params) const { |
| 187 // Keep track of clear_local_state_on_exit for isolated apps. | 200 // Keep track of clear_local_state_on_exit for isolated apps. |
| 188 clear_local_state_on_exit_ = profile_params->clear_local_state_on_exit; | 201 clear_local_state_on_exit_ = profile_params->clear_local_state_on_exit; |
| 189 | 202 |
| 190 ChromeURLRequestContext* main_context = main_request_context(); | 203 ChromeURLRequestContext* main_context = main_request_context(); |
| 191 ChromeURLRequestContext* extensions_context = extensions_request_context(); | 204 ChromeURLRequestContext* extensions_context = extensions_request_context(); |
| 192 media_request_context_ = new ChromeURLRequestContext; | 205 media_request_context_ = new ChromeURLRequestContext; |
| 193 | 206 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 main_context->set_ftp_transaction_factory( | 342 main_context->set_ftp_transaction_factory( |
| 330 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); | 343 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); |
| 331 | 344 |
| 332 main_context->set_chrome_url_data_manager_backend( | 345 main_context->set_chrome_url_data_manager_backend( |
| 333 chrome_url_data_manager_backend()); | 346 chrome_url_data_manager_backend()); |
| 334 | 347 |
| 335 main_context->set_job_factory(job_factory()); | 348 main_context->set_job_factory(job_factory()); |
| 336 media_request_context_->set_job_factory(job_factory()); | 349 media_request_context_->set_job_factory(job_factory()); |
| 337 extensions_context->set_job_factory(job_factory()); | 350 extensions_context->set_job_factory(job_factory()); |
| 338 | 351 |
| 352 job_factory()->AddInterceptor( | |
| 353 new chrome_browser_net::ConnectInterceptor(predictor_.get())); | |
| 354 | |
| 339 lazy_params_.reset(); | 355 lazy_params_.reset(); |
| 340 } | 356 } |
| 341 | 357 |
| 342 scoped_refptr<ChromeURLRequestContext> | 358 scoped_refptr<ChromeURLRequestContext> |
| 343 ProfileImplIOData::InitializeAppRequestContext( | 359 ProfileImplIOData::InitializeAppRequestContext( |
| 344 scoped_refptr<ChromeURLRequestContext> main_context, | 360 scoped_refptr<ChromeURLRequestContext> main_context, |
| 345 const std::string& app_id) const { | 361 const std::string& app_id) const { |
| 346 AppRequestContext* context = new AppRequestContext; | 362 AppRequestContext* context = new AppRequestContext; |
| 347 | 363 |
| 348 // Copy most state from the main context. | 364 // Copy most state from the main context. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 scoped_refptr<ChromeURLRequestContext> | 426 scoped_refptr<ChromeURLRequestContext> |
| 411 ProfileImplIOData::AcquireIsolatedAppRequestContext( | 427 ProfileImplIOData::AcquireIsolatedAppRequestContext( |
| 412 scoped_refptr<ChromeURLRequestContext> main_context, | 428 scoped_refptr<ChromeURLRequestContext> main_context, |
| 413 const std::string& app_id) const { | 429 const std::string& app_id) const { |
| 414 // We create per-app contexts on demand, unlike the others above. | 430 // We create per-app contexts on demand, unlike the others above. |
| 415 scoped_refptr<ChromeURLRequestContext> app_request_context = | 431 scoped_refptr<ChromeURLRequestContext> app_request_context = |
| 416 InitializeAppRequestContext(main_context, app_id); | 432 InitializeAppRequestContext(main_context, app_id); |
| 417 DCHECK(app_request_context); | 433 DCHECK(app_request_context); |
| 418 return app_request_context; | 434 return app_request_context; |
| 419 } | 435 } |
| OLD | NEW |