OLD | NEW |
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_AUTOCOMPLETE_IN_MEMORY_URL_INDEX_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_IN_MEMORY_URL_INDEX_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_IN_MEMORY_URL_INDEX_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_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> |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "components/history/core/browser/history_types.h" | 24 #include "components/history/core/browser/history_types.h" |
25 #include "components/keyed_service/core/keyed_service.h" | 25 #include "components/keyed_service/core/keyed_service.h" |
26 #include "sql/connection.h" | 26 #include "sql/connection.h" |
27 | 27 |
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 bookmarks { |
| 35 class BookmarkModel; |
| 36 } |
| 37 |
34 namespace in_memory_url_index { | 38 namespace in_memory_url_index { |
35 class InMemoryURLIndexCacheItem; | 39 class InMemoryURLIndexCacheItem; |
36 } | 40 } |
37 | 41 |
38 namespace history { | 42 namespace history { |
39 class HistoryDatabase; | 43 class HistoryDatabase; |
40 class HistoryService; | 44 class HistoryService; |
41 } | 45 } |
42 | 46 |
43 class URLIndexPrivateData; | 47 class URLIndexPrivateData; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // This is called on the UI thread. | 92 // This is called on the UI thread. |
89 virtual void OnCacheSaveFinished(bool succeeded) = 0; | 93 virtual void OnCacheSaveFinished(bool succeeded) = 0; |
90 }; | 94 }; |
91 | 95 |
92 // |history_service| which may be null during unit testing is used to register | 96 // |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 | 97 // |as an HistoryServiceObserver. |history_dir| is a path to the directory |
94 // containing the history database within the profile wherein the cache and | 98 // containing the history database within the profile wherein the cache and |
95 // transaction journals will be stored. |languages| gives a list of language | 99 // 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 | 100 // encodings by which URLs and omnibox searches are broken down into words and |
97 // characters. | 101 // characters. |
98 InMemoryURLIndex(history::HistoryService* history_service, | 102 InMemoryURLIndex(bookmarks::BookmarkModel* bookmark_model, |
| 103 history::HistoryService* history_service, |
99 const base::FilePath& history_dir, | 104 const base::FilePath& history_dir, |
100 const std::string& languages); | 105 const std::string& languages); |
101 ~InMemoryURLIndex() override; | 106 ~InMemoryURLIndex() override; |
102 | 107 |
103 // Opens and prepares the index of historical URL visits. If the index private | 108 // Opens and prepares the index of historical URL visits. If the index private |
104 // data cannot be restored from its cache file then it is rebuilt from the | 109 // data cannot be restored from its cache file then it is rebuilt from the |
105 // history database. | 110 // history database. |
106 void Init(); | 111 void Init(); |
107 | 112 |
108 // Scans the history index and returns a vector with all scored, matching | 113 // Scans the history index and returns a vector with all scored, matching |
109 // history items. This entry point simply forwards the call on to the | 114 // history items. This entry point simply forwards the call on to the |
110 // URLIndexPrivateData class. For a complete description of this function | 115 // URLIndexPrivateData class. For a complete description of this function |
111 // refer to that class. If |cursor_position| is base::string16::npos, the | 116 // refer to that class. If |cursor_position| is base::string16::npos, the |
112 // function doesn't do anything special with the cursor; this is equivalent | 117 // function doesn't do anything special with the cursor; this is equivalent |
113 // to the cursor being at the end. In total, |max_matches| of items will be | 118 // to the cursor being at the end. In total, |max_matches| of items will be |
114 // returned in the |ScoredHistoryMatches| vector. | 119 // returned in the |ScoredHistoryMatches| vector. |
115 ScoredHistoryMatches HistoryItemsForTerms( | 120 ScoredHistoryMatches HistoryItemsForTerms(const base::string16& term_string, |
116 const base::string16& term_string, | 121 size_t cursor_position, |
117 size_t cursor_position, | 122 size_t max_matches); |
118 size_t max_matches, | |
119 const ScoredHistoryMatch::Builder& builder); | |
120 | 123 |
121 // Deletes the index entry, if any, for the given |url|. | 124 // Deletes the index entry, if any, for the given |url|. |
122 void DeleteURL(const GURL& url); | 125 void DeleteURL(const GURL& url); |
123 | 126 |
124 // Sets the optional observers for completion of restoral and saving of the | 127 // Sets the optional observers for completion of restoral and saving of the |
125 // index's private data. | 128 // index's private data. |
126 void set_restore_cache_observer( | 129 void set_restore_cache_observer( |
127 RestoreCacheObserver* restore_cache_observer) { | 130 RestoreCacheObserver* restore_cache_observer) { |
128 restore_cache_observer_ = restore_cache_observer; | 131 restore_cache_observer_ = restore_cache_observer; |
129 } | 132 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 255 |
253 // Returns a pointer to our private data cancelable request tracker. For | 256 // Returns a pointer to our private data cancelable request tracker. For |
254 // unit testing only. | 257 // unit testing only. |
255 base::CancelableTaskTracker* private_data_tracker() { | 258 base::CancelableTaskTracker* private_data_tracker() { |
256 return &private_data_tracker_; | 259 return &private_data_tracker_; |
257 } | 260 } |
258 | 261 |
259 // Returns the set of whitelisted schemes. For unit testing only. | 262 // Returns the set of whitelisted schemes. For unit testing only. |
260 const std::set<std::string>& scheme_whitelist() { return scheme_whitelist_; } | 263 const std::set<std::string>& scheme_whitelist() { return scheme_whitelist_; } |
261 | 264 |
| 265 // The BookmarkModel; may be null when testing. |
| 266 bookmarks::BookmarkModel* bookmark_model_; |
| 267 |
262 // The HistoryService; may be null when testing. | 268 // The HistoryService; may be null when testing. |
263 history::HistoryService* history_service_; | 269 history::HistoryService* history_service_; |
264 | 270 |
265 // Directory where cache file resides. This is, except when unit testing, | 271 // Directory where cache file resides. This is, except when unit testing, |
266 // the same directory in which the history database is found. It should never | 272 // the same directory in which the history database is found. It should never |
267 // be empty. | 273 // be empty. |
268 base::FilePath history_dir_; | 274 base::FilePath history_dir_; |
269 | 275 |
270 // Languages used during the word-breaking process during indexing. | 276 // Languages used during the word-breaking process during indexing. |
271 std::string languages_; | 277 std::string languages_; |
(...skipping 24 matching lines...) Expand all Loading... |
296 bool needs_to_be_cached_; | 302 bool needs_to_be_cached_; |
297 | 303 |
298 // This flag is set to true if we want to listen to the | 304 // This flag is set to true if we want to listen to the |
299 // HistoryServiceLoaded Notification. | 305 // HistoryServiceLoaded Notification. |
300 bool listen_to_history_service_loaded_; | 306 bool listen_to_history_service_loaded_; |
301 | 307 |
302 DISALLOW_COPY_AND_ASSIGN(InMemoryURLIndex); | 308 DISALLOW_COPY_AND_ASSIGN(InMemoryURLIndex); |
303 }; | 309 }; |
304 | 310 |
305 #endif // CHROME_BROWSER_AUTOCOMPLETE_IN_MEMORY_URL_INDEX_H_ | 311 #endif // CHROME_BROWSER_AUTOCOMPLETE_IN_MEMORY_URL_INDEX_H_ |
OLD | NEW |