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

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, 4 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(SPDY_PROXY_AUTH_ORIGIN)
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,
135 scoped_ptr<data_reduction_proxy::DataReductionProxyParams>
136 data_reduction_proxy_params) {
124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
125 DCHECK(!io_data_->lazy_params_); 138 DCHECK(!io_data_->lazy_params_);
126 DCHECK(predictor); 139 DCHECK(predictor);
127 140
128 LazyParams* lazy_params = new LazyParams(); 141 LazyParams* lazy_params = new LazyParams();
129 142
130 lazy_params->cookie_path = cookie_path; 143 lazy_params->cookie_path = cookie_path;
131 lazy_params->server_bound_cert_path = server_bound_cert_path; 144 lazy_params->server_bound_cert_path = server_bound_cert_path;
132 lazy_params->cache_path = cache_path; 145 lazy_params->cache_path = cache_path;
133 lazy_params->cache_max_size = cache_max_size; 146 lazy_params->cache_max_size = cache_max_size;
134 lazy_params->media_cache_path = media_cache_path; 147 lazy_params->media_cache_path = media_cache_path;
135 lazy_params->media_cache_max_size = media_cache_max_size; 148 lazy_params->media_cache_max_size = media_cache_max_size;
136 lazy_params->extensions_cookie_path = extensions_cookie_path; 149 lazy_params->extensions_cookie_path = extensions_cookie_path;
137 lazy_params->infinite_cache_path = infinite_cache_path; 150 lazy_params->infinite_cache_path = infinite_cache_path;
138 lazy_params->session_cookie_mode = session_cookie_mode; 151 lazy_params->session_cookie_mode = session_cookie_mode;
139 lazy_params->special_storage_policy = special_storage_policy; 152 lazy_params->special_storage_policy = special_storage_policy;
140 153
141 io_data_->lazy_params_.reset(lazy_params); 154 io_data_->lazy_params_.reset(lazy_params);
142 155
143 // Keep track of profile path and cache sizes separately so we can use them 156 // Keep track of profile path and cache sizes separately so we can use them
144 // on demand when creating storage isolated URLRequestContextGetters. 157 // on demand when creating storage isolated URLRequestContextGetters.
145 io_data_->profile_path_ = profile_path; 158 io_data_->profile_path_ = profile_path;
146 io_data_->app_cache_max_size_ = cache_max_size; 159 io_data_->app_cache_max_size_ = cache_max_size;
147 io_data_->app_media_cache_max_size_ = media_cache_max_size; 160 io_data_->app_media_cache_max_size_ = media_cache_max_size;
148 161
149 io_data_->predictor_.reset(predictor); 162 io_data_->predictor_.reset(predictor);
150 io_data_->domain_reliability_monitor_ = domain_reliability_monitor.Pass(); 163 io_data_->domain_reliability_monitor_ = domain_reliability_monitor.Pass();
151 164
152 io_data_->InitializeMetricsEnabledStateOnUIThread(); 165 io_data_->InitializeMetricsEnabledStateOnUIThread();
166
167 #if defined(SPDY_PROXY_AUTH_ORIGIN)
168 io_data_->data_reduction_proxy_unavailable_callback_ =
169 data_reduction_proxy_unavailable;
170 io_data_->data_reduction_proxy_params_ =
171 data_reduction_proxy_params.Pass();
172 #endif // defined(SPDY_PROXY_AUTH_ORIGIN)
153 } 173 }
154 174
155 content::ResourceContext* 175 content::ResourceContext*
156 ProfileImplIOData::Handle::GetResourceContext() const { 176 ProfileImplIOData::Handle::GetResourceContext() const {
157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
158 LazyInitialize(); 178 LazyInitialize();
159 return GetResourceContextNoInit(); 179 return GetResourceContextNoInit();
160 } 180 }
161 181
162 content::ResourceContext* 182 content::ResourceContext*
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 io_data_->session_startup_pref()->Init( 341 io_data_->session_startup_pref()->Init(
322 prefs::kRestoreOnStartup, pref_service); 342 prefs::kRestoreOnStartup, pref_service);
323 io_data_->session_startup_pref()->MoveToThread( 343 io_data_->session_startup_pref()->MoveToThread(
324 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); 344 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
325 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) 345 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING)
326 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled, 346 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled,
327 pref_service); 347 pref_service);
328 io_data_->safe_browsing_enabled()->MoveToThread( 348 io_data_->safe_browsing_enabled()->MoveToThread(
329 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); 349 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
330 #endif 350 #endif
331 #if defined(OS_ANDROID) || defined(OS_IOS) 351 #if defined(SPDY_PROXY_AUTH_ORIGIN)
332 io_data_->data_reduction_proxy_enabled()->Init( 352 io_data_->data_reduction_proxy_enabled()->Init(
333 data_reduction_proxy::prefs::kDataReductionProxyEnabled, pref_service); 353 data_reduction_proxy::prefs::kDataReductionProxyEnabled, pref_service);
334 io_data_->data_reduction_proxy_enabled()->MoveToThread( 354 io_data_->data_reduction_proxy_enabled()->MoveToThread(
335 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); 355 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
336 #endif 356 #endif // defined(SPDY_PROXY_AUTH_ORIGIN)
337 io_data_->InitializeOnUIThread(profile_); 357 io_data_->InitializeOnUIThread(profile_);
338 } 358 }
339 359
340 ProfileImplIOData::LazyParams::LazyParams() 360 ProfileImplIOData::LazyParams::LazyParams()
341 : cache_max_size(0), 361 : cache_max_size(0),
342 media_cache_max_size(0), 362 media_cache_max_size(0),
343 session_cookie_mode( 363 session_cookie_mode(
344 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES) {} 364 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES) {}
345 365
346 ProfileImplIOData::LazyParams::~LazyParams() {} 366 ProfileImplIOData::LazyParams::~LazyParams() {}
(...skipping 17 matching lines...) Expand all
364 384
365 void ProfileImplIOData::InitializeInternal( 385 void ProfileImplIOData::InitializeInternal(
366 ProfileParams* profile_params, 386 ProfileParams* profile_params,
367 content::ProtocolHandlerMap* protocol_handlers, 387 content::ProtocolHandlerMap* protocol_handlers,
368 content::URLRequestInterceptorScopedVector request_interceptors) const { 388 content::URLRequestInterceptorScopedVector request_interceptors) const {
369 ChromeURLRequestContext* main_context = main_request_context(); 389 ChromeURLRequestContext* main_context = main_request_context();
370 390
371 IOThread* const io_thread = profile_params->io_thread; 391 IOThread* const io_thread = profile_params->io_thread;
372 IOThread::Globals* const io_thread_globals = io_thread->globals(); 392 IOThread::Globals* const io_thread_globals = io_thread->globals();
373 393
394 #if defined(SPDY_PROXY_AUTH_ORIGIN)
395 data_reduction_proxy_auth_request_handler_.reset(
396 new data_reduction_proxy::DataReductionProxyAuthRequestHandler(
397 data_reduction_proxy_params_.get(),
398 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
399 data_reduction_proxy_usage_stats_.reset(
400 new data_reduction_proxy::DataReductionProxyUsageStats(
401 data_reduction_proxy_params_.get(),
402 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)));
403 data_reduction_proxy_usage_stats_->set_unavailable_callback(
404 data_reduction_proxy_unavailable_callback_);
405
406
407 network_delegate()->set_data_reduction_proxy_params(
408 data_reduction_proxy_params_.get());
409 network_delegate()->set_data_reduction_proxy_usage_stats(
410 data_reduction_proxy_usage_stats_.get());
411 network_delegate()->set_data_reduction_proxy_auth_request_handler(
412 data_reduction_proxy_auth_request_handler_.get());
413 network_delegate()->set_on_resolve_proxy_handler(
414 base::Bind(data_reduction_proxy::OnResolveProxyHandler));
415 #endif // defined(SPDY_PROXY_AUTH_ORIGIN)
416
374 network_delegate()->set_predictor(predictor_.get()); 417 network_delegate()->set_predictor(predictor_.get());
375 418
376 // Initialize context members. 419 // Initialize context members.
377 420
378 ApplyProfileParamsToContext(main_context); 421 ApplyProfileParamsToContext(main_context);
379 422
380 if (http_server_properties_manager_) 423 if (http_server_properties_manager_)
381 http_server_properties_manager_->InitializeOnNetworkThread(); 424 http_server_properties_manager_->InitializeOnNetworkThread();
382 425
383 main_context->set_transport_security_state(transport_security_state()); 426 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) { 794 const base::Closure& completion) {
752 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 795 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
753 DCHECK(initialized()); 796 DCHECK(initialized());
754 797
755 DCHECK(transport_security_state()); 798 DCHECK(transport_security_state());
756 // Completes synchronously. 799 // Completes synchronously.
757 transport_security_state()->DeleteAllDynamicDataSince(time); 800 transport_security_state()->DeleteAllDynamicDataSince(time);
758 DCHECK(http_server_properties_manager_); 801 DCHECK(http_server_properties_manager_);
759 http_server_properties_manager_->Clear(completion); 802 http_server_properties_manager_->Clear(completion);
760 } 803 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698