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

Unified Diff: chrome/renderer/page_load_histograms.cc

Issue 156373002: Support for new data reduction proxy via header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed compilation error on unsupported platforms Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/net/spdyproxy/data_saving_metrics.cc ('k') | net/http/http_network_layer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f01df4329095a19f424b2d6a988e6d4bae003c69 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,15 +195,30 @@ 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);
-#endif
+ 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();
+#else
return false;
+#endif
}
// Returns true if the provided URL is a referrer string that came from
« no previous file with comments | « chrome/browser/net/spdyproxy/data_saving_metrics.cc ('k') | net/http/http_network_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698