| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "chrome/browser/autocomplete/autocomplete.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/i18n/number_formatting.h" | 11 #include "base/i18n/number_formatting.h" |
| 12 #include "base/metrics/histogram.h" |
| 12 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
| 13 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 14 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" | 16 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" |
| 16 #include "chrome/browser/autocomplete/autocomplete_match.h" | 17 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 17 #include "chrome/browser/autocomplete/builtin_provider.h" | 18 #include "chrome/browser/autocomplete/builtin_provider.h" |
| 18 #include "chrome/browser/autocomplete/history_contents_provider.h" | 19 #include "chrome/browser/autocomplete/history_contents_provider.h" |
| 19 #include "chrome/browser/autocomplete/history_quick_provider.h" | 20 #include "chrome/browser/autocomplete/history_quick_provider.h" |
| 20 #include "chrome/browser/autocomplete/history_url_provider.h" | 21 #include "chrome/browser/autocomplete/history_url_provider.h" |
| 21 #include "chrome/browser/autocomplete/keyword_provider.h" | 22 #include "chrome/browser/autocomplete/keyword_provider.h" |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 // | 846 // |
| 846 // NOTE: This comes after constructing |input_| above since that construction | 847 // NOTE: This comes after constructing |input_| above since that construction |
| 847 // can change the text string (e.g. by stripping off a leading '?'). | 848 // can change the text string (e.g. by stripping off a leading '?'). |
| 848 const bool minimal_changes = (input_.text() == old_input_text) && | 849 const bool minimal_changes = (input_.text() == old_input_text) && |
| 849 (input_.synchronous_only() == old_synchronous_only); | 850 (input_.synchronous_only() == old_synchronous_only); |
| 850 | 851 |
| 851 expire_timer_.Stop(); | 852 expire_timer_.Stop(); |
| 852 | 853 |
| 853 // Start the new query. | 854 // Start the new query. |
| 854 in_start_ = true; | 855 in_start_ = true; |
| 856 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 855 for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); | 857 for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); |
| 856 ++i) { | 858 ++i) { |
| 857 (*i)->Start(input_, minimal_changes); | 859 (*i)->Start(input_, minimal_changes); |
| 858 if (synchronous_only) | 860 if (synchronous_only) |
| 859 DCHECK((*i)->done()); | 861 DCHECK((*i)->done()); |
| 860 } | 862 } |
| 863 if (!synchronous_only && text.size() < 6) { |
| 864 base::TimeTicks end_time = base::TimeTicks::Now(); |
| 865 std::string name = "Omnibox.QueryTime." + base::IntToString(text.size()); |
| 866 scoped_refptr<base::Histogram> counter = base::Histogram::FactoryGet( |
| 867 name, 1, 1000, 50, base::Histogram::kUmaTargetedHistogramFlag); |
| 868 counter->Add(static_cast<int>((end_time - start_time).InMilliseconds())); |
| 869 } |
| 861 in_start_ = false; | 870 in_start_ = false; |
| 862 CheckIfDone(); | 871 CheckIfDone(); |
| 863 UpdateResult(true); | 872 UpdateResult(true); |
| 864 | 873 |
| 865 if (!done_) | 874 if (!done_) |
| 866 StartExpireTimer(); | 875 StartExpireTimer(); |
| 867 } | 876 } |
| 868 | 877 |
| 869 void AutocompleteController::Stop(bool clear_result) { | 878 void AutocompleteController::Stop(bool clear_result) { |
| 870 for (ACProviders::const_iterator i(providers_.begin()); i != providers_.end(); | 879 for (ACProviders::const_iterator i(providers_.begin()); i != providers_.end(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 } | 981 } |
| 973 } | 982 } |
| 974 done_ = true; | 983 done_ = true; |
| 975 } | 984 } |
| 976 | 985 |
| 977 void AutocompleteController::StartExpireTimer() { | 986 void AutocompleteController::StartExpireTimer() { |
| 978 if (result_.HasCopiedMatches()) | 987 if (result_.HasCopiedMatches()) |
| 979 expire_timer_.Start(base::TimeDelta::FromMilliseconds(kExpireTimeMS), | 988 expire_timer_.Start(base::TimeDelta::FromMilliseconds(kExpireTimeMS), |
| 980 this, &AutocompleteController::ExpireCopiedEntries); | 989 this, &AutocompleteController::ExpireCopiedEntries); |
| 981 } | 990 } |
| OLD | NEW |