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