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...) 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 (!base::StartsWithASCII(referrer.host(), "www.google.", true)) | 182 if (!base::StartsWith(referrer.host(), "www.google.", |
| 183 base::CompareCase::SENSITIVE)) |
183 return false; | 184 return false; |
184 if (base::StartsWithASCII(referrer.path(), "/url", true)) | 185 if (base::StartsWith(referrer.path(), "/url", |
| 186 base::CompareCase::SENSITIVE)) |
185 return true; | 187 return true; |
186 bool is_possible_search_referrer = | 188 bool is_possible_search_referrer = |
187 referrer.path().empty() || referrer.path() == "/" || | 189 referrer.path().empty() || referrer.path() == "/" || |
188 base::StartsWithASCII(referrer.path(), "/search", true) || | 190 base::StartsWith(referrer.path(), "/search", |
189 base::StartsWithASCII(referrer.path(), "/webhp", true); | 191 base::CompareCase::SENSITIVE) || |
| 192 base::StartsWith(referrer.path(), "/webhp", |
| 193 base::CompareCase::SENSITIVE); |
190 if (is_possible_search_referrer && | 194 if (is_possible_search_referrer && |
191 !base::StartsWithASCII(url.host(), "www.google", true)) | 195 !base::StartsWith(url.host(), "www.google", |
| 196 base::CompareCase::SENSITIVE)) |
192 return true; | 197 return true; |
193 return false; | 198 return false; |
194 } | 199 } |
195 | 200 |
196 // Extracts a Google Web Search and Chrome joint experiment ID from a referrer | 201 // Extracts a Google Web Search and Chrome joint experiment ID from a referrer |
197 // that came from a Google Web Search results page. An experiment ID is embedded | 202 // that came from a Google Web Search results page. An experiment ID is embedded |
198 // in a query string as a "gcjeid=" parameter value. | 203 // in a query string as a "gcjeid=" parameter value. |
199 int GetQueryStringBasedExperiment(const GURL& referrer) { | 204 int GetQueryStringBasedExperiment(const GURL& referrer) { |
200 std::string value; | 205 std::string value; |
201 if (!net::GetValueForKeyInQuery(referrer, "gcjeid", &value)) | 206 if (!net::GetValueForKeyInQuery(referrer, "gcjeid", &value)) |
(...skipping 710 matching lines...) Loading... |
912 | 917 |
913 DCHECK(document_state); | 918 DCHECK(document_state); |
914 DCHECK(ds); | 919 DCHECK(ds); |
915 GURL url(ds->request().url()); | 920 GURL url(ds->request().url()); |
916 Time start = document_state->start_load_time(); | 921 Time start = document_state->start_load_time(); |
917 Time finish = document_state->finish_load_time(); | 922 Time finish = document_state->finish_load_time(); |
918 // TODO(mbelshe): should we log more stats? | 923 // TODO(mbelshe): should we log more stats? |
919 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " | 924 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " |
920 << url.spec(); | 925 << url.spec(); |
921 } | 926 } |
OLD | NEW |