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

Side by Side 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: Addressed more comments 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer/page_load_histograms.h" 5 #include "chrome/renderer/page_load_histograms.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 14 matching lines...) Expand all
25 #include "extensions/common/url_pattern.h" 25 #include "extensions/common/url_pattern.h"
26 #include "net/base/url_util.h" 26 #include "net/base/url_util.h"
27 #include "third_party/WebKit/public/platform/WebURLRequest.h" 27 #include "third_party/WebKit/public/platform/WebURLRequest.h"
28 #include "third_party/WebKit/public/platform/WebURLResponse.h" 28 #include "third_party/WebKit/public/platform/WebURLResponse.h"
29 #include "third_party/WebKit/public/web/WebDocument.h" 29 #include "third_party/WebKit/public/web/WebDocument.h"
30 #include "third_party/WebKit/public/web/WebFrame.h" 30 #include "third_party/WebKit/public/web/WebFrame.h"
31 #include "third_party/WebKit/public/web/WebPerformance.h" 31 #include "third_party/WebKit/public/web/WebPerformance.h"
32 #include "third_party/WebKit/public/web/WebView.h" 32 #include "third_party/WebKit/public/web/WebView.h"
33 #include "url/gurl.h" 33 #include "url/gurl.h"
34 34
35 #if defined(SPDY_PROXY_AUTH_ORIGIN)
36 #include "net/http/http_response_headers.h"
37 #endif
38
35 using blink::WebDataSource; 39 using blink::WebDataSource;
36 using blink::WebFrame; 40 using blink::WebFrame;
37 using blink::WebPerformance; 41 using blink::WebPerformance;
38 using blink::WebString; 42 using blink::WebString;
39 using base::Time; 43 using base::Time;
40 using base::TimeDelta; 44 using base::TimeDelta;
41 using content::DocumentState; 45 using content::DocumentState;
42 46
43 const size_t kPLTCount = 100; 47 const size_t kPLTCount = 100;
44 48
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // not expected to contain any commas. 188 // not expected to contain any commas.
185 // Example., Via: 1.0 Compression proxy, 1.1 Google promise preview 189 // Example., Via: 1.0 Compression proxy, 1.1 Google promise preview
186 base::SplitString( 190 base::SplitString(
187 frame->dataSource()->response().httpHeaderField(kViaHeaderName).utf8(), 191 frame->dataSource()->response().httpHeaderField(kViaHeaderName).utf8(),
188 ',', &values); 192 ',', &values);
189 return std::find(values.begin(), values.end(), via_value) != values.end(); 193 return std::find(values.begin(), values.end(), via_value) != values.end();
190 } 194 }
191 195
192 // Returns true if the data reduction proxy was used. Note, this function will 196 // Returns true if the data reduction proxy was used. Note, this function will
193 // produce a false positive if a page is fetched using SPDY and using a proxy, 197 // produce a false positive if a page is fetched using SPDY and using a proxy,
194 // and |kDatReductionProxyViaValue| is added to the Via header. 198 // and the data reduction proxy's via value is added to the Via header.
195 // TODO(bengr): Plumb the hostname of the proxy from |HttpNetworkTransaction| 199 // TODO(bengr): Plumb the hostname of the proxy and check if it matches
196 // and check if it matches |SPDY_PROXY_AUTH_ORIGIN|. 200 // |SPDY_PROXY_AUTH_ORIGIN|.
197 bool DataReductionProxyWasUsed(WebFrame* frame) { 201 bool DataReductionProxyWasUsed(WebFrame* frame) {
198 #if defined(SPDY_PROXY_AUTH_ORIGIN) 202 #if defined(SPDY_PROXY_AUTH_ORIGIN)
199 const char kDatReductionProxyViaValue[] = "1.1 Chrome Compression Proxy"; 203 DocumentState* document_state =
200 return ViaHeaderContains(frame, kDatReductionProxyViaValue); 204 DocumentState::FromDataSource(frame->dataSource());
205 if (!document_state->was_fetched_via_proxy())
206 return false;
207
208 std::string via_header =
209 base::UTF16ToUTF8(frame->dataSource()->response().httpHeaderField("Via"));
210
211 if (via_header.empty())
212 return false;
213 std::string headers = "HTTP/1.1 200 OK\nVia: " + via_header + "\n\n";
214 // Produce raw headers, expected by the |HttpResponseHeaders| constructor.
215 std::replace(headers.begin(), headers.end(), '\n', '\0');
216 scoped_refptr<net::HttpResponseHeaders> response_headers(
217 new net::HttpResponseHeaders(headers));
218 return response_headers->IsChromeProxyResponse();
201 #endif 219 #endif
202 return false; 220 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,
203 } 221 }
204 222
205 // Returns true if the provided URL is a referrer string that came from 223 // Returns true if the provided URL is a referrer string that came from
206 // a Google Web Search results page. This is a little non-deterministic 224 // a Google Web Search results page. This is a little non-deterministic
207 // because desktop and mobile websearch differ and sometimes just provide 225 // because desktop and mobile websearch differ and sometimes just provide
208 // http://www.google.com/ as the referrer. In the case of /url we can be sure 226 // http://www.google.com/ as the referrer. In the case of /url we can be sure
209 // that it came from websearch but we will be generous and allow for cases 227 // that it came from websearch but we will be generous and allow for cases
210 // where a non-Google URL was provided a bare Google URL as a referrer. 228 // where a non-Google URL was provided a bare Google URL as a referrer.
211 // The domain validation matches the code used by the prerenderer for similar 229 // The domain validation matches the code used by the prerenderer for similar
212 // purposes. 230 // purposes.
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 1046
1029 DCHECK(document_state); 1047 DCHECK(document_state);
1030 DCHECK(ds); 1048 DCHECK(ds);
1031 GURL url(ds->request().url()); 1049 GURL url(ds->request().url());
1032 Time start = document_state->start_load_time(); 1050 Time start = document_state->start_load_time();
1033 Time finish = document_state->finish_load_time(); 1051 Time finish = document_state->finish_load_time();
1034 // TODO(mbelshe): should we log more stats? 1052 // TODO(mbelshe): should we log more stats?
1035 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " 1053 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms "
1036 << url.spec(); 1054 << url.spec();
1037 } 1055 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698