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()); |
mef
2014/02/12 21:36:50
Given that ViaHeaderContains is still used in GetP
bengr
2014/02/13 00:17:38
ViaHeaderContains is only used by Promise as non-c
| |
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 std::replace(headers.begin(), headers.end(), '\n', '\0'); | |
mef
2014/02/12 21:36:50
Is it worth adding a comment that this produces a
bengr
2014/02/13 00:17:38
Done.
| |
215 scoped_refptr<net::HttpResponseHeaders> response_headers( | |
216 new net::HttpResponseHeaders(headers)); | |
217 return response_headers->IsChromeProxyResponse(); | |
201 #endif | 218 #endif |
202 return false; | 219 return false; |
203 } | 220 } |
204 | 221 |
205 // Returns true if the provided URL is a referrer string that came from | 222 // 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 | 223 // a Google Web Search results page. This is a little non-deterministic |
207 // because desktop and mobile websearch differ and sometimes just provide | 224 // 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 | 225 // 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 | 226 // 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. | 227 // where a non-Google URL was provided a bare Google URL as a referrer. |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1028 | 1045 |
1029 DCHECK(document_state); | 1046 DCHECK(document_state); |
1030 DCHECK(ds); | 1047 DCHECK(ds); |
1031 GURL url(ds->request().url()); | 1048 GURL url(ds->request().url()); |
1032 Time start = document_state->start_load_time(); | 1049 Time start = document_state->start_load_time(); |
1033 Time finish = document_state->finish_load_time(); | 1050 Time finish = document_state->finish_load_time(); |
1034 // TODO(mbelshe): should we log more stats? | 1051 // TODO(mbelshe): should we log more stats? |
1035 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " | 1052 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " |
1036 << url.spec(); | 1053 << url.spec(); |
1037 } | 1054 } |
OLD | NEW |