| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 std::string via_header = | 170 std::string via_header = |
| 171 base::UTF16ToUTF8(frame->dataSource()->response().httpHeaderField("Via")); | 171 base::UTF16ToUTF8(frame->dataSource()->response().httpHeaderField("Via")); |
| 172 | 172 |
| 173 if (via_header.empty()) | 173 if (via_header.empty()) |
| 174 return false; | 174 return false; |
| 175 std::string headers = "HTTP/1.1 200 OK\nVia: " + via_header + "\n\n"; | 175 std::string headers = "HTTP/1.1 200 OK\nVia: " + via_header + "\n\n"; |
| 176 // Produce raw headers, expected by the |HttpResponseHeaders| constructor. | 176 // Produce raw headers, expected by the |HttpResponseHeaders| constructor. |
| 177 std::replace(headers.begin(), headers.end(), '\n', '\0'); | 177 std::replace(headers.begin(), headers.end(), '\n', '\0'); |
| 178 scoped_refptr<net::HttpResponseHeaders> response_headers( | 178 scoped_refptr<net::HttpResponseHeaders> response_headers( |
| 179 new net::HttpResponseHeaders(headers)); | 179 new net::HttpResponseHeaders(headers)); |
| 180 return data_reduction_proxy::HasDataReductionProxyViaHeader( | 180 return data_reduction_proxy::HasDataReductionProxyViaHeader(response_headers); |
| 181 response_headers, NULL); | |
| 182 } | 181 } |
| 183 | 182 |
| 184 // Returns true if the provided URL is a referrer string that came from | 183 // Returns true if the provided URL is a referrer string that came from |
| 185 // a Google Web Search results page. This is a little non-deterministic | 184 // a Google Web Search results page. This is a little non-deterministic |
| 186 // because desktop and mobile websearch differ and sometimes just provide | 185 // because desktop and mobile websearch differ and sometimes just provide |
| 187 // http://www.google.com/ as the referrer. In the case of /url we can be sure | 186 // http://www.google.com/ as the referrer. In the case of /url we can be sure |
| 188 // that it came from websearch but we will be generous and allow for cases | 187 // that it came from websearch but we will be generous and allow for cases |
| 189 // where a non-Google URL was provided a bare Google URL as a referrer. | 188 // where a non-Google URL was provided a bare Google URL as a referrer. |
| 190 // The domain validation matches the code used by the prerenderer for similar | 189 // The domain validation matches the code used by the prerenderer for similar |
| 191 // purposes. | 190 // purposes. |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 | 756 |
| 758 DCHECK(document_state); | 757 DCHECK(document_state); |
| 759 DCHECK(ds); | 758 DCHECK(ds); |
| 760 GURL url(ds->request().url()); | 759 GURL url(ds->request().url()); |
| 761 Time start = document_state->start_load_time(); | 760 Time start = document_state->start_load_time(); |
| 762 Time finish = document_state->finish_load_time(); | 761 Time finish = document_state->finish_load_time(); |
| 763 // TODO(mbelshe): should we log more stats? | 762 // TODO(mbelshe): should we log more stats? |
| 764 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " | 763 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " |
| 765 << url.spec(); | 764 << url.spec(); |
| 766 } | 765 } |
| OLD | NEW |