| 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/autocomplete_controller.h" | 5 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 expire_timer_.Stop(); | 255 expire_timer_.Stop(); |
| 256 stop_timer_.Stop(); | 256 stop_timer_.Stop(); |
| 257 | 257 |
| 258 // Start the new query. | 258 // Start the new query. |
| 259 in_start_ = true; | 259 in_start_ = true; |
| 260 base::TimeTicks start_time = base::TimeTicks::Now(); | 260 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 261 for (Providers::iterator i(providers_.begin()); i != providers_.end(); ++i) { | 261 for (Providers::iterator i(providers_.begin()); i != providers_.end(); ++i) { |
| 262 // TODO(mpearson): Remove timing code once bugs 178705 / 237703 / 168933 | 262 // TODO(mpearson): Remove timing code once bugs 178705 / 237703 / 168933 |
| 263 // are resolved. | 263 // are resolved. |
| 264 base::TimeTicks provider_start_time = base::TimeTicks::Now(); | 264 base::TimeTicks provider_start_time = base::TimeTicks::Now(); |
| 265 | 265 (*i)->Start(input_, minimal_changes, false); |
| 266 // Call Start() on ZeroSuggestProvider with an INVALID AutocompleteInput | |
| 267 // to clear out zero-suggest |matches_|. | |
| 268 if (i->get() == zero_suggest_provider_) | |
| 269 (*i)->Start(AutocompleteInput(), minimal_changes); | |
| 270 else | |
| 271 (*i)->Start(input_, minimal_changes); | |
| 272 | |
| 273 if (!input.want_asynchronous_matches()) | 266 if (!input.want_asynchronous_matches()) |
| 274 DCHECK((*i)->done()); | 267 DCHECK((*i)->done()); |
| 275 base::TimeTicks provider_end_time = base::TimeTicks::Now(); | 268 base::TimeTicks provider_end_time = base::TimeTicks::Now(); |
| 276 std::string name = std::string("Omnibox.ProviderTime.") + (*i)->GetName(); | 269 std::string name = std::string("Omnibox.ProviderTime.") + (*i)->GetName(); |
| 277 base::HistogramBase* counter = base::Histogram::FactoryGet( | 270 base::HistogramBase* counter = base::Histogram::FactoryGet( |
| 278 name, 1, 5000, 20, base::Histogram::kUmaTargetedHistogramFlag); | 271 name, 1, 5000, 20, base::Histogram::kUmaTargetedHistogramFlag); |
| 279 counter->Add(static_cast<int>( | 272 counter->Add(static_cast<int>( |
| 280 (provider_end_time - provider_start_time).InMilliseconds())); | 273 (provider_end_time - provider_start_time).InMilliseconds())); |
| 281 } | 274 } |
| 282 if (input.want_asynchronous_matches() && (input.text().length() < 6)) { | 275 if (input.want_asynchronous_matches() && (input.text().length() < 6)) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 NotifyChanged(false); | 319 NotifyChanged(false); |
| 327 } | 320 } |
| 328 } | 321 } |
| 329 | 322 |
| 330 void AutocompleteController::OnOmniboxFocused(const AutocompleteInput& input) { | 323 void AutocompleteController::OnOmniboxFocused(const AutocompleteInput& input) { |
| 331 DCHECK(!in_start_); // We should not be already running a query. | 324 DCHECK(!in_start_); // We should not be already running a query. |
| 332 | 325 |
| 333 // Call Start() on all prefix-based providers with an INVALID | 326 // Call Start() on all prefix-based providers with an INVALID |
| 334 // AutocompleteInput to clear out cached |matches_|, which ensures that | 327 // AutocompleteInput to clear out cached |matches_|, which ensures that |
| 335 // they aren't used with zero suggest. | 328 // they aren't used with zero suggest. |
| 336 for (Providers::iterator i(providers_.begin()); i != providers_.end(); ++i) { | 329 for (Providers::iterator i(providers_.begin()); i != providers_.end(); ++i) |
| 337 if ((*i)->ProvidesMatchesOnOmniboxFocus()) | 330 (*i)->Start(input, false, true); |
| 338 (*i)->Start(input, false); | |
| 339 else | |
| 340 (*i)->Start(AutocompleteInput(), false); | |
| 341 } | |
| 342 | 331 |
| 343 UpdateResult(false, false); | 332 UpdateResult(false, false); |
| 344 } | 333 } |
| 345 | 334 |
| 346 void AutocompleteController::DeleteMatch(const AutocompleteMatch& match) { | 335 void AutocompleteController::DeleteMatch(const AutocompleteMatch& match) { |
| 347 DCHECK(match.SupportsDeletion()); | 336 DCHECK(match.SupportsDeletion()); |
| 348 | 337 |
| 349 // Delete duplicate matches attached to the main match first. | 338 // Delete duplicate matches attached to the main match first. |
| 350 for (ACMatches::const_iterator it(match.duplicate_matches.begin()); | 339 for (ACMatches::const_iterator it(match.duplicate_matches.begin()); |
| 351 it != match.duplicate_matches.end(); ++it) { | 340 it != match.duplicate_matches.end(); ++it) { |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 this, &AutocompleteController::ExpireCopiedEntries); | 664 this, &AutocompleteController::ExpireCopiedEntries); |
| 676 } | 665 } |
| 677 | 666 |
| 678 void AutocompleteController::StartStopTimer() { | 667 void AutocompleteController::StartStopTimer() { |
| 679 stop_timer_.Start(FROM_HERE, | 668 stop_timer_.Start(FROM_HERE, |
| 680 stop_timer_duration_, | 669 stop_timer_duration_, |
| 681 base::Bind(&AutocompleteController::Stop, | 670 base::Bind(&AutocompleteController::Stop, |
| 682 base::Unretained(this), | 671 base::Unretained(this), |
| 683 false)); | 672 false)); |
| 684 } | 673 } |
| OLD | NEW |