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_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> |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // |profile|, which may be NULL during unit testing, is used to register for | 99 // |profile|, which may be NULL during unit testing, is used to register for |
100 // history changes. |history_dir| is a path to the directory containing the | 100 // history changes. |history_dir| is a path to the directory containing the |
101 // history database within the profile wherein the cache and transaction | 101 // history database within the profile wherein the cache and transaction |
102 // journals will be stored. |languages| gives a list of language encodings by | 102 // journals will be stored. |languages| gives a list of language encodings by |
103 // which URLs and omnibox searches are broken down into words and characters. | 103 // which URLs and omnibox searches are broken down into words and characters. |
104 InMemoryURLIndex(Profile* profile, | 104 InMemoryURLIndex(Profile* profile, |
105 HistoryService* history_service, | 105 HistoryService* history_service, |
106 const base::FilePath& history_dir, | 106 const base::FilePath& history_dir, |
107 const std::string& languages, | 107 const std::string& languages, |
108 HistoryClient* client); | 108 HistoryClient* client); |
109 virtual ~InMemoryURLIndex(); | 109 ~InMemoryURLIndex() override; |
110 | 110 |
111 // Opens and prepares the index of historical URL visits. If the index private | 111 // Opens and prepares the index of historical URL visits. If the index private |
112 // data cannot be restored from its cache file then it is rebuilt from the | 112 // data cannot be restored from its cache file then it is rebuilt from the |
113 // history database. | 113 // history database. |
114 void Init(); | 114 void Init(); |
115 | 115 |
116 // Signals that any outstanding initialization should be canceled and | 116 // Signals that any outstanding initialization should be canceled and |
117 // flushes the cache to disk. | 117 // flushes the cache to disk. |
118 void ShutDown(); | 118 void ShutDown(); |
119 | 119 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 InMemoryURLIndex(); | 156 InMemoryURLIndex(); |
157 | 157 |
158 // HistoryDBTask used to rebuild our private data from the history database. | 158 // HistoryDBTask used to rebuild our private data from the history database. |
159 class RebuildPrivateDataFromHistoryDBTask : public HistoryDBTask { | 159 class RebuildPrivateDataFromHistoryDBTask : public HistoryDBTask { |
160 public: | 160 public: |
161 explicit RebuildPrivateDataFromHistoryDBTask( | 161 explicit RebuildPrivateDataFromHistoryDBTask( |
162 InMemoryURLIndex* index, | 162 InMemoryURLIndex* index, |
163 const std::string& languages, | 163 const std::string& languages, |
164 const std::set<std::string>& scheme_whitelist); | 164 const std::set<std::string>& scheme_whitelist); |
165 | 165 |
166 virtual bool RunOnDBThread(HistoryBackend* backend, | 166 bool RunOnDBThread(HistoryBackend* backend, |
167 history::HistoryDatabase* db) override; | 167 history::HistoryDatabase* db) override; |
168 virtual void DoneRunOnMainThread() override; | 168 void DoneRunOnMainThread() override; |
169 | 169 |
170 private: | 170 private: |
171 virtual ~RebuildPrivateDataFromHistoryDBTask(); | 171 ~RebuildPrivateDataFromHistoryDBTask() override; |
172 | 172 |
173 InMemoryURLIndex* index_; // Call back to this index at completion. | 173 InMemoryURLIndex* index_; // Call back to this index at completion. |
174 std::string languages_; // Languages for word-breaking. | 174 std::string languages_; // Languages for word-breaking. |
175 std::set<std::string> scheme_whitelist_; // Schemes to be indexed. | 175 std::set<std::string> scheme_whitelist_; // Schemes to be indexed. |
176 bool succeeded_; // Indicates if the rebuild was successful. | 176 bool succeeded_; // Indicates if the rebuild was successful. |
177 scoped_refptr<URLIndexPrivateData> data_; // The rebuilt private data. | 177 scoped_refptr<URLIndexPrivateData> data_; // The rebuilt private data. |
178 | 178 |
179 DISALLOW_COPY_AND_ASSIGN(RebuildPrivateDataFromHistoryDBTask); | 179 DISALLOW_COPY_AND_ASSIGN(RebuildPrivateDataFromHistoryDBTask); |
180 }; | 180 }; |
181 | 181 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 228 |
229 // Saves private_data_ to the given |path|. Runs on the UI thread. | 229 // Saves private_data_ to the given |path|. Runs on the UI thread. |
230 // Provided for unit testing so that a test cache file can be used. | 230 // Provided for unit testing so that a test cache file can be used. |
231 void DoSaveToCacheFile(const base::FilePath& path); | 231 void DoSaveToCacheFile(const base::FilePath& path); |
232 | 232 |
233 // Notifies the observer, if any, of the success of the private data caching. | 233 // Notifies the observer, if any, of the success of the private data caching. |
234 // |succeeded| is true on a successful save. | 234 // |succeeded| is true on a successful save. |
235 void OnCacheSaveDone(bool succeeded); | 235 void OnCacheSaveDone(bool succeeded); |
236 | 236 |
237 // Handles notifications of history changes. | 237 // Handles notifications of history changes. |
238 virtual void Observe(int notification_type, | 238 void Observe(int notification_type, |
239 const content::NotificationSource& source, | 239 const content::NotificationSource& source, |
240 const content::NotificationDetails& details) override; | 240 const content::NotificationDetails& details) override; |
241 | 241 |
242 // HistoryServiceObserver: | 242 // HistoryServiceObserver: |
243 virtual void OnURLVisited(HistoryService* history_service, | 243 void OnURLVisited(HistoryService* history_service, |
244 ui::PageTransition transition, | 244 ui::PageTransition transition, |
245 const URLRow& row, | 245 const URLRow& row, |
246 const RedirectList& redirects, | 246 const RedirectList& redirects, |
247 base::Time visit_time) override; | 247 base::Time visit_time) override; |
248 | 248 |
249 // Notification handlers. | 249 // Notification handlers. |
250 void OnURLsModified(const URLsModifiedDetails* details); | 250 void OnURLsModified(const URLsModifiedDetails* details); |
251 void OnURLsDeleted(const URLsDeletedDetails* details); | 251 void OnURLsDeleted(const URLsDeletedDetails* details); |
252 | 252 |
253 // Sets the directory wherein the cache file will be maintained. | 253 // Sets the directory wherein the cache file will be maintained. |
254 // For unit test usage only. | 254 // For unit test usage only. |
255 void set_history_dir(const base::FilePath& dir_path) { | 255 void set_history_dir(const base::FilePath& dir_path) { |
256 history_dir_ = dir_path; | 256 history_dir_ = dir_path; |
257 } | 257 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 // temporary safety check to insure that the cache is saved before the | 308 // temporary safety check to insure that the cache is saved before the |
309 // index has been destructed. | 309 // index has been destructed. |
310 bool needs_to_be_cached_; | 310 bool needs_to_be_cached_; |
311 | 311 |
312 DISALLOW_COPY_AND_ASSIGN(InMemoryURLIndex); | 312 DISALLOW_COPY_AND_ASSIGN(InMemoryURLIndex); |
313 }; | 313 }; |
314 | 314 |
315 } // namespace history | 315 } // namespace history |
316 | 316 |
317 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_URL_INDEX_H_ | 317 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_URL_INDEX_H_ |
OLD | NEW |