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/history_quick_provider.h" | 5 #include "chrome/browser/autocomplete/history_quick_provider.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/i18n/break_iterator.h" | 8 #include "base/i18n/break_iterator.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" |
| 11 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/time.h" |
11 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/history/history.h" | 15 #include "chrome/browser/history/history.h" |
13 #include "chrome/browser/history/in_memory_url_index.h" | 16 #include "chrome/browser/history/in_memory_url_index.h" |
14 #include "chrome/browser/net/url_fixer_upper.h" | 17 #include "chrome/browser/net/url_fixer_upper.h" |
15 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
16 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
18 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
19 #include "googleurl/src/url_parse.h" | 22 #include "googleurl/src/url_parse.h" |
20 #include "content/common/notification_source.h" | 23 #include "content/common/notification_source.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 // have cases where this happens offhand). We can't do anything with | 58 // have cases where this happens offhand). We can't do anything with |
56 // empty input, so just bail; otherwise we'd crash later. | 59 // empty input, so just bail; otherwise we'd crash later. |
57 return; | 60 return; |
58 } | 61 } |
59 autocomplete_input_.set_text(fixed_text); | 62 autocomplete_input_.set_text(fixed_text); |
60 | 63 |
61 // TODO(pkasting): We should just block here until this loads. Any time | 64 // TODO(pkasting): We should just block here until this loads. Any time |
62 // someone unloads the history backend, we'll get inconsistent inline | 65 // someone unloads the history backend, we'll get inconsistent inline |
63 // autocomplete behavior here. | 66 // autocomplete behavior here. |
64 if (GetIndex()) { | 67 if (GetIndex()) { |
| 68 base::TimeTicks start_time = base::TimeTicks::Now(); |
65 DoAutocomplete(); | 69 DoAutocomplete(); |
| 70 if (input.text().size() < 6) { |
| 71 base::TimeTicks end_time = base::TimeTicks::Now(); |
| 72 std::string name = "HistoryQuickProvider.QueryIndexTime." + |
| 73 base::IntToString(input.text().size()); |
| 74 scoped_refptr<base::Histogram> counter = base::Histogram::FactoryGet( |
| 75 name, 1, 1000, 50, base::Histogram::kUmaTargetedHistogramFlag); |
| 76 counter->Add(static_cast<int>((end_time - start_time).InMilliseconds())); |
| 77 } |
66 UpdateStarredStateOfMatches(); | 78 UpdateStarredStateOfMatches(); |
67 } | 79 } |
68 } | 80 } |
69 | 81 |
70 // HistoryQuickProvider matches are currently not deletable. | 82 // HistoryQuickProvider matches are currently not deletable. |
71 // TODO(mrossetti): Determine when a match should be deletable. | 83 // TODO(mrossetti): Determine when a match should be deletable. |
72 void HistoryQuickProvider::DeleteMatch(const AutocompleteMatch& match) {} | 84 void HistoryQuickProvider::DeleteMatch(const AutocompleteMatch& match) {} |
73 | 85 |
74 void HistoryQuickProvider::DoAutocomplete() { | 86 void HistoryQuickProvider::DoAutocomplete() { |
75 // Get the matching URLs from the DB. | 87 // Get the matching URLs from the DB. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 ++i; | 205 ++i; |
194 } while ((i < match_count) && (offset == matches[i].offset - adjust)); | 206 } while ((i < match_count) && (offset == matches[i].offset - adjust)); |
195 if (offset < text_length) { | 207 if (offset < text_length) { |
196 spans.push_back(ACMatchClassification(offset, | 208 spans.push_back(ACMatchClassification(offset, |
197 ACMatchClassification::NONE)); | 209 ACMatchClassification::NONE)); |
198 } | 210 } |
199 } | 211 } |
200 | 212 |
201 return spans; | 213 return spans; |
202 } | 214 } |
OLD | NEW |