| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/io_thread.h" | 12 #include "chrome/browser/io_thread.h" |
| 13 #include "chrome/browser/net/chrome_cookie_policy.h" | 13 #include "chrome/browser/net/chrome_cookie_policy.h" |
| 14 #include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h" | 14 #include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h" |
| 15 #include "chrome/browser/net/chrome_net_log.h" | 15 #include "chrome/browser/net/chrome_net_log.h" |
| 16 #include "chrome/browser/net/chrome_network_delegate.h" | 16 #include "chrome/browser/net/chrome_network_delegate.h" |
| 17 #include "chrome/browser/net/proxy_service_factory.h" | 17 #include "chrome/browser/net/proxy_service_factory.h" |
| 18 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" | 18 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" |
| 19 #include "chrome/common/chrome_constants.h" | 19 #include "chrome/common/chrome_constants.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
| 23 #include "content/browser/browser_thread.h" | 23 #include "content/browser/browser_thread.h" |
| 24 #include "content/browser/resource_context.h" |
| 24 #include "net/ftp/ftp_network_layer.h" | 25 #include "net/ftp/ftp_network_layer.h" |
| 25 #include "net/http/http_cache.h" | 26 #include "net/http/http_cache.h" |
| 26 | 27 |
| 27 ProfileImplIOData::Handle::Handle(Profile* profile) | 28 ProfileImplIOData::Handle::Handle(Profile* profile) |
| 28 : io_data_(new ProfileImplIOData), | 29 : io_data_(new ProfileImplIOData), |
| 29 profile_(profile), | 30 profile_(profile), |
| 30 initialized_(false) { | 31 initialized_(false) { |
| 31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 32 DCHECK(profile); | 33 DCHECK(profile); |
| 33 } | 34 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 lazy_params->extensions_cookie_path = extensions_cookie_path; | 70 lazy_params->extensions_cookie_path = extensions_cookie_path; |
| 70 | 71 |
| 71 lazy_params->io_thread = g_browser_process->io_thread(); | 72 lazy_params->io_thread = g_browser_process->io_thread(); |
| 72 | 73 |
| 73 io_data_->lazy_params_.reset(lazy_params); | 74 io_data_->lazy_params_.reset(lazy_params); |
| 74 | 75 |
| 75 // Keep track of isolated app path separately so we can use it on demand. | 76 // Keep track of isolated app path separately so we can use it on demand. |
| 76 io_data_->app_path_ = app_path; | 77 io_data_->app_path_ = app_path; |
| 77 } | 78 } |
| 78 | 79 |
| 80 content::ResourceContextGetter* |
| 81 ProfileImplIOData::Handle::GetResourceContextGetter() const { |
| 82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 83 LazyInitialize(); |
| 84 return new ProfileResourceContextGetter(io_data_); |
| 85 } |
| 86 |
| 79 scoped_refptr<ChromeURLRequestContextGetter> | 87 scoped_refptr<ChromeURLRequestContextGetter> |
| 80 ProfileImplIOData::Handle::GetMainRequestContextGetter() const { | 88 ProfileImplIOData::Handle::GetMainRequestContextGetter() const { |
| 81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 82 LazyInitialize(); | 90 LazyInitialize(); |
| 83 if (!main_request_context_getter_) { | 91 if (!main_request_context_getter_) { |
| 84 main_request_context_getter_ = | 92 main_request_context_getter_ = |
| 85 ChromeURLRequestContextGetter::CreateOriginal( | 93 ChromeURLRequestContextGetter::CreateOriginal( |
| 86 profile_, io_data_); | 94 profile_, io_data_); |
| 87 } | 95 } |
| 88 return main_request_context_getter_; | 96 return main_request_context_getter_; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 extensions_cookie_store); | 297 extensions_cookie_store); |
| 290 | 298 |
| 291 main_http_factory_.reset(main_cache); | 299 main_http_factory_.reset(main_cache); |
| 292 media_http_factory_.reset(media_cache); | 300 media_http_factory_.reset(media_cache); |
| 293 main_request_context_->set_http_transaction_factory(main_cache); | 301 main_request_context_->set_http_transaction_factory(main_cache); |
| 294 media_request_context_->set_http_transaction_factory(media_cache); | 302 media_request_context_->set_http_transaction_factory(media_cache); |
| 295 | 303 |
| 296 main_request_context_->set_ftp_transaction_factory( | 304 main_request_context_->set_ftp_transaction_factory( |
| 297 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); | 305 new net::FtpNetworkLayer(io_thread_globals->host_resolver.get())); |
| 298 | 306 |
| 307 // Initialize ResourceContext. |
| 308 |
| 309 scoped_ptr<content::ResourceContext> resource_context( |
| 310 new content::ResourceContext); |
| 311 resource_context->set_database_tracker(profile_params.database_tracker); |
| 312 set_resource_context(resource_context.release()); |
| 313 |
| 299 lazy_params_.reset(); | 314 lazy_params_.reset(); |
| 300 } | 315 } |
| 301 | 316 |
| 302 scoped_refptr<ProfileIOData::RequestContext> | 317 scoped_refptr<ProfileIOData::RequestContext> |
| 303 ProfileImplIOData::InitializeAppRequestContext( | 318 ProfileImplIOData::InitializeAppRequestContext( |
| 304 scoped_refptr<ChromeURLRequestContext> main_context, | 319 scoped_refptr<ChromeURLRequestContext> main_context, |
| 305 const std::string& app_id) const { | 320 const std::string& app_id) const { |
| 306 scoped_refptr<ProfileIOData::RequestContext> context = new RequestContext; | 321 scoped_refptr<ProfileIOData::RequestContext> context = new RequestContext; |
| 307 | 322 |
| 308 // Copy most state from the main context. | 323 // Copy most state from the main context. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 ProfileImplIOData::AcquireIsolatedAppRequestContext( | 411 ProfileImplIOData::AcquireIsolatedAppRequestContext( |
| 397 scoped_refptr<ChromeURLRequestContext> main_context, | 412 scoped_refptr<ChromeURLRequestContext> main_context, |
| 398 const std::string& app_id) const { | 413 const std::string& app_id) const { |
| 399 // We create per-app contexts on demand, unlike the others above. | 414 // We create per-app contexts on demand, unlike the others above. |
| 400 scoped_refptr<RequestContext> app_request_context = | 415 scoped_refptr<RequestContext> app_request_context = |
| 401 InitializeAppRequestContext(main_context, app_id); | 416 InitializeAppRequestContext(main_context, app_id); |
| 402 DCHECK(app_request_context); | 417 DCHECK(app_request_context); |
| 403 app_request_context->set_profile_io_data(this); | 418 app_request_context->set_profile_io_data(this); |
| 404 return app_request_context; | 419 return app_request_context; |
| 405 } | 420 } |
| OLD | NEW |