| 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 23 matching lines...) Expand all Loading... |
| 34 class HistoryService; | 34 class HistoryService; |
| 35 class Profile; | 35 class Profile; |
| 36 | 36 |
| 37 namespace base { | 37 namespace base { |
| 38 class FilePath; | 38 class FilePath; |
| 39 } | 39 } |
| 40 | 40 |
| 41 namespace history { | 41 namespace history { |
| 42 | 42 |
| 43 class InMemoryDatabase; | 43 class InMemoryDatabase; |
| 44 struct KeywordSearchDeletedDetails; | |
| 45 class URLDatabase; | 44 class URLDatabase; |
| 46 class URLRow; | 45 class URLRow; |
| 47 struct URLsDeletedDetails; | 46 struct URLsDeletedDetails; |
| 48 struct URLsModifiedDetails; | 47 struct URLsModifiedDetails; |
| 49 | 48 |
| 50 class InMemoryHistoryBackend : public HistoryServiceObserver, | 49 class InMemoryHistoryBackend : public HistoryServiceObserver, |
| 51 public content::NotificationObserver { | 50 public content::NotificationObserver { |
| 52 public: | 51 public: |
| 53 InMemoryHistoryBackend(); | 52 InMemoryHistoryBackend(); |
| 54 ~InMemoryHistoryBackend() override; | 53 ~InMemoryHistoryBackend() override; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 78 ui::PageTransition transition, | 77 ui::PageTransition transition, |
| 79 const URLRow& row, | 78 const URLRow& row, |
| 80 const RedirectList& redirects, | 79 const RedirectList& redirects, |
| 81 base::Time visit_time) override; | 80 base::Time visit_time) override; |
| 82 void OnURLsModified(HistoryService* history_service, | 81 void OnURLsModified(HistoryService* history_service, |
| 83 const URLRows& changed_urls) override; | 82 const URLRows& changed_urls) override; |
| 84 void OnKeywordSearchTermUpdated(HistoryService* history_service, | 83 void OnKeywordSearchTermUpdated(HistoryService* history_service, |
| 85 const URLRow& row, | 84 const URLRow& row, |
| 86 KeywordID keyword_id, | 85 KeywordID keyword_id, |
| 87 const base::string16& term) override; | 86 const base::string16& term) override; |
| 87 void OnKeywordSearchTermDeleted(HistoryService* history_service, |
| 88 URLID url_id) override; |
| 88 | 89 |
| 89 // Notification callback. | 90 // Notification callback. |
| 90 void Observe(int type, | 91 void Observe(int type, |
| 91 const content::NotificationSource& source, | 92 const content::NotificationSource& source, |
| 92 const content::NotificationDetails& details) override; | 93 const content::NotificationDetails& details) override; |
| 93 | 94 |
| 94 private: | 95 private: |
| 95 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAll); | 96 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAll); |
| 96 | 97 |
| 97 // Handler for HISTORY_URL_VISITED and HISTORY_URLS_MODIFIED. | 98 // Handler for HISTORY_URL_VISITED and HISTORY_URLS_MODIFIED. |
| 98 void OnURLVisitedOrModified(const URLRow& url_row); | 99 void OnURLVisitedOrModified(const URLRow& url_row); |
| 99 | 100 |
| 100 // Handler for HISTORY_URLS_DELETED. | 101 // Handler for HISTORY_URLS_DELETED. |
| 101 void OnURLsDeleted(const URLsDeletedDetails& details); | 102 void OnURLsDeleted(const URLsDeletedDetails& details); |
| 102 | 103 |
| 103 // Handler for HISTORY_KEYWORD_SEARCH_TERM_DELETED. | |
| 104 void OnKeywordSearchTermDeleted(const KeywordSearchDeletedDetails& details); | |
| 105 | |
| 106 content::NotificationRegistrar registrar_; | 104 content::NotificationRegistrar registrar_; |
| 107 | 105 |
| 108 scoped_ptr<InMemoryDatabase> db_; | 106 scoped_ptr<InMemoryDatabase> db_; |
| 109 | 107 |
| 110 // The profile that this object is attached. May be NULL before | 108 // The profile that this object is attached. May be NULL before |
| 111 // initialization. | 109 // initialization. |
| 112 Profile* profile_; | 110 Profile* profile_; |
| 113 ScopedObserver<HistoryService, HistoryServiceObserver> | 111 ScopedObserver<HistoryService, HistoryServiceObserver> |
| 114 history_service_observer_; | 112 history_service_observer_; |
| 115 HistoryService* history_service_; | 113 HistoryService* history_service_; |
| 116 | 114 |
| 117 DISALLOW_COPY_AND_ASSIGN(InMemoryHistoryBackend); | 115 DISALLOW_COPY_AND_ASSIGN(InMemoryHistoryBackend); |
| 118 }; | 116 }; |
| 119 | 117 |
| 120 } // namespace history | 118 } // namespace history |
| 121 | 119 |
| 122 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_HISTORY_BACKEND_H_ | 120 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_HISTORY_BACKEND_H_ |
| OLD | NEW |