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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 // Returns true if the provided URL is a referrer string that came from | 172 // Returns true if the provided URL is a referrer string that came from |
173 // a Google Web Search results page. This is a little non-deterministic | 173 // a Google Web Search results page. This is a little non-deterministic |
174 // because desktop and mobile websearch differ and sometimes just provide | 174 // because desktop and mobile websearch differ and sometimes just provide |
175 // http://www.google.com/ as the referrer. In the case of /url we can be sure | 175 // http://www.google.com/ as the referrer. In the case of /url we can be sure |
176 // that it came from websearch but we will be generous and allow for cases | 176 // that it came from websearch but we will be generous and allow for cases |
177 // where a non-Google URL was provided a bare Google URL as a referrer. | 177 // where a non-Google URL was provided a bare Google URL as a referrer. |
178 // The domain validation matches the code used by the prerenderer for similar | 178 // The domain validation matches the code used by the prerenderer for similar |
179 // purposes. | 179 // purposes. |
180 // TODO(pmeenan): Remove the fuzzy logic when the referrer is reliable | 180 // TODO(pmeenan): Remove the fuzzy logic when the referrer is reliable |
181 bool IsFromGoogleSearchResult(const GURL& url, const GURL& referrer) { | 181 bool IsFromGoogleSearchResult(const GURL& url, const GURL& referrer) { |
182 if (!StartsWithASCII(referrer.host(), "www.google.", true)) | 182 if (!base::StartsWithASCII(referrer.host(), "www.google.", true)) |
183 return false; | 183 return false; |
184 if (StartsWithASCII(referrer.path(), "/url", true)) | 184 if (base::StartsWithASCII(referrer.path(), "/url", true)) |
185 return true; | 185 return true; |
186 bool is_possible_search_referrer = | 186 bool is_possible_search_referrer = |
187 referrer.path().empty() || | 187 referrer.path().empty() || referrer.path() == "/" || |
188 referrer.path() == "/" || | 188 base::StartsWithASCII(referrer.path(), "/search", true) || |
189 StartsWithASCII(referrer.path(), "/search", true) || | 189 base::StartsWithASCII(referrer.path(), "/webhp", true); |
190 StartsWithASCII(referrer.path(), "/webhp", true); | |
191 if (is_possible_search_referrer && | 190 if (is_possible_search_referrer && |
192 !StartsWithASCII(url.host(), "www.google", true)) | 191 !base::StartsWithASCII(url.host(), "www.google", true)) |
193 return true; | 192 return true; |
194 return false; | 193 return false; |
195 } | 194 } |
196 | 195 |
197 // Extracts a Google Web Search and Chrome joint experiment ID from a referrer | 196 // Extracts a Google Web Search and Chrome joint experiment ID from a referrer |
198 // that came from a Google Web Search results page. An experiment ID is embedded | 197 // that came from a Google Web Search results page. An experiment ID is embedded |
199 // in a query string as a "gcjeid=" parameter value. | 198 // in a query string as a "gcjeid=" parameter value. |
200 int GetQueryStringBasedExperiment(const GURL& referrer) { | 199 int GetQueryStringBasedExperiment(const GURL& referrer) { |
201 std::string value; | 200 std::string value; |
202 if (!net::GetValueForKeyInQuery(referrer, "gcjeid", &value)) | 201 if (!net::GetValueForKeyInQuery(referrer, "gcjeid", &value)) |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 | 912 |
914 DCHECK(document_state); | 913 DCHECK(document_state); |
915 DCHECK(ds); | 914 DCHECK(ds); |
916 GURL url(ds->request().url()); | 915 GURL url(ds->request().url()); |
917 Time start = document_state->start_load_time(); | 916 Time start = document_state->start_load_time(); |
918 Time finish = document_state->finish_load_time(); | 917 Time finish = document_state->finish_load_time(); |
919 // TODO(mbelshe): should we log more stats? | 918 // TODO(mbelshe): should we log more stats? |
920 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " | 919 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " |
921 << url.spec(); | 920 << url.spec(); |
922 } | 921 } |
OLD | NEW |