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

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: Added suggestion from sgurun 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/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 "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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 int cache_max_size, 143 int cache_max_size,
134 const base::FilePath& media_cache_path, 144 const base::FilePath& media_cache_path,
135 int media_cache_max_size, 145 int media_cache_max_size,
136 const base::FilePath& extensions_cookie_path, 146 const base::FilePath& extensions_cookie_path,
137 const base::FilePath& profile_path, 147 const base::FilePath& profile_path,
138 const base::FilePath& infinite_cache_path, 148 const base::FilePath& infinite_cache_path,
139 chrome_browser_net::Predictor* predictor, 149 chrome_browser_net::Predictor* predictor,
140 content::CookieStoreConfig::SessionCookieMode session_cookie_mode, 150 content::CookieStoreConfig::SessionCookieMode session_cookie_mode,
141 quota::SpecialStoragePolicy* special_storage_policy, 151 quota::SpecialStoragePolicy* special_storage_policy,
142 scoped_ptr<domain_reliability::DomainReliabilityMonitor> 152 scoped_ptr<domain_reliability::DomainReliabilityMonitor>
143 domain_reliability_monitor) { 153 domain_reliability_monitor,
154 const base::Callback<void(bool)>& data_reduction_proxy_unavailable,
155 scoped_ptr<data_reduction_proxy::DataReductionProxyParams>
156 data_reduction_proxy_params) {
144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
145 DCHECK(!io_data_->lazy_params_); 158 DCHECK(!io_data_->lazy_params_);
146 DCHECK(predictor); 159 DCHECK(predictor);
147 160
148 LazyParams* lazy_params = new LazyParams(); 161 LazyParams* lazy_params = new LazyParams();
149 162
150 lazy_params->cookie_path = cookie_path; 163 lazy_params->cookie_path = cookie_path;
151 lazy_params->channel_id_path = channel_id_path; 164 lazy_params->channel_id_path = channel_id_path;
152 lazy_params->cache_path = cache_path; 165 lazy_params->cache_path = cache_path;
153 lazy_params->cache_max_size = cache_max_size; 166 lazy_params->cache_max_size = cache_max_size;
154 lazy_params->media_cache_path = media_cache_path; 167 lazy_params->media_cache_path = media_cache_path;
155 lazy_params->media_cache_max_size = media_cache_max_size; 168 lazy_params->media_cache_max_size = media_cache_max_size;
156 lazy_params->extensions_cookie_path = extensions_cookie_path; 169 lazy_params->extensions_cookie_path = extensions_cookie_path;
157 lazy_params->infinite_cache_path = infinite_cache_path; 170 lazy_params->infinite_cache_path = infinite_cache_path;
158 lazy_params->session_cookie_mode = session_cookie_mode; 171 lazy_params->session_cookie_mode = session_cookie_mode;
159 lazy_params->special_storage_policy = special_storage_policy; 172 lazy_params->special_storage_policy = special_storage_policy;
160 173
161 io_data_->lazy_params_.reset(lazy_params); 174 io_data_->lazy_params_.reset(lazy_params);
162 175
163 // Keep track of profile path and cache sizes separately so we can use them 176 // Keep track of profile path and cache sizes separately so we can use them
164 // on demand when creating storage isolated URLRequestContextGetters. 177 // on demand when creating storage isolated URLRequestContextGetters.
165 io_data_->profile_path_ = profile_path; 178 io_data_->profile_path_ = profile_path;
166 io_data_->app_cache_max_size_ = cache_max_size; 179 io_data_->app_cache_max_size_ = cache_max_size;
167 io_data_->app_media_cache_max_size_ = media_cache_max_size; 180 io_data_->app_media_cache_max_size_ = media_cache_max_size;
168 181
169 io_data_->predictor_.reset(predictor); 182 io_data_->predictor_.reset(predictor);
170 io_data_->domain_reliability_monitor_ = domain_reliability_monitor.Pass(); 183 io_data_->domain_reliability_monitor_ = domain_reliability_monitor.Pass();
171 184
172 io_data_->InitializeMetricsEnabledStateOnUIThread(); 185 io_data_->InitializeMetricsEnabledStateOnUIThread();
186
187 #if defined(SPDY_PROXY_AUTH_ORIGIN)
188 io_data_->data_reduction_proxy_unavailable_callback_ =
189 data_reduction_proxy_unavailable;
190 io_data_->data_reduction_proxy_params_ =
191 data_reduction_proxy_params.Pass();
192 #endif // defined(SPDY_PROXY_AUTH_ORIGIN)
173 } 193 }
174 194
175 content::ResourceContext* 195 content::ResourceContext*
176 ProfileImplIOData::Handle::GetResourceContext() const { 196 ProfileImplIOData::Handle::GetResourceContext() const {
177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 197 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
178 LazyInitialize(); 198 LazyInitialize();
179 return GetResourceContextNoInit(); 199 return GetResourceContextNoInit();
180 } 200 }
181 201
182 content::ResourceContext* 202 content::ResourceContext*
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 io_data_->session_startup_pref()->Init( 361 io_data_->session_startup_pref()->Init(
342 prefs::kRestoreOnStartup, pref_service); 362 prefs::kRestoreOnStartup, pref_service);
343 io_data_->session_startup_pref()->MoveToThread( 363 io_data_->session_startup_pref()->MoveToThread(
344 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); 364 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
345 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING) 365 #if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING)
346 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled, 366 io_data_->safe_browsing_enabled()->Init(prefs::kSafeBrowsingEnabled,
347 pref_service); 367 pref_service);
348 io_data_->safe_browsing_enabled()->MoveToThread( 368 io_data_->safe_browsing_enabled()->MoveToThread(
349 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); 369 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
350 #endif 370 #endif
351 #if defined(OS_ANDROID) || defined(OS_IOS) 371 #if defined(SPDY_PROXY_AUTH_ORIGIN)
352 io_data_->data_reduction_proxy_enabled()->Init( 372 io_data_->data_reduction_proxy_enabled()->Init(
353 data_reduction_proxy::prefs::kDataReductionProxyEnabled, pref_service); 373 data_reduction_proxy::prefs::kDataReductionProxyEnabled, pref_service);
354 io_data_->data_reduction_proxy_enabled()->MoveToThread( 374 io_data_->data_reduction_proxy_enabled()->MoveToThread(
355 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); 375 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
356 #endif 376 #endif // defined(SPDY_PROXY_AUTH_ORIGIN)
357 io_data_->InitializeOnUIThread(profile_); 377 io_data_->InitializeOnUIThread(profile_);
358 } 378 }
359 379
360 ProfileImplIOData::LazyParams::LazyParams() 380 ProfileImplIOData::LazyParams::LazyParams()
361 : cache_max_size(0), 381 : cache_max_size(0),
362 media_cache_max_size(0), 382 media_cache_max_size(0),
363 session_cookie_mode( 383 session_cookie_mode(
364 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES) {} 384 content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES) {}
365 385
366 ProfileImplIOData::LazyParams::~LazyParams() {} 386 ProfileImplIOData::LazyParams::~LazyParams() {}
(...skipping 17 matching lines...) Expand all
384 404
385 void ProfileImplIOData::InitializeInternal( 405 void ProfileImplIOData::InitializeInternal(
386 ProfileParams* profile_params, 406 ProfileParams* profile_params,
387 content::ProtocolHandlerMap* protocol_handlers, 407 content::ProtocolHandlerMap* protocol_handlers,
388 content::URLRequestInterceptorScopedVector request_interceptors) const { 408 content::URLRequestInterceptorScopedVector request_interceptors) const {
389 net::URLRequestContext* main_context = main_request_context(); 409 net::URLRequestContext* main_context = main_request_context();
390 410
391 IOThread* const io_thread = profile_params->io_thread; 411 IOThread* const io_thread = profile_params->io_thread;
392 IOThread::Globals* const io_thread_globals = io_thread->globals(); 412 IOThread::Globals* const io_thread_globals = io_thread->globals();
393 413
414 #if defined(SPDY_PROXY_AUTH_ORIGIN)
415 data_reduction_proxy_auth_request_handler_.reset(
416 new data_reduction_proxy::DataReductionProxyAuthRequestHandler(
417 data_reduction_proxy_params_.get(),
418 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
419 data_reduction_proxy_usage_stats_.reset(
420 new data_reduction_proxy::DataReductionProxyUsageStats(
421 data_reduction_proxy_params_.get(),
422 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)));
423 data_reduction_proxy_usage_stats_->set_unavailable_callback(
424 data_reduction_proxy_unavailable_callback_);
425
426
427 network_delegate()->set_data_reduction_proxy_params(
428 data_reduction_proxy_params_.get());
429 network_delegate()->set_data_reduction_proxy_usage_stats(
430 data_reduction_proxy_usage_stats_.get());
431 network_delegate()->set_data_reduction_proxy_auth_request_handler(
432 data_reduction_proxy_auth_request_handler_.get());
433 network_delegate()->set_on_resolve_proxy_handler(
434 base::Bind(data_reduction_proxy::OnResolveProxyHandler));
435 #endif // defined(SPDY_PROXY_AUTH_ORIGIN)
436
394 network_delegate()->set_predictor(predictor_.get()); 437 network_delegate()->set_predictor(predictor_.get());
395 438
396 // Initialize context members. 439 // Initialize context members.
397 440
398 ApplyProfileParamsToContext(main_context); 441 ApplyProfileParamsToContext(main_context);
399 442
400 if (http_server_properties_manager_) 443 if (http_server_properties_manager_)
401 http_server_properties_manager_->InitializeOnNetworkThread(); 444 http_server_properties_manager_->InitializeOnNetworkThread();
402 445
403 main_context->set_transport_security_state(transport_security_state()); 446 main_context->set_transport_security_state(transport_security_state());
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 const base::Closure& completion) { 814 const base::Closure& completion) {
772 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 815 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
773 DCHECK(initialized()); 816 DCHECK(initialized());
774 817
775 DCHECK(transport_security_state()); 818 DCHECK(transport_security_state());
776 // Completes synchronously. 819 // Completes synchronously.
777 transport_security_state()->DeleteAllDynamicDataSince(time); 820 transport_security_state()->DeleteAllDynamicDataSince(time);
778 DCHECK(http_server_properties_manager_); 821 DCHECK(http_server_properties_manager_);
779 http_server_properties_manager_->Clear(completion); 822 http_server_properties_manager_->Clear(completion);
780 } 823 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698