Chromium Code Reviews| 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/browser/autocomplete/search_provider.h" | 5 #include "chrome/browser/autocomplete/search_provider.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 base::OnStringConversionError::FAIL, | 332 base::OnStringConversionError::FAIL, |
| 333 &data_16)) | 333 &data_16)) |
| 334 json_data = UTF16ToUTF8(data_16); | 334 json_data = UTF16ToUTF8(data_16); |
| 335 } | 335 } |
| 336 } | 336 } |
| 337 | 337 |
| 338 bool is_keyword = (source == keyword_fetcher_.get()); | 338 bool is_keyword = (source == keyword_fetcher_.get()); |
| 339 SuggestResults* suggest_results = | 339 SuggestResults* suggest_results = |
| 340 is_keyword ? &keyword_suggest_results_ : &default_suggest_results_; | 340 is_keyword ? &keyword_suggest_results_ : &default_suggest_results_; |
| 341 | 341 |
| 342 std::string histogram_name = | 342 bool request_succeeded = false; |
|
Ilya Sherman
2012/05/17 22:53:15
nit: bool request_succeeded = source->GetStatus().
Mark P
2012/05/18 13:23:07
Took that idea and brought it one step further to
| |
| 343 "Omnibox.SuggestRequest.Failure.GoogleResponseTime"; | |
| 344 if (source->GetStatus().is_success() && source->GetResponseCode() == 200) { | 343 if (source->GetStatus().is_success() && source->GetResponseCode() == 200) { |
| 344 request_succeeded = true; | |
| 345 JSONStringValueSerializer deserializer(json_data); | 345 JSONStringValueSerializer deserializer(json_data); |
| 346 deserializer.set_allow_trailing_comma(true); | 346 deserializer.set_allow_trailing_comma(true); |
| 347 scoped_ptr<Value> root_val(deserializer.Deserialize(NULL, NULL)); | 347 scoped_ptr<Value> root_val(deserializer.Deserialize(NULL, NULL)); |
| 348 const string16& input = is_keyword ? keyword_input_text_ : input_.text(); | 348 const string16& input = is_keyword ? keyword_input_text_ : input_.text(); |
| 349 have_suggest_results_ = root_val.get() && | 349 have_suggest_results_ = root_val.get() && |
| 350 ParseSuggestResults(root_val.get(), is_keyword, input, suggest_results); | 350 ParseSuggestResults(root_val.get(), is_keyword, input, suggest_results); |
| 351 histogram_name = "Omnibox.SuggestRequest.Success.GoogleResponseTime"; | |
| 352 } | 351 } |
| 353 | 352 |
| 354 // Record response time for suggest requests sent to Google. We care | 353 // Record response time for suggest requests sent to Google. We care |
| 355 // only about the common case: the Google default provider used in | 354 // only about the common case: the Google default provider used in |
| 356 // non-keyword mode. | 355 // non-keyword mode. |
| 357 const TemplateURL* default_url = providers_.GetDefaultProviderURL(); | 356 const TemplateURL* default_url = providers_.GetDefaultProviderURL(); |
| 358 if (!is_keyword && default_url && | 357 if (!is_keyword && default_url && |
| 359 (default_url->prepopulate_id() == SEARCH_ENGINE_GOOGLE)) { | 358 (default_url->prepopulate_id() == SEARCH_ENGINE_GOOGLE)) { |
| 360 UMA_HISTOGRAM_TIMES(histogram_name, | 359 if (request_succeeded) |
| 361 base::TimeTicks::Now() - time_suggest_request_sent_); | 360 UMA_HISTOGRAM_TIMES("Omnibox.SuggestRequest.Failure.GoogleResponseTime", |
|
Mark P
2012/05/18 13:23:07
Also noticed I had histogram names backwards.
| |
| 361 base::TimeTicks::Now() - time_suggest_request_sent_); | |
|
Ilya Sherman
2012/05/17 22:53:15
nit: Perhaps compute this once, outside of the UMA
Mark P
2012/05/18 13:23:07
Done.
| |
| 362 else | |
| 363 UMA_HISTOGRAM_TIMES("Omnibox.SuggestRequest.Success.GoogleResponseTime", | |
| 364 base::TimeTicks::Now() - time_suggest_request_sent_); | |
|
Ilya Sherman
2012/05/17 22:53:15
nit: Please add curly braces to the if-else, since
Mark P
2012/05/18 13:23:07
Done.
| |
| 362 } | 365 } |
| 363 | 366 |
| 364 ConvertResultsToAutocompleteMatches(); | 367 ConvertResultsToAutocompleteMatches(); |
| 365 listener_->OnProviderUpdate(!suggest_results->empty()); | 368 listener_->OnProviderUpdate(!suggest_results->empty()); |
| 366 } | 369 } |
| 367 | 370 |
| 368 SearchProvider::~SearchProvider() { | 371 SearchProvider::~SearchProvider() { |
| 369 } | 372 } |
| 370 | 373 |
| 371 void SearchProvider::DoHistoryQuery(bool minimal_changes) { | 374 void SearchProvider::DoHistoryQuery(bool minimal_changes) { |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 984 | 987 |
| 985 return match; | 988 return match; |
| 986 } | 989 } |
| 987 | 990 |
| 988 void SearchProvider::UpdateDone() { | 991 void SearchProvider::UpdateDone() { |
| 989 // We're done when there are no more suggest queries pending (this is set to 1 | 992 // We're done when there are no more suggest queries pending (this is set to 1 |
| 990 // when the timer is started) and we're not waiting on instant. | 993 // when the timer is started) and we're not waiting on instant. |
| 991 done_ = ((suggest_results_pending_ == 0) && | 994 done_ = ((suggest_results_pending_ == 0) && |
| 992 (instant_finalized_ || !InstantController::IsEnabled(profile_))); | 995 (instant_finalized_ || !InstantController::IsEnabled(profile_))); |
| 993 } | 996 } |
| OLD | NEW |