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

Side by Side Diff: chrome/browser/history/in_memory_url_index.h

Issue 903493002: Componentize ScoredHistoryMatch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 10 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) 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 #ifndef CHROME_BROWSER_HISTORY_IN_MEMORY_URL_INDEX_H_ 5 #ifndef CHROME_BROWSER_HISTORY_IN_MEMORY_URL_INDEX_H_
6 #define CHROME_BROWSER_HISTORY_IN_MEMORY_URL_INDEX_H_ 6 #define CHROME_BROWSER_HISTORY_IN_MEMORY_URL_INDEX_H_
7 7
8 #include <functional> 8 #include <functional>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/gtest_prod_util.h" 16 #include "base/gtest_prod_util.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "base/strings/string16.h" 19 #include "base/strings/string16.h"
20 #include "base/task/cancelable_task_tracker.h" 20 #include "base/task/cancelable_task_tracker.h"
21 #include "chrome/browser/history/scored_history_match.h"
22 #include "components/history/core/browser/history_db_task.h" 21 #include "components/history/core/browser/history_db_task.h"
23 #include "components/history/core/browser/history_service_observer.h" 22 #include "components/history/core/browser/history_service_observer.h"
24 #include "components/history/core/browser/history_types.h" 23 #include "components/history/core/browser/history_types.h"
24 #include "components/history/core/browser/scored_history_match.h"
25 #include "sql/connection.h" 25 #include "sql/connection.h"
26 26
27 class HistoryService; 27 class HistoryService;
28 class HistoryQuickProviderTest; 28 class HistoryQuickProviderTest;
29 29
30 namespace base { 30 namespace base {
31 class Time; 31 class Time;
32 } 32 }
33 33
34 namespace in_memory_url_index { 34 namespace in_memory_url_index {
35 class InMemoryURLIndexCacheItem; 35 class InMemoryURLIndexCacheItem;
36 } 36 }
37 37
38 namespace history { 38 namespace history {
39 39
40 namespace imui = in_memory_url_index; 40 namespace imui = in_memory_url_index;
41 41
42 class HistoryClient;
43 class HistoryDatabase; 42 class HistoryDatabase;
43 class ScoredHistoryMatchClient;
44 class URLIndexPrivateData; 44 class URLIndexPrivateData;
45 45
46 // The URL history source. 46 // The URL history source.
47 // Holds portions of the URL database in memory in an indexed form. Used to 47 // Holds portions of the URL database in memory in an indexed form. Used to
48 // quickly look up matching URLs for a given query string. Used by 48 // quickly look up matching URLs for a given query string. Used by
49 // the HistoryURLProvider for inline autocomplete and to provide URL 49 // the HistoryURLProvider for inline autocomplete and to provide URL
50 // matches to the omnibox. 50 // matches to the omnibox.
51 // 51 //
52 // Note about multi-byte codepoints and the data structures in the 52 // Note about multi-byte codepoints and the data structures in the
53 // InMemoryURLIndex class: One will quickly notice that no effort is made to 53 // InMemoryURLIndex class: One will quickly notice that no effort is made to
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 }; 90 };
91 91
92 // |history_service| which may be null during unit testing is used to register 92 // |history_service| which may be null during unit testing is used to register
93 // |as an HistoryServiceObserver. |history_dir| is a path to the directory 93 // |as an HistoryServiceObserver. |history_dir| is a path to the directory
94 // containing the history database within the profile wherein the cache and 94 // containing the history database within the profile wherein the cache and
95 // transaction journals will be stored. |languages| gives a list of language 95 // transaction journals will be stored. |languages| gives a list of language
96 // encodings by which URLs and omnibox searches are broken down into words and 96 // encodings by which URLs and omnibox searches are broken down into words and
97 // characters. 97 // characters.
98 InMemoryURLIndex(HistoryService* history_service, 98 InMemoryURLIndex(HistoryService* history_service,
99 const base::FilePath& history_dir, 99 const base::FilePath& history_dir,
100 const std::string& languages, 100 const std::string& languages);
101 HistoryClient* client);
102 ~InMemoryURLIndex() override; 101 ~InMemoryURLIndex() override;
103 102
104 // Opens and prepares the index of historical URL visits. If the index private 103 // Opens and prepares the index of historical URL visits. If the index private
105 // data cannot be restored from its cache file then it is rebuilt from the 104 // data cannot be restored from its cache file then it is rebuilt from the
106 // history database. 105 // history database.
107 void Init(); 106 void Init();
108 107
109 // Signals that any outstanding initialization should be canceled and 108 // Signals that any outstanding initialization should be canceled and
110 // flushes the cache to disk. 109 // flushes the cache to disk.
111 void ShutDown(); 110 void ShutDown();
112 111
113 // Scans the history index and returns a vector with all scored, matching 112 // Scans the history index and returns a vector with all scored, matching
114 // history items. This entry point simply forwards the call on to the 113 // history items. This entry point simply forwards the call on to the
115 // URLIndexPrivateData class. For a complete description of this function 114 // URLIndexPrivateData class. For a complete description of this function
116 // refer to that class. If |cursor_position| is base::string16::npos, the 115 // refer to that class. If |cursor_position| is base::string16::npos, the
117 // function doesn't do anything special with the cursor; this is equivalent 116 // function doesn't do anything special with the cursor; this is equivalent
118 // to the cursor being at the end. In total, |max_matches| of items will be 117 // to the cursor being at the end. In total, |max_matches| of items will be
119 // returned in the |ScoredHistoryMatches| vector. 118 // returned in the |ScoredHistoryMatches| vector.
120 ScoredHistoryMatches HistoryItemsForTerms(const base::string16& term_string, 119 ScoredHistoryMatches HistoryItemsForTerms(
121 size_t cursor_position, 120 const base::string16& term_string,
122 size_t max_matches); 121 size_t cursor_position,
122 size_t max_matches,
123 const ScoredHistoryMatchClient* scored_history_match_client);
123 124
124 // Deletes the index entry, if any, for the given |url|. 125 // Deletes the index entry, if any, for the given |url|.
125 void DeleteURL(const GURL& url); 126 void DeleteURL(const GURL& url);
126 127
127 // Sets the optional observers for completion of restoral and saving of the 128 // Sets the optional observers for completion of restoral and saving of the
128 // index's private data. 129 // index's private data.
129 void set_restore_cache_observer( 130 void set_restore_cache_observer(
130 RestoreCacheObserver* restore_cache_observer) { 131 RestoreCacheObserver* restore_cache_observer) {
131 restore_cache_observer_ = restore_cache_observer; 132 restore_cache_observer_ = restore_cache_observer;
132 } 133 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 base::CancelableTaskTracker* private_data_tracker() { 255 base::CancelableTaskTracker* private_data_tracker() {
255 return &private_data_tracker_; 256 return &private_data_tracker_;
256 } 257 }
257 258
258 // Returns the set of whitelisted schemes. For unit testing only. 259 // Returns the set of whitelisted schemes. For unit testing only.
259 const std::set<std::string>& scheme_whitelist() { return scheme_whitelist_; } 260 const std::set<std::string>& scheme_whitelist() { return scheme_whitelist_; }
260 261
261 // The HistoryService; may be null when testing. 262 // The HistoryService; may be null when testing.
262 HistoryService* history_service_; 263 HistoryService* history_service_;
263 264
264 // The HistoryClient; may be null when testing.
265 HistoryClient* history_client_;
266
267 // Directory where cache file resides. This is, except when unit testing, 265 // Directory where cache file resides. This is, except when unit testing,
268 // the same directory in which the history database is found. It should never 266 // the same directory in which the history database is found. It should never
269 // be empty. 267 // be empty.
270 base::FilePath history_dir_; 268 base::FilePath history_dir_;
271 269
272 // Languages used during the word-breaking process during indexing. 270 // Languages used during the word-breaking process during indexing.
273 std::string languages_; 271 std::string languages_;
274 272
275 // Only URLs with a whitelisted scheme are indexed. 273 // Only URLs with a whitelisted scheme are indexed.
276 std::set<std::string> scheme_whitelist_; 274 std::set<std::string> scheme_whitelist_;
(...skipping 19 matching lines...) Expand all
296 // temporary safety check to insure that the cache is saved before the 294 // temporary safety check to insure that the cache is saved before the
297 // index has been destructed. 295 // index has been destructed.
298 bool needs_to_be_cached_; 296 bool needs_to_be_cached_;
299 297
300 DISALLOW_COPY_AND_ASSIGN(InMemoryURLIndex); 298 DISALLOW_COPY_AND_ASSIGN(InMemoryURLIndex);
301 }; 299 };
302 300
303 } // namespace history 301 } // namespace history
304 302
305 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_URL_INDEX_H_ 303 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_URL_INDEX_H_
OLDNEW
« no previous file with comments | « chrome/browser/history/history_service.cc ('k') | chrome/browser/history/in_memory_url_index.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698