Chromium Code Reviews| 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..843899ea514788dd990c31e834a3ba25228d80d0 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,27 @@ 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"; |
| + // Produce raw headers, expected by the |HttpResponseHeaders| constructor. |
| + std::replace(headers.begin(), headers.end(), '\n', '\0'); |
| + scoped_refptr<net::HttpResponseHeaders> response_headers( |
| + new net::HttpResponseHeaders(headers)); |
| + return response_headers->IsChromeProxyResponse(); |
| #endif |
| return false; |
|
Lei Zhang
2014/02/13 01:33:07
shouldn't this be inside: #else ... #endif ?
Othe
bengr
2014/02/13 16:57:36
Done. Good catch. Thanks!
On 2014/02/13 01:33:07,
|
| } |