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

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

Issue 631253002: Refactor sending NOTIFICATION_HISTORY_URL_VISITED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests on Android Created 6 years, 2 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/history_db_task.h" 21 #include "chrome/browser/history/history_db_task.h"
22 #include "chrome/browser/history/in_memory_url_index_types.h" 22 #include "chrome/browser/history/in_memory_url_index_types.h"
23 #include "chrome/browser/history/scored_history_match.h" 23 #include "chrome/browser/history/scored_history_match.h"
24 #include "components/history/core/browser/history_service_observer.h"
24 #include "components/history/core/browser/history_types.h" 25 #include "components/history/core/browser/history_types.h"
25 #include "content/public/browser/notification_observer.h" 26 #include "content/public/browser/notification_observer.h"
26 #include "content/public/browser/notification_registrar.h" 27 #include "content/public/browser/notification_registrar.h"
27 #include "sql/connection.h" 28 #include "sql/connection.h"
28 29
30 class HistoryService;
29 class HistoryQuickProviderTest; 31 class HistoryQuickProviderTest;
30 class Profile; 32 class Profile;
31 33
32 namespace base { 34 namespace base {
33 class Time; 35 class Time;
34 } 36 }
35 37
36 namespace in_memory_url_index { 38 namespace in_memory_url_index {
37 class InMemoryURLIndexCacheItem; 39 class InMemoryURLIndexCacheItem;
38 } 40 }
(...skipping 21 matching lines...) Expand all
60 // words and characters in the URL history database except when converting 62 // words and characters in the URL history database except when converting
61 // URL strings to lowercase. Multi-byte-edness makes no difference when 63 // URL strings to lowercase. Multi-byte-edness makes no difference when
62 // indexing or when searching the index as the final filtering of results 64 // indexing or when searching the index as the final filtering of results
63 // is dependent on the comparison of a string of bytes, not individual 65 // is dependent on the comparison of a string of bytes, not individual
64 // characters. While the lookup of those bytes during a search in the 66 // characters. While the lookup of those bytes during a search in the
65 // |char_word_map_| could serve up words in which the individual char16 67 // |char_word_map_| could serve up words in which the individual char16
66 // occurs as a portion of a composite character the next filtering step 68 // occurs as a portion of a composite character the next filtering step
67 // will eliminate such words except in the case where a single character 69 // will eliminate such words except in the case where a single character
68 // is being searched on and which character occurs as the second char16 of a 70 // is being searched on and which character occurs as the second char16 of a
69 // multi-char16 instance. 71 // multi-char16 instance.
70 class InMemoryURLIndex : public content::NotificationObserver, 72 class InMemoryURLIndex : public HistoryServiceObserver,
73 public content::NotificationObserver,
71 public base::SupportsWeakPtr<InMemoryURLIndex> { 74 public base::SupportsWeakPtr<InMemoryURLIndex> {
72 public: 75 public:
73 // Defines an abstract class which is notified upon completion of restoring 76 // Defines an abstract class which is notified upon completion of restoring
74 // the index's private data either by reading from the cache file or by 77 // the index's private data either by reading from the cache file or by
75 // rebuilding from the history database. 78 // rebuilding from the history database.
76 class RestoreCacheObserver { 79 class RestoreCacheObserver {
77 public: 80 public:
78 virtual ~RestoreCacheObserver(); 81 virtual ~RestoreCacheObserver();
79 82
80 // Callback that lets the observer know that the restore operation has 83 // Callback that lets the observer know that the restore operation has
(...skipping 12 matching lines...) Expand all
93 // This is called on the UI thread. 96 // This is called on the UI thread.
94 virtual void OnCacheSaveFinished(bool succeeded) = 0; 97 virtual void OnCacheSaveFinished(bool succeeded) = 0;
95 }; 98 };
96 99
97 // |profile|, which may be NULL during unit testing, is used to register for 100 // |profile|, which may be NULL during unit testing, is used to register for
98 // history changes. |history_dir| is a path to the directory containing the 101 // history changes. |history_dir| is a path to the directory containing the
99 // history database within the profile wherein the cache and transaction 102 // history database within the profile wherein the cache and transaction
100 // journals will be stored. |languages| gives a list of language encodings by 103 // journals will be stored. |languages| gives a list of language encodings by
101 // which URLs and omnibox searches are broken down into words and characters. 104 // which URLs and omnibox searches are broken down into words and characters.
102 InMemoryURLIndex(Profile* profile, 105 InMemoryURLIndex(Profile* profile,
106 HistoryService* history_service,
103 const base::FilePath& history_dir, 107 const base::FilePath& history_dir,
104 const std::string& languages, 108 const std::string& languages,
105 HistoryClient* client); 109 HistoryClient* client);
106 virtual ~InMemoryURLIndex(); 110 virtual ~InMemoryURLIndex();
107 111
108 // Opens and prepares the index of historical URL visits. If the index private 112 // Opens and prepares the index of historical URL visits. If the index private
109 // data cannot be restored from its cache file then it is rebuilt from the 113 // data cannot be restored from its cache file then it is rebuilt from the
110 // history database. 114 // history database.
111 void Init(); 115 void Init();
112 116
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 233
230 // Notifies the observer, if any, of the success of the private data caching. 234 // Notifies the observer, if any, of the success of the private data caching.
231 // |succeeded| is true on a successful save. 235 // |succeeded| is true on a successful save.
232 void OnCacheSaveDone(bool succeeded); 236 void OnCacheSaveDone(bool succeeded);
233 237
234 // Handles notifications of history changes. 238 // Handles notifications of history changes.
235 virtual void Observe(int notification_type, 239 virtual void Observe(int notification_type,
236 const content::NotificationSource& source, 240 const content::NotificationSource& source,
237 const content::NotificationDetails& details) override; 241 const content::NotificationDetails& details) override;
238 242
243 // HistoryServiceObserver:
244 virtual void OnURLVisited(HistoryService* history_service,
245 ui::PageTransition transition,
246 const URLRow& row,
247 const RedirectList& redirects,
248 base::Time visit_time) OVERRIDE;
249
239 // Notification handlers. 250 // Notification handlers.
240 void OnURLVisited(const URLVisitedDetails* details);
241 void OnURLsModified(const URLsModifiedDetails* details); 251 void OnURLsModified(const URLsModifiedDetails* details);
242 void OnURLsDeleted(const URLsDeletedDetails* details); 252 void OnURLsDeleted(const URLsDeletedDetails* details);
243 253
244 // Sets the directory wherein the cache file will be maintained. 254 // Sets the directory wherein the cache file will be maintained.
245 // For unit test usage only. 255 // For unit test usage only.
246 void set_history_dir(const base::FilePath& dir_path) { 256 void set_history_dir(const base::FilePath& dir_path) {
247 history_dir_ = dir_path; 257 history_dir_ = dir_path;
248 } 258 }
249 259
250 // Returns a pointer to our private data. For unit testing only. 260 // Returns a pointer to our private data. For unit testing only.
251 URLIndexPrivateData* private_data() { return private_data_.get(); } 261 URLIndexPrivateData* private_data() { return private_data_.get(); }
252 262
253 // Returns a pointer to our private data cancelable request tracker. For 263 // Returns a pointer to our private data cancelable request tracker. For
254 // unit testing only. 264 // unit testing only.
255 base::CancelableTaskTracker* private_data_tracker() { 265 base::CancelableTaskTracker* private_data_tracker() {
256 return &private_data_tracker_; 266 return &private_data_tracker_;
257 } 267 }
258 268
259 // Returns the set of whitelisted schemes. For unit testing only. 269 // Returns the set of whitelisted schemes. For unit testing only.
260 const std::set<std::string>& scheme_whitelist() { return scheme_whitelist_; } 270 const std::set<std::string>& scheme_whitelist() { return scheme_whitelist_; }
261 271
262 // The profile, may be null when testing. 272 // The profile, may be null when testing.
263 Profile* profile_; 273 Profile* profile_;
274 HistoryService* history_service_;
264 275
265 // The HistoryClient; may be NULL when testing. 276 // The HistoryClient; may be NULL when testing.
266 HistoryClient* history_client_; 277 HistoryClient* history_client_;
267 278
268 // Directory where cache file resides. This is, except when unit testing, 279 // Directory where cache file resides. This is, except when unit testing,
269 // the same directory in which the profile's history database is found. It 280 // the same directory in which the profile's history database is found. It
270 // should never be empty. 281 // should never be empty.
271 base::FilePath history_dir_; 282 base::FilePath history_dir_;
272 283
273 // Languages used during the word-breaking process during indexing. 284 // Languages used during the word-breaking process during indexing.
(...skipping 24 matching lines...) Expand all
298 // temporary safety check to insure that the cache is saved before the 309 // temporary safety check to insure that the cache is saved before the
299 // index has been destructed. 310 // index has been destructed.
300 bool needs_to_be_cached_; 311 bool needs_to_be_cached_;
301 312
302 DISALLOW_COPY_AND_ASSIGN(InMemoryURLIndex); 313 DISALLOW_COPY_AND_ASSIGN(InMemoryURLIndex);
303 }; 314 };
304 315
305 } // namespace history 316 } // namespace history
306 317
307 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_URL_INDEX_H_ 318 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_URL_INDEX_H_
OLDNEW
« no previous file with comments | « chrome/browser/history/in_memory_history_backend.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