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

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

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