Chromium Code Reviews| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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( | 211 bool DataReductionProxySettings::WasFetchedViaProxy( |
| 212 const net::HttpResponseHeaders* headers) { | 212 const net::HttpResponseHeaders* response_headers) { |
| 213 const char kChromeProxyViaValue[] = "1.1 Chrome Compression Proxy"; | 213 if (!response_headers) { |
| 214 return false; | |
| 215 } | |
| 216 | |
| 217 const size_t kVersionSize = 4; | |
| 218 const char kDataReductionProxyViaValue[] = "Chrome-Compression-Proxy"; | |
|
mef
2014/02/07 20:33:25
Any particular reason to skip version?
Also, I t
bengr
2014/02/07 23:55:36
The version is the HTTP version from the origin, w
mef
2014/02/12 18:12:18
Are you sure? From this comment in rfc2616 it seem
bengr
2014/02/12 21:14:00
It is always the protocol used for the response fr
| |
| 219 size_t value_len = strlen(kDataReductionProxyViaValue); | |
| 214 void* iter = NULL; | 220 void* iter = NULL; |
| 215 std::string value; | 221 std::string value; |
| 216 while (headers->EnumerateHeader(&iter, "via", &value)) | 222 |
| 217 if (value == kChromeProxyViaValue) return true; | 223 // Case-sensitive comparison. Assumes the received protocol and the space |
| 224 // following it are always |kVersionSize| characters. E.g., | |
| 225 // 'Via: 1.1 Chrome-Compression-Proxy' | |
| 226 while (response_headers->EnumerateHeader(&iter, "via", &value)) { | |
| 227 if (!value.compare(kVersionSize, value_len, kDataReductionProxyViaValue)) | |
| 228 return true; | |
| 229 } | |
| 230 | |
| 231 // TODO(bengr): Remove deprecated header value. | |
| 232 const char kDeprecatedDataReductionProxyViaValue[] = | |
| 233 "1.1 Chrome Compression Proxy"; | |
| 234 iter = NULL; | |
| 235 while (response_headers->EnumerateHeader(&iter, "via", &value)) | |
| 236 if (value == kDeprecatedDataReductionProxyViaValue) return true; | |
| 237 | |
| 218 return false; | 238 return false; |
| 219 } | 239 } |
| 220 | 240 |
| 221 // static | 241 // static |
| 222 std::string DataReductionProxySettings::GetDataReductionProxyOrigin() { | 242 std::string DataReductionProxySettings::GetDataReductionProxyOrigin() { |
| 223 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 243 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 224 if (command_line.HasSwitch(switches::kSpdyProxyDevAuthOrigin)) | 244 if (command_line.HasSwitch(switches::kSpdyProxyDevAuthOrigin)) |
| 225 return command_line.GetSwitchValueASCII(switches::kSpdyProxyDevAuthOrigin); | 245 return command_line.GetSwitchValueASCII(switches::kSpdyProxyDevAuthOrigin); |
| 226 if (command_line.HasSwitch(switches::kSpdyProxyAuthOrigin)) | 246 if (command_line.HasSwitch(switches::kSpdyProxyAuthOrigin)) |
| 227 return command_line.GetSwitchValueASCII(switches::kSpdyProxyAuthOrigin); | 247 return command_line.GetSwitchValueASCII(switches::kSpdyProxyAuthOrigin); |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 667 } | 687 } |
| 668 | 688 |
| 669 void | 689 void |
| 670 DataReductionProxySettings::ProbeWhetherDataReductionProxyIsAvailable() { | 690 DataReductionProxySettings::ProbeWhetherDataReductionProxyIsAvailable() { |
| 671 net::URLFetcher* fetcher = GetURLFetcher(); | 691 net::URLFetcher* fetcher = GetURLFetcher(); |
| 672 if (!fetcher) | 692 if (!fetcher) |
| 673 return; | 693 return; |
| 674 fetcher_.reset(fetcher); | 694 fetcher_.reset(fetcher); |
| 675 fetcher_->Start(); | 695 fetcher_->Start(); |
| 676 } | 696 } |
| OLD | NEW |