| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 266 // Call Start() on ZeroSuggestProvider with an INVALID AutocompleteInput | 266 // Call Start() on ZeroSuggestProvider with an INVALID AutocompleteInput |
| 267 // to clear out zero-suggest |matches_|. | 267 // to clear out zero-suggest |matches_|. |
| 268 if (*i == zero_suggest_provider_) | 268 if (i->get() == zero_suggest_provider_) |
| 269 (*i)->Start(AutocompleteInput(), minimal_changes); | 269 (*i)->Start(AutocompleteInput(), minimal_changes); |
| 270 else | 270 else |
| 271 (*i)->Start(input_, minimal_changes); | 271 (*i)->Start(input_, minimal_changes); |
| 272 | 272 |
| 273 if (!input.want_asynchronous_matches()) | 273 if (!input.want_asynchronous_matches()) |
| 274 DCHECK((*i)->done()); | 274 DCHECK((*i)->done()); |
| 275 base::TimeTicks provider_end_time = base::TimeTicks::Now(); | 275 base::TimeTicks provider_end_time = base::TimeTicks::Now(); |
| 276 std::string name = std::string("Omnibox.ProviderTime.") + (*i)->GetName(); | 276 std::string name = std::string("Omnibox.ProviderTime.") + (*i)->GetName(); |
| 277 base::HistogramBase* counter = base::Histogram::FactoryGet( | 277 base::HistogramBase* counter = base::Histogram::FactoryGet( |
| 278 name, 1, 5000, 20, base::Histogram::kUmaTargetedHistogramFlag); | 278 name, 1, 5000, 20, base::Histogram::kUmaTargetedHistogramFlag); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 void AutocompleteController::StartZeroSuggest(const AutocompleteInput& input) { | 330 void AutocompleteController::StartZeroSuggest(const AutocompleteInput& input) { |
| 331 if (zero_suggest_provider_ == NULL) | 331 if (zero_suggest_provider_ == NULL) |
| 332 return; | 332 return; |
| 333 | 333 |
| 334 DCHECK(!in_start_); // We should not be already running a query. | 334 DCHECK(!in_start_); // We should not be already running a query. |
| 335 | 335 |
| 336 // Call Start() on all prefix-based providers with an INVALID | 336 // Call Start() on all prefix-based providers with an INVALID |
| 337 // AutocompleteInput to clear out cached |matches_|, which ensures that | 337 // AutocompleteInput to clear out cached |matches_|, which ensures that |
| 338 // they aren't used with zero suggest. | 338 // they aren't used with zero suggest. |
| 339 for (Providers::iterator i(providers_.begin()); i != providers_.end(); ++i) { | 339 for (Providers::iterator i(providers_.begin()); i != providers_.end(); ++i) { |
| 340 if (*i == zero_suggest_provider_) | 340 if (i->get() == zero_suggest_provider_) |
| 341 (*i)->Start(input, false); | 341 (*i)->Start(input, false); |
| 342 else | 342 else |
| 343 (*i)->Start(AutocompleteInput(), false); | 343 (*i)->Start(AutocompleteInput(), false); |
| 344 } | 344 } |
| 345 | 345 |
| 346 if (!zero_suggest_provider_->matches().empty()) | 346 if (!zero_suggest_provider_->matches().empty()) |
| 347 UpdateResult(false, false); | 347 UpdateResult(false, false); |
| 348 } | 348 } |
| 349 | 349 |
| 350 void AutocompleteController::DeleteMatch(const AutocompleteMatch& match) { | 350 void AutocompleteController::DeleteMatch(const AutocompleteMatch& match) { |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 this, &AutocompleteController::ExpireCopiedEntries); | 679 this, &AutocompleteController::ExpireCopiedEntries); |
| 680 } | 680 } |
| 681 | 681 |
| 682 void AutocompleteController::StartStopTimer() { | 682 void AutocompleteController::StartStopTimer() { |
| 683 stop_timer_.Start(FROM_HERE, | 683 stop_timer_.Start(FROM_HERE, |
| 684 stop_timer_duration_, | 684 stop_timer_duration_, |
| 685 base::Bind(&AutocompleteController::Stop, | 685 base::Bind(&AutocompleteController::Stop, |
| 686 base::Unretained(this), | 686 base::Unretained(this), |
| 687 false)); | 687 false)); |
| 688 } | 688 } |
| OLD | NEW |