| 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 std::replace(headers.begin(), headers.end(), '\n', '\0'); |
| 215 scoped_refptr<net::HttpResponseHeaders> response_headers( |
| 216 new net::HttpResponseHeaders(headers)); |
| 217 |
| 218 // TODO(bengr): Remove duplication of this code in DataReductionProxySettings |
| 219 // and HttpNetworkTransaction. |
| 220 const size_t kVersionSize = 4; |
| 221 const char kDataReductionProxyViaValue[] = "Chrome-Compression-Proxy"; |
| 222 size_t value_len = strlen(kDataReductionProxyViaValue); |
| 223 void* iter = NULL; |
| 224 std::string value; |
| 225 |
| 226 // Case-sensitive comparison. Assumes the received protocol and the space |
| 227 // following it are always |kVersionSize| characters. E.g., |
| 228 // 'Via: 1.1 Chrome-Compression-Proxy' |
| 229 while (response_headers->EnumerateHeader(&iter, "via", &value)) { |
| 230 if (!value.compare(kVersionSize, value_len, kDataReductionProxyViaValue)) |
| 231 return true; |
| 232 } |
| 233 |
| 234 // TODO(bengr): Remove deprecated header value. |
| 235 const char kDeprecatedDataReductionProxyViaValue[] = |
| 236 "1.1 Chrome Compression Proxy"; |
| 237 iter = NULL; |
| 238 while (response_headers->EnumerateHeader(&iter, "via", &value)) |
| 239 if (value == kDeprecatedDataReductionProxyViaValue) return true; |
| 240 |
| 241 return false; |
| 242 |
| 201 #endif | 243 #endif |
| 202 return false; | 244 return false; |
| 203 } | 245 } |
| 204 | 246 |
| 205 // Returns true if the provided URL is a referrer string that came from | 247 // 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 | 248 // a Google Web Search results page. This is a little non-deterministic |
| 207 // because desktop and mobile websearch differ and sometimes just provide | 249 // 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 | 250 // 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 | 251 // 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. | 252 // 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 | 1070 |
| 1029 DCHECK(document_state); | 1071 DCHECK(document_state); |
| 1030 DCHECK(ds); | 1072 DCHECK(ds); |
| 1031 GURL url(ds->request().url()); | 1073 GURL url(ds->request().url()); |
| 1032 Time start = document_state->start_load_time(); | 1074 Time start = document_state->start_load_time(); |
| 1033 Time finish = document_state->finish_load_time(); | 1075 Time finish = document_state->finish_load_time(); |
| 1034 // TODO(mbelshe): should we log more stats? | 1076 // TODO(mbelshe): should we log more stats? |
| 1035 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " | 1077 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " |
| 1036 << url.spec(); | 1078 << url.spec(); |
| 1037 } | 1079 } |
| OLD | NEW |