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

Side by Side Diff: chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc

Issue 792803007: Make Data Reduction Proxy a best effort proxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated tests Created 5 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/net/spdyproxy/data_reduction_proxy_chrome_settings.h" 5 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/prefs/scoped_user_pref_update.h"
9 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" 11 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
11 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator. h" 12 #include "chrome/browser/prefs/proxy_prefs.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
15 #include "chrome/common/pref_names.h"
14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth _request_handler.h" 16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth _request_handler.h"
15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf igurator.h" 17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf igurator.h"
16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h" 18 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h"
17 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" 19 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h"
18 #include "net/url_request/url_request_context_getter.h" 20 #include "net/url_request/url_request_context_getter.h"
19 21
20 using data_reduction_proxy::Client; 22 using data_reduction_proxy::Client;
21 using data_reduction_proxy::DataReductionProxyParams; 23 using data_reduction_proxy::DataReductionProxyParams;
22 using data_reduction_proxy::DataReductionProxySettings; 24 using data_reduction_proxy::DataReductionProxySettings;
23 25
26 // The Data Reduction Proxy has been turned into a "best effort" proxy,
27 // meaning it is used only if the effective proxy configuration resolves to
28 // DIRECT for a URL. It no longer can be a ProxyConfig in the proxy preference
29 // hierarchy. This method removes the Data Reduction Proxy configuration from
30 // prefs, if present. |proxy_pref_name| is the name of the proxy pref.
31 void MigrateDataReductionProxyOffProxyPrefs(PrefService* prefs) {
32 DictionaryPrefUpdate update(prefs, prefs::kProxy);
33 base::DictionaryValue* dict = update.Get();
34 std::string mode;
35 if (!dict->GetString("mode", &mode))
36 return;
37 if (ProxyModeToString(ProxyPrefs::MODE_FIXED_SERVERS) != mode)
38 return;
39 std::string proxy_server;
40 if (!dict->GetString("server", &proxy_server))
41 return;
42 net::ProxyConfig::ProxyRules proxy_rules;
43 proxy_rules.ParseFromString(proxy_server);
44 if (!data_reduction_proxy::DataReductionProxyConfigurator::
45 ContainsDataReductionProxy(proxy_rules)) {
46 return;
47 }
48 dict->SetString("mode", ProxyModeToString(ProxyPrefs::MODE_SYSTEM));
49 dict->SetString("server", "");
50 dict->SetString("bypass_list", "");
51 }
52
24 DataReductionProxyChromeSettings::DataReductionProxyChromeSettings( 53 DataReductionProxyChromeSettings::DataReductionProxyChromeSettings(
25 DataReductionProxyParams* params) : DataReductionProxySettings(params) { 54 DataReductionProxyParams* params) : DataReductionProxySettings(params) {
26 } 55 }
27 56
28 DataReductionProxyChromeSettings::~DataReductionProxyChromeSettings() { 57 DataReductionProxyChromeSettings::~DataReductionProxyChromeSettings() {
29 } 58 }
30 59
31 void DataReductionProxyChromeSettings::InitDataReductionProxySettings( 60 void DataReductionProxyChromeSettings::InitDataReductionProxySettings(
32 data_reduction_proxy::DataReductionProxyConfigurator* configurator, 61 data_reduction_proxy::DataReductionProxyConfigurator* configurator,
33 PrefService* profile_prefs, 62 PrefService* profile_prefs,
34 PrefService* local_state_prefs, 63 PrefService* local_state_prefs,
35 net::URLRequestContextGetter* request_context, 64 net::URLRequestContextGetter* request_context,
36 net::NetLog* net_log, 65 net::NetLog* net_log,
37 data_reduction_proxy::DataReductionProxyEventStore* event_store) { 66 data_reduction_proxy::DataReductionProxyEventStore* event_store) {
38 SetProxyConfigurator(configurator); 67 SetProxyConfigurator(configurator);
39 DataReductionProxySettings::InitDataReductionProxySettings( 68 DataReductionProxySettings::InitDataReductionProxySettings(
40 profile_prefs, 69 profile_prefs,
41 request_context, 70 request_context,
42 net_log, 71 net_log,
43 event_store); 72 event_store);
44 DataReductionProxySettings::SetOnDataReductionEnabledCallback( 73 DataReductionProxySettings::SetOnDataReductionEnabledCallback(
45 base::Bind(&DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial, 74 base::Bind(&DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial,
46 base::Unretained(this))); 75 base::Unretained(this)));
47 SetDataReductionProxyAlternativeEnabled( 76 SetDataReductionProxyAlternativeEnabled(
48 DataReductionProxyParams::IsIncludedInAlternativeFieldTrial()); 77 DataReductionProxyParams::IsIncludedInAlternativeFieldTrial());
78 // TODO(bengr): Remove after M46. See http://crbug.com/445599.
79 MigrateDataReductionProxyOffProxyPrefs(profile_prefs);
49 } 80 }
50 81
51 void DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial( 82 void DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial(
52 bool data_reduction_proxy_enabled) { 83 bool data_reduction_proxy_enabled) {
53 ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial( 84 ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial(
54 "DataReductionProxyEnabled", 85 "DataReductionProxyEnabled",
55 data_reduction_proxy_enabled ? "true" : "false"); 86 data_reduction_proxy_enabled ? "true" : "false");
56 } 87 }
57 88
58 // static 89 // static
(...skipping 15 matching lines...) Expand all
74 #elif defined(OS_OPENBSD) 105 #elif defined(OS_OPENBSD)
75 return Client::CHROME_OPENBSD; 106 return Client::CHROME_OPENBSD;
76 #elif defined(OS_SOLARIS) 107 #elif defined(OS_SOLARIS)
77 return Client::CHROME_SOLARIS; 108 return Client::CHROME_SOLARIS;
78 #elif defined(OS_QNX) 109 #elif defined(OS_QNX)
79 return Client::CHROME_QNX; 110 return Client::CHROME_QNX;
80 #else 111 #else
81 return Client::UNKNOWN; 112 return Client::UNKNOWN;
82 #endif 113 #endif
83 } 114 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698