OLD | NEW |
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 "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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "net/base/cache_type.h" | 43 #include "net/base/cache_type.h" |
44 #include "net/base/sdch_dictionary_fetcher.h" | 44 #include "net/base/sdch_dictionary_fetcher.h" |
45 #include "net/base/sdch_manager.h" | 45 #include "net/base/sdch_manager.h" |
46 #include "net/ftp/ftp_network_layer.h" | 46 #include "net/ftp/ftp_network_layer.h" |
47 #include "net/http/http_cache.h" | 47 #include "net/http/http_cache.h" |
48 #include "net/http/http_server_properties_manager.h" | 48 #include "net/http/http_server_properties_manager.h" |
49 #include "net/ssl/channel_id_service.h" | 49 #include "net/ssl/channel_id_service.h" |
50 #include "net/url_request/url_request_job_factory_impl.h" | 50 #include "net/url_request/url_request_job_factory_impl.h" |
51 #include "webkit/browser/quota/special_storage_policy.h" | 51 #include "webkit/browser/quota/special_storage_policy.h" |
52 | 52 |
| 53 #if defined(SPDY_PROXY_AUTH_ORIGIN) |
| 54 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
| 55 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ
est_handler.h" |
| 56 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol.
h" |
| 57 #include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_sta
ts.h" |
| 58 #include "components/data_reduction_proxy/common/data_reduction_proxy_pref_names
.h" |
| 59 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) |
| 60 |
53 namespace { | 61 namespace { |
54 | 62 |
55 net::BackendType ChooseCacheBackendType() { | 63 net::BackendType ChooseCacheBackendType() { |
56 #if defined(OS_ANDROID) | 64 #if defined(OS_ANDROID) |
57 return net::CACHE_BACKEND_SIMPLE; | 65 return net::CACHE_BACKEND_SIMPLE; |
58 #else | 66 #else |
59 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 67 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
60 if (command_line.HasSwitch(switches::kUseSimpleCacheBackend)) { | 68 if (command_line.HasSwitch(switches::kUseSimpleCacheBackend)) { |
61 const std::string opt_value = | 69 const std::string opt_value = |
62 command_line.GetSwitchValueASCII(switches::kUseSimpleCacheBackend); | 70 command_line.GetSwitchValueASCII(switches::kUseSimpleCacheBackend); |
63 if (LowerCaseEqualsASCII(opt_value, "off")) | 71 if (LowerCaseEqualsASCII(opt_value, "off")) |
64 return net::CACHE_BACKEND_BLOCKFILE; | 72 return net::CACHE_BACKEND_BLOCKFILE; |
65 if (opt_value == "" || LowerCaseEqualsASCII(opt_value, "on")) | 73 if (opt_value == "" || LowerCaseEqualsASCII(opt_value, "on")) |
66 return net::CACHE_BACKEND_SIMPLE; | 74 return net::CACHE_BACKEND_SIMPLE; |
67 } | 75 } |
68 const std::string experiment_name = | 76 const std::string experiment_name = |
69 base::FieldTrialList::FindFullName("SimpleCacheTrial"); | 77 base::FieldTrialList::FindFullName("SimpleCacheTrial"); |
70 if (experiment_name == "ExperimentYes" || | 78 if (experiment_name == "ExperimentYes" || |
71 experiment_name == "ExperimentYes2") { | 79 experiment_name == "ExperimentYes2") { |
72 return net::CACHE_BACKEND_SIMPLE; | 80 return net::CACHE_BACKEND_SIMPLE; |
73 } | 81 } |
74 return net::CACHE_BACKEND_BLOCKFILE; | 82 return net::CACHE_BACKEND_BLOCKFILE; |
75 #endif | 83 #endif |
76 } | 84 } |
77 | 85 |
78 } // namespace | 86 } // namespace |
79 | 87 |
80 using content::BrowserThread; | 88 using content::BrowserThread; |
| 89 #if defined(SPDY_PROXY_AUTH_ORIGIN) |
| 90 using data_reduction_proxy::DataReductionProxyParams; |
| 91 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) |
81 | 92 |
82 ProfileImplIOData::Handle::Handle(Profile* profile) | 93 ProfileImplIOData::Handle::Handle(Profile* profile) |
83 : io_data_(new ProfileImplIOData), | 94 : io_data_(new ProfileImplIOData), |
84 profile_(profile), | 95 profile_(profile), |
85 initialized_(false) { | 96 initialized_(false) { |
86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
87 DCHECK(profile); | 98 DCHECK(profile); |
88 } | 99 } |
89 | 100 |
90 ProfileImplIOData::Handle::~Handle() { | 101 ProfileImplIOData::Handle::~Handle() { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 int cache_max_size, | 144 int cache_max_size, |
134 const base::FilePath& media_cache_path, | 145 const base::FilePath& media_cache_path, |
135 int media_cache_max_size, | 146 int media_cache_max_size, |
136 const base::FilePath& extensions_cookie_path, | 147 const base::FilePath& extensions_cookie_path, |
137 const base::FilePath& profile_path, | 148 const base::FilePath& profile_path, |
138 const base::FilePath& infinite_cache_path, | 149 const base::FilePath& infinite_cache_path, |
139 chrome_browser_net::Predictor* predictor, | 150 chrome_browser_net::Predictor* predictor, |
140 content::CookieStoreConfig::SessionCookieMode session_cookie_mode, | 151 content::CookieStoreConfig::SessionCookieMode session_cookie_mode, |
141 quota::SpecialStoragePolicy* special_storage_policy, | 152 quota::SpecialStoragePolicy* special_storage_policy, |
142 scoped_ptr<domain_reliability::DomainReliabilityMonitor> | 153 scoped_ptr<domain_reliability::DomainReliabilityMonitor> |
143 domain_reliability_monitor) { | 154 domain_reliability_monitor, |
| 155 const base::Callback<void(bool)>& data_reduction_proxy_unavailable, |
| 156 scoped_ptr<data_reduction_proxy::DataReductionProxyParams> |
| 157 data_reduction_proxy_params) { |
144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 158 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
145 DCHECK(!io_data_->lazy_params_); | 159 DCHECK(!io_data_->lazy_params_); |
146 DCHECK(predictor); | 160 DCHECK(predictor); |
147 | 161 |
148 LazyParams* lazy_params = new LazyParams(); | 162 LazyParams* lazy_params = new LazyParams(); |
149 | 163 |
150 lazy_params->cookie_path = cookie_path; | 164 lazy_params->cookie_path = cookie_path; |
151 lazy_params->channel_id_path = channel_id_path; | 165 lazy_params->channel_id_path = channel_id_path; |
152 lazy_params->cache_path = cache_path; | 166 lazy_params->cache_path = cache_path; |
153 lazy_params->cache_max_size = cache_max_size; | 167 lazy_params->cache_max_size = cache_max_size; |
154 lazy_params->media_cache_path = media_cache_path; | 168 lazy_params->media_cache_path = media_cache_path; |
155 lazy_params->media_cache_max_size = media_cache_max_size; | 169 lazy_params->media_cache_max_size = media_cache_max_size; |
156 lazy_params->extensions_cookie_path = extensions_cookie_path; | 170 lazy_params->extensions_cookie_path = extensions_cookie_path; |
157 lazy_params->infinite_cache_path = infinite_cache_path; | 171 lazy_params->infinite_cache_path = infinite_cache_path; |
158 lazy_params->session_cookie_mode = session_cookie_mode; | 172 lazy_params->session_cookie_mode = session_cookie_mode; |
159 lazy_params->special_storage_policy = special_storage_policy; | 173 lazy_params->special_storage_policy = special_storage_policy; |
160 | 174 |
161 io_data_->lazy_params_.reset(lazy_params); | 175 io_data_->lazy_params_.reset(lazy_params); |
162 | 176 |
163 // Keep track of profile path and cache sizes separately so we can use them | 177 // Keep track of profile path and cache sizes separately so we can use them |
164 // on demand when creating storage isolated URLRequestContextGetters. | 178 // on demand when creating storage isolated URLRequestContextGetters. |
165 io_data_->profile_path_ = profile_path; | 179 io_data_->profile_path_ = profile_path; |
166 io_data_->app_cache_max_size_ = cache_max_size; | 180 io_data_->app_cache_max_size_ = cache_max_size; |
167 io_data_->app_media_cache_max_size_ = media_cache_max_size; | 181 io_data_->app_media_cache_max_size_ = media_cache_max_size; |
168 | 182 |
169 io_data_->predictor_.reset(predictor); | 183 io_data_->predictor_.reset(predictor); |
170 io_data_->domain_reliability_monitor_ = domain_reliability_monitor.Pass(); | 184 io_data_->domain_reliability_monitor_ = domain_reliability_monitor.Pass(); |
171 | 185 |
172 io_data_->InitializeMetricsEnabledStateOnUIThread(); | 186 io_data_->InitializeMetricsEnabledStateOnUIThread(); |
| 187 |
| 188 #if defined(SPDY_PROXY_AUTH_ORIGIN) |
| 189 io_data_->data_reduction_proxy_unavailable_callback_ = |
| 190 data_reduction_proxy_unavailable; |
| 191 io_data_->data_reduction_proxy_params_ = |
| 192 data_reduction_proxy_params.Pass(); |
| 193 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) |
173 } | 194 } |
174 | 195 |
175 content::ResourceContext* | 196 content::ResourceContext* |
176 ProfileImplIOData::Handle::GetResourceContext() const { | 197 ProfileImplIOData::Handle::GetResourceContext() const { |
177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
178 LazyInitialize(); | 199 LazyInitialize(); |
179 return GetResourceContextNoInit(); | 200 return GetResourceContextNoInit(); |
180 } | 201 } |
181 | 202 |
182 content::ResourceContext* | 203 content::ResourceContext* |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 io_data_->session_startup_pref()->Init( | 362 io_data_->session_startup_pref()->Init( |
342 prefs::kRestoreOnStartup, pref_service); | 363 prefs::kRestoreOnStartup, pref_service); |
343 io_data_->session_startup_pref()->MoveToThread( | 364 io_data_->session_startup_pref()->MoveToThread( |
344 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 365 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
345 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) | 366 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) |
346 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled, | 367 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled, |
347 pref_service); | 368 pref_service); |
348 io_data_->safe_browsing_enabled()->MoveToThread( | 369 io_data_->safe_browsing_enabled()->MoveToThread( |
349 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 370 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
350 #endif | 371 #endif |
351 #if defined(OS_ANDROID) || defined(OS_IOS) | 372 #if defined(SPDY_PROXY_AUTH_ORIGIN) |
352 io_data_->data_reduction_proxy_enabled()->Init( | 373 io_data_->data_reduction_proxy_enabled()->Init( |
353 data_reduction_proxy::prefs::kDataReductionProxyEnabled, pref_service); | 374 data_reduction_proxy::prefs::kDataReductionProxyEnabled, pref_service); |
354 io_data_->data_reduction_proxy_enabled()->MoveToThread( | 375 io_data_->data_reduction_proxy_enabled()->MoveToThread( |
355 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 376 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
356 #endif | 377 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) |
357 io_data_->InitializeOnUIThread(profile_); | 378 io_data_->InitializeOnUIThread(profile_); |
358 } | 379 } |
359 | 380 |
360 ProfileImplIOData::LazyParams::LazyParams() | 381 ProfileImplIOData::LazyParams::LazyParams() |
361 : cache_max_size(0), | 382 : cache_max_size(0), |
362 media_cache_max_size(0), | 383 media_cache_max_size(0), |
363 session_cookie_mode( | 384 session_cookie_mode( |
364 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES) {} | 385 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES) {} |
365 | 386 |
366 ProfileImplIOData::LazyParams::~LazyParams() {} | 387 ProfileImplIOData::LazyParams::~LazyParams() {} |
(...skipping 17 matching lines...) Expand all Loading... |
384 | 405 |
385 void ProfileImplIOData::InitializeInternal( | 406 void ProfileImplIOData::InitializeInternal( |
386 ProfileParams* profile_params, | 407 ProfileParams* profile_params, |
387 content::ProtocolHandlerMap* protocol_handlers, | 408 content::ProtocolHandlerMap* protocol_handlers, |
388 content::URLRequestInterceptorScopedVector request_interceptors) const { | 409 content::URLRequestInterceptorScopedVector request_interceptors) const { |
389 net::URLRequestContext* main_context = main_request_context(); | 410 net::URLRequestContext* main_context = main_request_context(); |
390 | 411 |
391 IOThread* const io_thread = profile_params->io_thread; | 412 IOThread* const io_thread = profile_params->io_thread; |
392 IOThread::Globals* const io_thread_globals = io_thread->globals(); | 413 IOThread::Globals* const io_thread_globals = io_thread->globals(); |
393 | 414 |
| 415 #if defined(SPDY_PROXY_AUTH_ORIGIN) |
| 416 data_reduction_proxy_auth_request_handler_.reset( |
| 417 new data_reduction_proxy::DataReductionProxyAuthRequestHandler( |
| 418 DataReductionProxyChromeSettings::GetClient(), |
| 419 DataReductionProxyChromeSettings::GetBuildAndPatchNumber(), |
| 420 data_reduction_proxy_params_.get(), |
| 421 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); |
| 422 data_reduction_proxy_usage_stats_.reset( |
| 423 new data_reduction_proxy::DataReductionProxyUsageStats( |
| 424 data_reduction_proxy_params_.get(), |
| 425 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI))); |
| 426 data_reduction_proxy_usage_stats_->set_unavailable_callback( |
| 427 data_reduction_proxy_unavailable_callback_); |
| 428 |
| 429 |
| 430 network_delegate()->set_data_reduction_proxy_params( |
| 431 data_reduction_proxy_params_.get()); |
| 432 network_delegate()->set_data_reduction_proxy_usage_stats( |
| 433 data_reduction_proxy_usage_stats_.get()); |
| 434 network_delegate()->set_data_reduction_proxy_auth_request_handler( |
| 435 data_reduction_proxy_auth_request_handler_.get()); |
| 436 network_delegate()->set_on_resolve_proxy_handler( |
| 437 base::Bind(data_reduction_proxy::OnResolveProxyHandler)); |
| 438 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) |
| 439 |
394 network_delegate()->set_predictor(predictor_.get()); | 440 network_delegate()->set_predictor(predictor_.get()); |
395 | 441 |
396 // Initialize context members. | 442 // Initialize context members. |
397 | 443 |
398 ApplyProfileParamsToContext(main_context); | 444 ApplyProfileParamsToContext(main_context); |
399 | 445 |
400 if (http_server_properties_manager_) | 446 if (http_server_properties_manager_) |
401 http_server_properties_manager_->InitializeOnNetworkThread(); | 447 http_server_properties_manager_->InitializeOnNetworkThread(); |
402 | 448 |
403 main_context->set_transport_security_state(transport_security_state()); | 449 main_context->set_transport_security_state(transport_security_state()); |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 const base::Closure& completion) { | 817 const base::Closure& completion) { |
772 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 818 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
773 DCHECK(initialized()); | 819 DCHECK(initialized()); |
774 | 820 |
775 DCHECK(transport_security_state()); | 821 DCHECK(transport_security_state()); |
776 // Completes synchronously. | 822 // Completes synchronously. |
777 transport_security_state()->DeleteAllDynamicDataSince(time); | 823 transport_security_state()->DeleteAllDynamicDataSince(time); |
778 DCHECK(http_server_properties_manager_); | 824 DCHECK(http_server_properties_manager_); |
779 http_server_properties_manager_->Clear(completion); | 825 http_server_properties_manager_->Clear(completion); |
780 } | 826 } |
OLD | NEW |