OLD | NEW |
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 Loading... |
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 Loading... |
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(); |
| 219 #else |
| 220 return false; |
201 #endif | 221 #endif |
202 return false; | |
203 } | 222 } |
204 | 223 |
205 // Returns true if the provided URL is a referrer string that came from | 224 // 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 | 225 // a Google Web Search results page. This is a little non-deterministic |
207 // because desktop and mobile websearch differ and sometimes just provide | 226 // 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 | 227 // 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 | 228 // 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. | 229 // 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 | 230 // The domain validation matches the code used by the prerenderer for similar |
212 // purposes. | 231 // purposes. |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 | 1047 |
1029 DCHECK(document_state); | 1048 DCHECK(document_state); |
1030 DCHECK(ds); | 1049 DCHECK(ds); |
1031 GURL url(ds->request().url()); | 1050 GURL url(ds->request().url()); |
1032 Time start = document_state->start_load_time(); | 1051 Time start = document_state->start_load_time(); |
1033 Time finish = document_state->finish_load_time(); | 1052 Time finish = document_state->finish_load_time(); |
1034 // TODO(mbelshe): should we log more stats? | 1053 // TODO(mbelshe): should we log more stats? |
1035 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " | 1054 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " |
1036 << url.spec(); | 1055 << url.spec(); |
1037 } | 1056 } |
OLD | NEW |