| Index: chrome/renderer/page_load_histograms.cc
|
| diff --git a/chrome/renderer/page_load_histograms.cc b/chrome/renderer/page_load_histograms.cc
|
| index 6ce21e24031130bec14e039ac58dd12542ea7a3e..66db91ec7ac5da11c7cae4794932d5e0ff036ab2 100644
|
| --- a/chrome/renderer/page_load_histograms.cc
|
| +++ b/chrome/renderer/page_load_histograms.cc
|
| @@ -32,6 +32,10 @@
|
| #include "third_party/WebKit/public/web/WebView.h"
|
| #include "url/gurl.h"
|
|
|
| +#if defined(SPDY_PROXY_AUTH_ORIGIN)
|
| +#include "net/http/http_response_headers.h"
|
| +#endif
|
| +
|
| using blink::WebDataSource;
|
| using blink::WebFrame;
|
| using blink::WebPerformance;
|
| @@ -191,13 +195,51 @@ bool ViaHeaderContains(WebFrame* frame, const std::string& via_value) {
|
|
|
| // Returns true if the data reduction proxy was used. Note, this function will
|
| // produce a false positive if a page is fetched using SPDY and using a proxy,
|
| -// and |kDatReductionProxyViaValue| is added to the Via header.
|
| -// TODO(bengr): Plumb the hostname of the proxy from |HttpNetworkTransaction|
|
| -// and check if it matches |SPDY_PROXY_AUTH_ORIGIN|.
|
| +// and the data reduction proxy's via value is added to the Via header.
|
| +// TODO(bengr): Plumb the hostname of the proxy and check if it matches
|
| +// |SPDY_PROXY_AUTH_ORIGIN|.
|
| bool DataReductionProxyWasUsed(WebFrame* frame) {
|
| #if defined(SPDY_PROXY_AUTH_ORIGIN)
|
| - const char kDatReductionProxyViaValue[] = "1.1 Chrome Compression Proxy";
|
| - return ViaHeaderContains(frame, kDatReductionProxyViaValue);
|
| + DocumentState* document_state =
|
| + DocumentState::FromDataSource(frame->dataSource());
|
| + if (!document_state->was_fetched_via_proxy())
|
| + return false;
|
| +
|
| + std::string via_header =
|
| + base::UTF16ToUTF8(frame->dataSource()->response().httpHeaderField("Via"));
|
| +
|
| + if (via_header.empty())
|
| + return false;
|
| + std::string headers = "HTTP/1.1 200 OK\nVia: " + via_header + "\n\n";
|
| + std::replace(headers.begin(), headers.end(), '\n', '\0');
|
| + scoped_refptr<net::HttpResponseHeaders> response_headers(
|
| + new net::HttpResponseHeaders(headers));
|
| +
|
| + // TODO(bengr): Remove duplication of this code in DataReductionProxySettings
|
| + // and HttpNetworkTransaction.
|
| + const size_t kVersionSize = 4;
|
| + const char kDataReductionProxyViaValue[] = "Chrome-Compression-Proxy";
|
| + size_t value_len = strlen(kDataReductionProxyViaValue);
|
| + void* iter = NULL;
|
| + std::string value;
|
| +
|
| + // Case-sensitive comparison. Assumes the received protocol and the space
|
| + // following it are always |kVersionSize| characters. E.g.,
|
| + // 'Via: 1.1 Chrome-Compression-Proxy'
|
| + while (response_headers->EnumerateHeader(&iter, "via", &value)) {
|
| + if (!value.compare(kVersionSize, value_len, kDataReductionProxyViaValue))
|
| + return true;
|
| + }
|
| +
|
| + // TODO(bengr): Remove deprecated header value.
|
| + const char kDeprecatedDataReductionProxyViaValue[] =
|
| + "1.1 Chrome Compression Proxy";
|
| + iter = NULL;
|
| + while (response_headers->EnumerateHeader(&iter, "via", &value))
|
| + if (value == kDeprecatedDataReductionProxyViaValue) return true;
|
| +
|
| + return false;
|
| +
|
| #endif
|
| return false;
|
| }
|
|
|