OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_settings.h" | 5 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_settings.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/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 | 201 |
202 // static | 202 // static |
203 bool DataReductionProxySettings::IsPreconnectHintingAllowed() { | 203 bool DataReductionProxySettings::IsPreconnectHintingAllowed() { |
204 if (!IsDataReductionProxyAllowed()) | 204 if (!IsDataReductionProxyAllowed()) |
205 return false; | 205 return false; |
206 return FieldTrialList::FindFullName("DataCompressionProxyPreconnectHints") == | 206 return FieldTrialList::FindFullName("DataCompressionProxyPreconnectHints") == |
207 kEnabled; | 207 kEnabled; |
208 } | 208 } |
209 | 209 |
210 // static | 210 // static |
211 bool DataReductionProxySettings::WasFetchedViaProxy( | |
212 const net::HttpResponseHeaders* headers) { | |
213 const char kChromeProxyViaValue[] = "1.1 Chrome Compression Proxy"; | |
214 void* iter = NULL; | |
215 std::string value; | |
216 while (headers->EnumerateHeader(&iter, "via", &value)) | |
217 if (value == kChromeProxyViaValue) return true; | |
218 return false; | |
219 } | |
220 | |
221 // static | |
222 std::string DataReductionProxySettings::GetDataReductionProxyOrigin() { | 211 std::string DataReductionProxySettings::GetDataReductionProxyOrigin() { |
223 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 212 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
224 if (command_line.HasSwitch(switches::kSpdyProxyDevAuthOrigin)) | 213 if (command_line.HasSwitch(switches::kSpdyProxyDevAuthOrigin)) |
225 return command_line.GetSwitchValueASCII(switches::kSpdyProxyDevAuthOrigin); | 214 return command_line.GetSwitchValueASCII(switches::kSpdyProxyDevAuthOrigin); |
226 if (command_line.HasSwitch(switches::kSpdyProxyAuthOrigin)) | 215 if (command_line.HasSwitch(switches::kSpdyProxyAuthOrigin)) |
227 return command_line.GetSwitchValueASCII(switches::kSpdyProxyAuthOrigin); | 216 return command_line.GetSwitchValueASCII(switches::kSpdyProxyAuthOrigin); |
228 #if defined(DATA_REDUCTION_DEV_HOST) | 217 #if defined(DATA_REDUCTION_DEV_HOST) |
229 if (FieldTrialList::FindFullName("DataCompressionProxyDevRollout") == | 218 if (FieldTrialList::FindFullName("DataCompressionProxyDevRollout") == |
230 kEnabled) { | 219 kEnabled) { |
231 return DATA_REDUCTION_DEV_HOST; | 220 return DATA_REDUCTION_DEV_HOST; |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 } | 656 } |
668 | 657 |
669 void | 658 void |
670 DataReductionProxySettings::ProbeWhetherDataReductionProxyIsAvailable() { | 659 DataReductionProxySettings::ProbeWhetherDataReductionProxyIsAvailable() { |
671 net::URLFetcher* fetcher = GetURLFetcher(); | 660 net::URLFetcher* fetcher = GetURLFetcher(); |
672 if (!fetcher) | 661 if (!fetcher) |
673 return; | 662 return; |
674 fetcher_.reset(fetcher); | 663 fetcher_.reset(fetcher); |
675 fetcher_->Start(); | 664 fetcher_->Start(); |
676 } | 665 } |
OLD | NEW |