Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: chrome/browser/autocomplete/history_url_provider.h

Issue 3177020: History provider: style cleanup (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Compile, and all that jazz Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H_ 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H_
6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H_ 6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector>
10
11 #include "chrome/browser/autocomplete/autocomplete.h" 9 #include "chrome/browser/autocomplete/autocomplete.h"
12 #include "chrome/browser/history/history_types.h" 10 #include "chrome/browser/autocomplete/history_provider_util.h"
13 11
14 class MessageLoop; 12 class MessageLoop;
15 class Profile; 13 class Profile;
16 14
17 namespace history { 15 namespace history {
18 class HistoryBackend; 16
17 class HistoryBackend;
18 class URLDatabase;
19 class URLRow;
20
19 } // namespace history 21 } // namespace history
20 22
21 // How history autocomplete works 23 // How history autocomplete works
22 // ============================== 24 // ==============================
23 // 25 //
24 // Read down this diagram for temporal ordering. 26 // Read down this diagram for temporal ordering.
25 // 27 //
26 // Main thread History thread 28 // Main thread History thread
27 // ----------- -------------- 29 // ----------- --------------
28 // AutocompleteController::Start 30 // AutocompleteController::Start
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // 126 //
125 // Note: This object can get leaked on shutdown if there are pending 127 // Note: This object can get leaked on shutdown if there are pending
126 // requests on the database (which hold a reference to us). Normally, these 128 // requests on the database (which hold a reference to us). Normally, these
127 // messages get flushed for each thread. We do a round trip from main, to 129 // messages get flushed for each thread. We do a round trip from main, to
128 // history, back to main while holding a reference. If the main thread 130 // history, back to main while holding a reference. If the main thread
129 // completes before the history thread, the message to delegate back to the 131 // completes before the history thread, the message to delegate back to the
130 // main thread will not run and the reference will leak. Therefore, don't do 132 // main thread will not run and the reference will leak. Therefore, don't do
131 // anything on destruction. 133 // anything on destruction.
132 class HistoryURLProvider : public AutocompleteProvider { 134 class HistoryURLProvider : public AutocompleteProvider {
133 public: 135 public:
134 HistoryURLProvider(ACProviderListener* listener, Profile* profile) 136 HistoryURLProvider(ACProviderListener* listener, Profile* profile);
135 : AutocompleteProvider(listener, profile, "HistoryURL"),
136 prefixes_(GetPrefixes()),
137 params_(NULL) {
138 }
139 137
140 #ifdef UNIT_TEST 138 #ifdef UNIT_TEST
141 HistoryURLProvider(ACProviderListener* listener, 139 HistoryURLProvider(ACProviderListener* listener,
142 Profile* profile, 140 Profile* profile,
143 const std::wstring& languages) 141 const std::wstring& languages)
144 : AutocompleteProvider(listener, profile, "History"), 142 : AutocompleteProvider(listener, profile, "History"),
145 prefixes_(GetPrefixes()), 143 prefixes_(GetPrefixes()),
146 params_(NULL), 144 params_(NULL),
147 languages_(languages) { 145 languages_(languages) {}
148 }
149 #endif 146 #endif
150 // no destructor (see note above) 147 // no destructor (see note above)
151 148
152 // AutocompleteProvider 149 // AutocompleteProvider
153 virtual void Start(const AutocompleteInput& input, 150 virtual void Start(const AutocompleteInput& input,
154 bool minimal_changes); 151 bool minimal_changes);
155 virtual void Stop(); 152 virtual void Stop();
156 virtual void DeleteMatch(const AutocompleteMatch& match); 153 virtual void DeleteMatch(const AutocompleteMatch& match);
157 154
158 // Runs the history query on the history thread, called by the history 155 // Runs the history query on the history thread, called by the history
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 size_t max_results) const; 291 size_t max_results) const;
295 292
296 // Helper function for CullRedirects, this removes all but the first 293 // Helper function for CullRedirects, this removes all but the first
297 // occurance of [any of the set of strings in |remove|] from the |matches| 294 // occurance of [any of the set of strings in |remove|] from the |matches|
298 // list. 295 // list.
299 // 296 //
300 // The return value is the index of the item that is after the item in the 297 // The return value is the index of the item that is after the item in the
301 // input identified by |source_index|. If |source_index| or an item before 298 // input identified by |source_index|. If |source_index| or an item before
302 // is removed, the next item will be shifted, and this allows the caller to 299 // is removed, the next item will be shifted, and this allows the caller to
303 // pick up on the next one when this happens. 300 // pick up on the next one when this happens.
304 size_t RemoveSubsequentMatchesOf( 301 size_t RemoveSubsequentMatchesOf(history::HistoryMatches* matches,
305 history::HistoryMatches* matches, 302 size_t source_index,
306 size_t source_index, 303 const std::vector<GURL>& remove) const;
307 const std::vector<GURL>& remove) const;
308 304
309 // Converts a line from the database into an autocomplete match for display. 305 // Converts a line from the database into an autocomplete match for display.
310 AutocompleteMatch HistoryMatchToACMatch( 306 AutocompleteMatch HistoryMatchToACMatch(
311 HistoryURLProviderParams* params, 307 HistoryURLProviderParams* params,
312 const history::HistoryMatch& history_match, 308 const history::HistoryMatch& history_match,
313 MatchType match_type, 309 MatchType match_type,
314 size_t match_number); 310 size_t match_number);
315 311
316 // Prefixes to try appending to user input when looking for a match. 312 // Prefixes to try appending to user input when looking for a match.
317 const history::Prefixes prefixes_; 313 const history::Prefixes prefixes_;
318 314
319 // Params for the current query. The provider should not free this directly; 315 // Params for the current query. The provider should not free this directly;
320 // instead, it is passed as a parameter through the history backend, and the 316 // instead, it is passed as a parameter through the history backend, and the
321 // parameter itself is freed once it's no longer needed. The only reason we 317 // parameter itself is freed once it's no longer needed. The only reason we
322 // keep this member is so we can set the cancel bit on it. 318 // keep this member is so we can set the cancel bit on it.
323 HistoryURLProviderParams* params_; 319 HistoryURLProviderParams* params_;
324 320
325 // Only used by unittests; if non-empty, overrides accept-languages in the 321 // Only used by unittests; if non-empty, overrides accept-languages in the
326 // profile's pref system. 322 // profile's pref system.
327 std::wstring languages_; 323 std::wstring languages_;
328 }; 324 };
329 325
330 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H_ 326 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/history_quick_provider.h ('k') | chrome/browser/autocomplete/history_url_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698