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

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

Issue 412143009: Moved data reduction proxy initialization logic to ProfileImplIOData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
OLDNEW
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
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/server_bound_cert_service.h" 49 #include "net/ssl/server_bound_cert_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 "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ est_handler.h"
55 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol. h"
56 #include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_sta ts.h"
57 #include "components/data_reduction_proxy/common/data_reduction_proxy_pref_names .h"
58 #endif // defined(SPDY_PROXY_AUTH_ORIGIN)
59
53 namespace { 60 namespace {
54 61
55 net::BackendType ChooseCacheBackendType() { 62 net::BackendType ChooseCacheBackendType() {
56 #if defined(OS_ANDROID) 63 #if defined(OS_ANDROID)
57 return net::CACHE_BACKEND_SIMPLE; 64 return net::CACHE_BACKEND_SIMPLE;
58 #else 65 #else
59 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 66 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
60 if (command_line.HasSwitch(switches::kUseSimpleCacheBackend)) { 67 if (command_line.HasSwitch(switches::kUseSimpleCacheBackend)) {
61 const std::string opt_value = 68 const std::string opt_value =
62 command_line.GetSwitchValueASCII(switches::kUseSimpleCacheBackend); 69 command_line.GetSwitchValueASCII(switches::kUseSimpleCacheBackend);
63 if (LowerCaseEqualsASCII(opt_value, "off")) 70 if (LowerCaseEqualsASCII(opt_value, "off"))
64 return net::CACHE_BACKEND_BLOCKFILE; 71 return net::CACHE_BACKEND_BLOCKFILE;
65 if (opt_value == "" || LowerCaseEqualsASCII(opt_value, "on")) 72 if (opt_value == "" || LowerCaseEqualsASCII(opt_value, "on"))
66 return net::CACHE_BACKEND_SIMPLE; 73 return net::CACHE_BACKEND_SIMPLE;
67 } 74 }
68 const std::string experiment_name = 75 const std::string experiment_name =
69 base::FieldTrialList::FindFullName("SimpleCacheTrial"); 76 base::FieldTrialList::FindFullName("SimpleCacheTrial");
70 if (experiment_name == "ExperimentYes" || 77 if (experiment_name == "ExperimentYes" ||
71 experiment_name == "ExperimentYes2") { 78 experiment_name == "ExperimentYes2") {
72 return net::CACHE_BACKEND_SIMPLE; 79 return net::CACHE_BACKEND_SIMPLE;
73 } 80 }
74 return net::CACHE_BACKEND_BLOCKFILE; 81 return net::CACHE_BACKEND_BLOCKFILE;
75 #endif 82 #endif
76 } 83 }
77 84
78 } // namespace 85 } // namespace
79 86
80 using content::BrowserThread; 87 using content::BrowserThread;
88 #if defined(SPDY_PROXY_AUTH_ORIGIN)
89 using data_reduction_proxy::DataReductionProxyParams;
90 #endif // defined(OS_ANDROID) || defined(OS_IOS)
81 91
82 ProfileImplIOData::Handle::Handle(Profile* profile) 92 ProfileImplIOData::Handle::Handle(Profile* profile)
83 : io_data_(new ProfileImplIOData), 93 : io_data_(new ProfileImplIOData),
84 profile_(profile), 94 profile_(profile),
85 initialized_(false) { 95 initialized_(false) {
86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
87 DCHECK(profile); 97 DCHECK(profile);
88 } 98 }
89 99
90 ProfileImplIOData::Handle::~Handle() { 100 ProfileImplIOData::Handle::~Handle() {
(...skipping 22 matching lines...) Expand all
113 int cache_max_size, 123 int cache_max_size,
114 const base::FilePath& media_cache_path, 124 const base::FilePath& media_cache_path,
115 int media_cache_max_size, 125 int media_cache_max_size,
116 const base::FilePath& extensions_cookie_path, 126 const base::FilePath& extensions_cookie_path,
117 const base::FilePath& profile_path, 127 const base::FilePath& profile_path,
118 const base::FilePath& infinite_cache_path, 128 const base::FilePath& infinite_cache_path,
119 chrome_browser_net::Predictor* predictor, 129 chrome_browser_net::Predictor* predictor,
120 content::CookieStoreConfig::SessionCookieMode session_cookie_mode, 130 content::CookieStoreConfig::SessionCookieMode session_cookie_mode,
121 quota::SpecialStoragePolicy* special_storage_policy, 131 quota::SpecialStoragePolicy* special_storage_policy,
122 scoped_ptr<domain_reliability::DomainReliabilityMonitor> 132 scoped_ptr<domain_reliability::DomainReliabilityMonitor>
123 domain_reliability_monitor) { 133 domain_reliability_monitor,
134 const base::Callback<void(bool)>& data_reduction_proxy_unavailable) {
124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
125 DCHECK(!io_data_->lazy_params_); 136 DCHECK(!io_data_->lazy_params_);
126 DCHECK(predictor); 137 DCHECK(predictor);
127 138
128 LazyParams* lazy_params = new LazyParams(); 139 LazyParams* lazy_params = new LazyParams();
129 140
130 lazy_params->cookie_path = cookie_path; 141 lazy_params->cookie_path = cookie_path;
131 lazy_params->server_bound_cert_path = server_bound_cert_path; 142 lazy_params->server_bound_cert_path = server_bound_cert_path;
132 lazy_params->cache_path = cache_path; 143 lazy_params->cache_path = cache_path;
133 lazy_params->cache_max_size = cache_max_size; 144 lazy_params->cache_max_size = cache_max_size;
134 lazy_params->media_cache_path = media_cache_path; 145 lazy_params->media_cache_path = media_cache_path;
135 lazy_params->media_cache_max_size = media_cache_max_size; 146 lazy_params->media_cache_max_size = media_cache_max_size;
136 lazy_params->extensions_cookie_path = extensions_cookie_path; 147 lazy_params->extensions_cookie_path = extensions_cookie_path;
137 lazy_params->infinite_cache_path = infinite_cache_path; 148 lazy_params->infinite_cache_path = infinite_cache_path;
138 lazy_params->session_cookie_mode = session_cookie_mode; 149 lazy_params->session_cookie_mode = session_cookie_mode;
139 lazy_params->special_storage_policy = special_storage_policy; 150 lazy_params->special_storage_policy = special_storage_policy;
140 151
141 io_data_->lazy_params_.reset(lazy_params); 152 io_data_->lazy_params_.reset(lazy_params);
142 153
143 // Keep track of profile path and cache sizes separately so we can use them 154 // Keep track of profile path and cache sizes separately so we can use them
144 // on demand when creating storage isolated URLRequestContextGetters. 155 // on demand when creating storage isolated URLRequestContextGetters.
145 io_data_->profile_path_ = profile_path; 156 io_data_->profile_path_ = profile_path;
146 io_data_->app_cache_max_size_ = cache_max_size; 157 io_data_->app_cache_max_size_ = cache_max_size;
147 io_data_->app_media_cache_max_size_ = media_cache_max_size; 158 io_data_->app_media_cache_max_size_ = media_cache_max_size;
148 159
149 io_data_->predictor_.reset(predictor); 160 io_data_->predictor_.reset(predictor);
150 io_data_->domain_reliability_monitor_ = domain_reliability_monitor.Pass(); 161 io_data_->domain_reliability_monitor_ = domain_reliability_monitor.Pass();
151 162
152 io_data_->InitializeMetricsEnabledStateOnUIThread(); 163 io_data_->InitializeMetricsEnabledStateOnUIThread();
164
165 #if defined(SPDY_PROXY_AUTH_ORIGIN)
166 io_data_->data_reduction_proxy_unavailable_callback_ =
167 data_reduction_proxy_unavailable;
168 #endif // defined(SPDY_PROXY_AUTH_ORIGIN)
153 } 169 }
154 170
155 content::ResourceContext* 171 content::ResourceContext*
156 ProfileImplIOData::Handle::GetResourceContext() const { 172 ProfileImplIOData::Handle::GetResourceContext() const {
157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
158 LazyInitialize(); 174 LazyInitialize();
159 return GetResourceContextNoInit(); 175 return GetResourceContextNoInit();
160 } 176 }
161 177
162 content::ResourceContext* 178 content::ResourceContext*
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 io_data_->session_startup_pref()->Init( 337 io_data_->session_startup_pref()->Init(
322 prefs::kRestoreOnStartup, pref_service); 338 prefs::kRestoreOnStartup, pref_service);
323 io_data_->session_startup_pref()->MoveToThread( 339 io_data_->session_startup_pref()->MoveToThread(
324 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); 340 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
325 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) 341 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING)
326 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled, 342 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled,
327 pref_service); 343 pref_service);
328 io_data_->safe_browsing_enabled()->MoveToThread( 344 io_data_->safe_browsing_enabled()->MoveToThread(
329 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); 345 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
330 #endif 346 #endif
331 #if defined(OS_ANDROID) || defined(OS_IOS) 347 #if defined(SPDY_PROXY_AUTH_ORIGIN)
332 io_data_->data_reduction_proxy_enabled()->Init( 348 io_data_->data_reduction_proxy_enabled()->Init(
333 data_reduction_proxy::prefs::kDataReductionProxyEnabled, pref_service); 349 data_reduction_proxy::prefs::kDataReductionProxyEnabled, pref_service);
334 io_data_->data_reduction_proxy_enabled()->MoveToThread( 350 io_data_->data_reduction_proxy_enabled()->MoveToThread(
335 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); 351 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
336 #endif 352 #endif // defined(SPDY_PROXY_AUTH_ORIGIN)
337 io_data_->InitializeOnUIThread(profile_); 353 io_data_->InitializeOnUIThread(profile_);
338 } 354 }
339 355
340 ProfileImplIOData::LazyParams::LazyParams() 356 ProfileImplIOData::LazyParams::LazyParams()
341 : cache_max_size(0), 357 : cache_max_size(0),
342 media_cache_max_size(0), 358 media_cache_max_size(0),
343 session_cookie_mode( 359 session_cookie_mode(
344 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES) {} 360 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES) {}
345 361
346 ProfileImplIOData::LazyParams::~LazyParams() {} 362 ProfileImplIOData::LazyParams::~LazyParams() {}
(...skipping 17 matching lines...) Expand all
364 380
365 void ProfileImplIOData::InitializeInternal( 381 void ProfileImplIOData::InitializeInternal(
366 ProfileParams* profile_params, 382 ProfileParams* profile_params,
367 content::ProtocolHandlerMap* protocol_handlers, 383 content::ProtocolHandlerMap* protocol_handlers,
368 content::URLRequestInterceptorScopedVector request_interceptors) const { 384 content::URLRequestInterceptorScopedVector request_interceptors) const {
369 ChromeURLRequestContext* main_context = main_request_context(); 385 ChromeURLRequestContext* main_context = main_request_context();
370 386
371 IOThread* const io_thread = profile_params->io_thread; 387 IOThread* const io_thread = profile_params->io_thread;
372 IOThread::Globals* const io_thread_globals = io_thread->globals(); 388 IOThread::Globals* const io_thread_globals = io_thread->globals();
373 389
390 #if defined(SPDY_PROXY_AUTH_ORIGIN)
391 // TODO(bengr): Extract parameters from DataReductionProxySettings.
392 int drp_flags = DataReductionProxyParams::kFallbackAllowed;
393 if (DataReductionProxyParams::IsIncludedInFieldTrial())
394 drp_flags |= DataReductionProxyParams::kAllowed;
395 if (DataReductionProxyParams::IsIncludedInAlternativeFieldTrial())
396 drp_flags |= DataReductionProxyParams::kAlternativeAllowed;
397 if (DataReductionProxyParams::IsIncludedInPromoFieldTrial())
398 drp_flags |= DataReductionProxyParams::kPromoAllowed;
399 data_reduction_proxy_params_.reset(
400 new DataReductionProxyParams(drp_flags));
401 data_reduction_proxy_auth_request_handler_.reset(
402 new data_reduction_proxy::DataReductionProxyAuthRequestHandler(
403 data_reduction_proxy_params_.get()));
404 data_reduction_proxy_usage_stats_.reset(
405 new data_reduction_proxy::DataReductionProxyUsageStats(
406 data_reduction_proxy_params_.get(),
407 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
408 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
409 data_reduction_proxy_usage_stats_->set_unavailable_callback(
410 data_reduction_proxy_unavailable_callback_);
411
412
413 network_delegate()->set_data_reduction_proxy_params(
414 data_reduction_proxy_params_.get());
415 network_delegate()->set_data_reduction_proxy_usage_stats(
416 data_reduction_proxy_usage_stats_.get());
417 network_delegate()->set_data_reduction_proxy_auth_request_handler(
418 data_reduction_proxy_auth_request_handler_.get());
419 network_delegate()->set_on_resolve_proxy_handler(
420 base::Bind(data_reduction_proxy::OnResolveProxyHandler));
421 #endif // defined(SPDY_PROXY_AUTH_ORIGIN)
422
374 network_delegate()->set_predictor(predictor_.get()); 423 network_delegate()->set_predictor(predictor_.get());
375 424
376 // Initialize context members. 425 // Initialize context members.
377 426
378 ApplyProfileParamsToContext(main_context); 427 ApplyProfileParamsToContext(main_context);
379 428
380 if (http_server_properties_manager_) 429 if (http_server_properties_manager_)
381 http_server_properties_manager_->InitializeOnNetworkThread(); 430 http_server_properties_manager_->InitializeOnNetworkThread();
382 431
383 main_context->set_transport_security_state(transport_security_state()); 432 main_context->set_transport_security_state(transport_security_state());
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 const base::Closure& completion) { 800 const base::Closure& completion) {
752 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 801 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
753 DCHECK(initialized()); 802 DCHECK(initialized());
754 803
755 DCHECK(transport_security_state()); 804 DCHECK(transport_security_state());
756 // Completes synchronously. 805 // Completes synchronously.
757 transport_security_state()->DeleteAllDynamicDataSince(time); 806 transport_security_state()->DeleteAllDynamicDataSince(time);
758 DCHECK(http_server_properties_manager_); 807 DCHECK(http_server_properties_manager_);
759 http_server_properties_manager_->Clear(completion); 808 http_server_properties_manager_->Clear(completion);
760 } 809 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698