Index: chrome/browser/autocomplete/search_provider.cc |
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc |
index d5507f67e4206b2731b5a54540fad147c32dca7f..3c8dbc2dc18aece3588d133840d75dead04e7586 100644 |
--- a/chrome/browser/autocomplete/search_provider.cc |
+++ b/chrome/browser/autocomplete/search_provider.cc |
@@ -122,6 +122,7 @@ SearchProvider::SearchProvider(AutocompleteProviderListener* listener, |
Profile* profile) |
: AutocompleteProvider(listener, profile, "Search"), |
providers_(TemplateURLServiceFactory::GetForProfile(profile)), |
+ in_timer_phase_(false), |
suggest_results_pending_(0), |
suggest_field_trial_group_number_( |
AutocompleteFieldTrial::GetSuggestNumberOfGroups()), |
@@ -309,6 +310,8 @@ class SearchProvider::CompareScoredResults { |
void SearchProvider::Run() { |
// Start a new request with the current input. |
DCHECK(!done_); |
+ DCHECK(in_timer_phase_); |
+ in_timer_phase_ = false; |
suggest_results_pending_ = 0; |
time_suggest_request_sent_ = base::TimeTicks::Now(); |
const TemplateURL* default_url = providers_.GetDefaultProviderURL(); |
@@ -504,16 +507,11 @@ void SearchProvider::StartOrStopSuggestQuery(bool minimal_changes) { |
if (input_.matches_requested() != AutocompleteInput::ALL_MATCHES) |
return; |
- // We'll have at least one pending fetch. Set it to 1 now, but the value is |
- // correctly set in Run. As Run isn't invoked immediately we need to set this |
- // now, else we won't think we're waiting on results from the server when we |
- // really are. |
- suggest_results_pending_ = 1; |
- |
// Kick off a timer that will start the URL fetch if it completes before |
// the user types another character. Requests may be delayed to avoid |
// flooding the server with requests that are likely to be thrown away later |
// anyway. |
+ in_timer_phase_ = true; |
timer_.Start(FROM_HERE, GetSuggestQueryDelay(), this, &SearchProvider::Run); |
} |
@@ -579,6 +577,7 @@ void SearchProvider::StopSuggest() { |
LogOmniboxSuggestRequest(REQUEST_INVALIDATED); |
suggest_results_pending_ = 0; |
timer_.Stop(); |
+ in_timer_phase_ = false; |
// Stop any in-progress URL fetches. |
keyword_fetcher_.reset(); |
default_fetcher_.reset(); |
@@ -1244,6 +1243,6 @@ AutocompleteMatch SearchProvider::NavigationToMatch( |
void SearchProvider::UpdateDone() { |
// We're done when there are no more suggest queries pending (this is set to 1 |
// when the timer is started) and we're not waiting on instant. |
- done_ = ((suggest_results_pending_ == 0) && |
+ done_ = (!in_timer_phase_ && (suggest_results_pending_ == 0) && |
(instant_finalized_ || !InstantController::IsEnabled(profile_))); |
} |