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

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

Issue 684223003: Data Reduction Proxy Interstitials (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding tests and addressing comments Created 6 years 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 #include "net/base/cache_type.h" 55 #include "net/base/cache_type.h"
56 #include "net/base/sdch_manager.h" 56 #include "net/base/sdch_manager.h"
57 #include "net/ftp/ftp_network_layer.h" 57 #include "net/ftp/ftp_network_layer.h"
58 #include "net/http/http_cache.h" 58 #include "net/http/http_cache.h"
59 #include "net/http/http_server_properties_manager.h" 59 #include "net/http/http_server_properties_manager.h"
60 #include "net/ssl/channel_id_service.h" 60 #include "net/ssl/channel_id_service.h"
61 #include "net/url_request/url_request_intercepting_job_factory.h" 61 #include "net/url_request/url_request_intercepting_job_factory.h"
62 #include "net/url_request/url_request_job_factory_impl.h" 62 #include "net/url_request/url_request_job_factory_impl.h"
63 #include "storage/browser/quota/special_storage_policy.h" 63 #include "storage/browser/quota/special_storage_policy.h"
64 64
65 #if defined(OS_ANDROID)
66 #include "components/data_reduction_proxy/content/browser/data_reduction_proxy_u i_service.h"
67 #endif
68
65 namespace { 69 namespace {
66 70
67 net::BackendType ChooseCacheBackendType() { 71 net::BackendType ChooseCacheBackendType() {
68 #if defined(OS_ANDROID) 72 #if defined(OS_ANDROID)
69 return net::CACHE_BACKEND_SIMPLE; 73 return net::CACHE_BACKEND_SIMPLE;
70 #else 74 #else
71 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 75 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
72 if (command_line.HasSwitch(switches::kUseSimpleCacheBackend)) { 76 if (command_line.HasSwitch(switches::kUseSimpleCacheBackend)) {
73 const std::string opt_value = 77 const std::string opt_value =
74 command_line.GetSwitchValueASCII(switches::kUseSimpleCacheBackend); 78 command_line.GetSwitchValueASCII(switches::kUseSimpleCacheBackend);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 storage::SpecialStoragePolicy* special_storage_policy, 142 storage::SpecialStoragePolicy* special_storage_policy,
139 scoped_ptr<domain_reliability::DomainReliabilityMonitor> 143 scoped_ptr<domain_reliability::DomainReliabilityMonitor>
140 domain_reliability_monitor, 144 domain_reliability_monitor,
141 const base::Callback<void(bool)>& data_reduction_proxy_unavailable, 145 const base::Callback<void(bool)>& data_reduction_proxy_unavailable,
142 scoped_ptr<DataReductionProxyChromeConfigurator> 146 scoped_ptr<DataReductionProxyChromeConfigurator>
143 data_reduction_proxy_chrome_configurator, 147 data_reduction_proxy_chrome_configurator,
144 scoped_ptr<data_reduction_proxy::DataReductionProxyParams> 148 scoped_ptr<data_reduction_proxy::DataReductionProxyParams>
145 data_reduction_proxy_params, 149 data_reduction_proxy_params,
146 scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs> 150 scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>
147 data_reduction_proxy_statistics_prefs, 151 data_reduction_proxy_statistics_prefs,
152 #if defined(OS_ANDROID)
153 scoped_ptr<data_reduction_proxy::DataReductionProxyUIService>
154 data_reduction_proxy_ui_service,
155 #endif
148 scoped_ptr<data_reduction_proxy::DataReductionProxyEventStore> 156 scoped_ptr<data_reduction_proxy::DataReductionProxyEventStore>
149 data_reduction_proxy_event_store) { 157 data_reduction_proxy_event_store) {
150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 158 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
151 DCHECK(!io_data_->lazy_params_); 159 DCHECK(!io_data_->lazy_params_);
152 DCHECK(predictor); 160 DCHECK(predictor);
153 161
154 LazyParams* lazy_params = new LazyParams(); 162 LazyParams* lazy_params = new LazyParams();
155 163
156 lazy_params->cookie_path = cookie_path; 164 lazy_params->cookie_path = cookie_path;
157 lazy_params->channel_id_path = channel_id_path; 165 lazy_params->channel_id_path = channel_id_path;
(...skipping 21 matching lines...) Expand all
179 if (io_data_->domain_reliability_monitor_) 187 if (io_data_->domain_reliability_monitor_)
180 io_data_->domain_reliability_monitor_->MoveToNetworkThread(); 188 io_data_->domain_reliability_monitor_->MoveToNetworkThread();
181 189
182 io_data_->set_data_reduction_proxy_unavailable_callback( 190 io_data_->set_data_reduction_proxy_unavailable_callback(
183 data_reduction_proxy_unavailable); 191 data_reduction_proxy_unavailable);
184 io_data_->set_data_reduction_proxy_chrome_configurator( 192 io_data_->set_data_reduction_proxy_chrome_configurator(
185 data_reduction_proxy_chrome_configurator.Pass()); 193 data_reduction_proxy_chrome_configurator.Pass());
186 io_data_->set_data_reduction_proxy_params(data_reduction_proxy_params.Pass()); 194 io_data_->set_data_reduction_proxy_params(data_reduction_proxy_params.Pass());
187 io_data_->set_data_reduction_proxy_statistics_prefs( 195 io_data_->set_data_reduction_proxy_statistics_prefs(
188 data_reduction_proxy_statistics_prefs.Pass()); 196 data_reduction_proxy_statistics_prefs.Pass());
197 #if defined(OS_ANDROID)
198 io_data_->set_data_reduction_proxy_ui_service(
199 data_reduction_proxy_ui_service.Pass());
200 #endif
189 io_data_->set_data_reduction_proxy_event_store( 201 io_data_->set_data_reduction_proxy_event_store(
190 data_reduction_proxy_event_store.Pass()); 202 data_reduction_proxy_event_store.Pass());
191 } 203 }
192 204
193 content::ResourceContext* 205 content::ResourceContext*
194 ProfileImplIOData::Handle::GetResourceContext() const { 206 ProfileImplIOData::Handle::GetResourceContext() const {
195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 207 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
196 LazyInitialize(); 208 LazyInitialize();
197 return GetResourceContextNoInit(); 209 return GetResourceContextNoInit();
198 } 210 }
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 data_reduction_proxy_params(), 477 data_reduction_proxy_params(),
466 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)))); 478 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))));
467 set_data_reduction_proxy_usage_stats( 479 set_data_reduction_proxy_usage_stats(
468 scoped_ptr<data_reduction_proxy::DataReductionProxyUsageStats> 480 scoped_ptr<data_reduction_proxy::DataReductionProxyUsageStats>
469 (new data_reduction_proxy::DataReductionProxyUsageStats( 481 (new data_reduction_proxy::DataReductionProxyUsageStats(
470 data_reduction_proxy_params(), 482 data_reduction_proxy_params(),
471 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI) 483 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)
472 .get()))); 484 .get())));
473 data_reduction_proxy_usage_stats()->set_unavailable_callback( 485 data_reduction_proxy_usage_stats()->set_unavailable_callback(
474 data_reduction_proxy_unavailable_callback()); 486 data_reduction_proxy_unavailable_callback());
487 #if defined(OS_ANDROID)
488 if (data_reduction_proxy_ui_service()) {
489 data_reduction_proxy_ui_service()->set_proxy_config_getter(
490 base::Bind(
491 &DataReductionProxyChromeConfigurator::GetProxyConfigOnIOThread,
492 base::Unretained(data_reduction_proxy_chrome_configurator())));
493 }
494 #endif
475 495
476 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436671 is fixed. 496 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436671 is fixed.
477 tracked_objects::ScopedTracker tracking_profile3( 497 tracked_objects::ScopedTracker tracking_profile3(
478 FROM_HERE_WITH_EXPLICIT_FUNCTION( 498 FROM_HERE_WITH_EXPLICIT_FUNCTION(
479 "436671 ProfileImplIOData::InitializeInternal3")); 499 "436671 ProfileImplIOData::InitializeInternal3"));
480 500
481 scoped_ptr<data_reduction_proxy::DataReductionProxyNetworkDelegate> 501 scoped_ptr<data_reduction_proxy::DataReductionProxyNetworkDelegate>
482 data_reduction_proxy_network_delegate( 502 data_reduction_proxy_network_delegate(
483 new data_reduction_proxy::DataReductionProxyNetworkDelegate( 503 new data_reduction_proxy::DataReductionProxyNetworkDelegate(
484 chrome_network_delegate.Pass(), 504 chrome_network_delegate.Pass(),
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 transport_security_state()->DeleteAllDynamicDataSince(time); 928 transport_security_state()->DeleteAllDynamicDataSince(time);
909 DCHECK(http_server_properties_manager_); 929 DCHECK(http_server_properties_manager_);
910 http_server_properties_manager_->Clear(completion); 930 http_server_properties_manager_->Clear(completion);
911 } 931 }
912 932
913 bool ProfileImplIOData::IsDataReductionProxyEnabled() const { 933 bool ProfileImplIOData::IsDataReductionProxyEnabled() const {
914 return data_reduction_proxy_enabled_.GetValue() || 934 return data_reduction_proxy_enabled_.GetValue() ||
915 CommandLine::ForCurrentProcess()->HasSwitch( 935 CommandLine::ForCurrentProcess()->HasSwitch(
916 data_reduction_proxy::switches::kEnableDataReductionProxy); 936 data_reduction_proxy::switches::kEnableDataReductionProxy);
917 } 937 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698