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 // The InMemoryHistoryBackend is a wrapper around the in-memory URL database. | 5 // The InMemoryHistoryBackend is a wrapper around the in-memory URL database. |
6 // It maintains an in-memory cache of a subset of history that is required for | 6 // It maintains an in-memory cache of a subset of history that is required for |
7 // low-latency operations, such as in-line autocomplete. | 7 // low-latency operations, such as in-line autocomplete. |
8 // | 8 // |
9 // The in-memory cache provides the following guarantees: | 9 // The in-memory cache provides the following guarantees: |
10 // (1.) It will always contain URLRows that either have a |typed_count| > 0; or | 10 // (1.) It will always contain URLRows that either have a |typed_count| > 0; or |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 struct KeywordSearchDeletedDetails; | 44 struct KeywordSearchDeletedDetails; |
45 class URLDatabase; | 45 class URLDatabase; |
46 class URLRow; | 46 class URLRow; |
47 struct URLsDeletedDetails; | 47 struct URLsDeletedDetails; |
48 struct URLsModifiedDetails; | 48 struct URLsModifiedDetails; |
49 | 49 |
50 class InMemoryHistoryBackend : public HistoryServiceObserver, | 50 class InMemoryHistoryBackend : public HistoryServiceObserver, |
51 public content::NotificationObserver { | 51 public content::NotificationObserver { |
52 public: | 52 public: |
53 InMemoryHistoryBackend(); | 53 InMemoryHistoryBackend(); |
54 virtual ~InMemoryHistoryBackend(); | 54 ~InMemoryHistoryBackend() override; |
55 | 55 |
56 // Initializes the backend from the history database pointed to by the | 56 // Initializes the backend from the history database pointed to by the |
57 // full path in |history_filename|. | 57 // full path in |history_filename|. |
58 bool Init(const base::FilePath& history_filename); | 58 bool Init(const base::FilePath& history_filename); |
59 | 59 |
60 // Does initialization work when this object is attached to the history | 60 // Does initialization work when this object is attached to the history |
61 // system on the main thread. The argument is the profile with which the | 61 // system on the main thread. The argument is the profile with which the |
62 // attached history service is under. | 62 // attached history service is under. |
63 void AttachToHistoryService(Profile* profile, | 63 void AttachToHistoryService(Profile* profile, |
64 HistoryService* history_service); | 64 HistoryService* history_service); |
65 | 65 |
66 // Deletes all search terms for the specified keyword. | 66 // Deletes all search terms for the specified keyword. |
67 void DeleteAllSearchTermsForKeyword(KeywordID keyword_id); | 67 void DeleteAllSearchTermsForKeyword(KeywordID keyword_id); |
68 | 68 |
69 // Returns the underlying database associated with this backend. The current | 69 // Returns the underlying database associated with this backend. The current |
70 // autocomplete code was written fro this, but it should probably be removed | 70 // autocomplete code was written fro this, but it should probably be removed |
71 // so that it can deal directly with this object, rather than the DB. | 71 // so that it can deal directly with this object, rather than the DB. |
72 InMemoryDatabase* db() const { | 72 InMemoryDatabase* db() const { |
73 return db_.get(); | 73 return db_.get(); |
74 } | 74 } |
75 | 75 |
76 // HistoryServiceObserver: | 76 // HistoryServiceObserver: |
77 virtual void OnURLVisited(HistoryService* history_service, | 77 void OnURLVisited(HistoryService* history_service, |
78 ui::PageTransition transition, | 78 ui::PageTransition transition, |
79 const URLRow& row, | 79 const URLRow& row, |
80 const RedirectList& redirects, | 80 const RedirectList& redirects, |
81 base::Time visit_time) override; | 81 base::Time visit_time) override; |
82 | 82 |
83 // Notification callback. | 83 // Notification callback. |
84 virtual void Observe(int type, | 84 void Observe(int type, |
85 const content::NotificationSource& source, | 85 const content::NotificationSource& source, |
86 const content::NotificationDetails& details) override; | 86 const content::NotificationDetails& details) override; |
87 | 87 |
88 private: | 88 private: |
89 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAll); | 89 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAll); |
90 | 90 |
91 // Handler for HISTORY_URL_VISITED and HISTORY_URLS_MODIFIED. | 91 // Handler for HISTORY_URL_VISITED and HISTORY_URLS_MODIFIED. |
92 void OnURLVisitedOrModified(const URLRow& url_row); | 92 void OnURLVisitedOrModified(const URLRow& url_row); |
93 | 93 |
94 // Handler for HISTORY_URLS_DELETED. | 94 // Handler for HISTORY_URLS_DELETED. |
95 void OnURLsDeleted(const URLsDeletedDetails& details); | 95 void OnURLsDeleted(const URLsDeletedDetails& details); |
96 | 96 |
(...skipping 11 matching lines...) Expand all Loading... |
108 // initialization. | 108 // initialization. |
109 Profile* profile_; | 109 Profile* profile_; |
110 HistoryService* history_service_; | 110 HistoryService* history_service_; |
111 | 111 |
112 DISALLOW_COPY_AND_ASSIGN(InMemoryHistoryBackend); | 112 DISALLOW_COPY_AND_ASSIGN(InMemoryHistoryBackend); |
113 }; | 113 }; |
114 | 114 |
115 } // namespace history | 115 } // namespace history |
116 | 116 |
117 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_HISTORY_BACKEND_H_ | 117 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_HISTORY_BACKEND_H_ |
OLD | NEW |