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

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

Issue 773103004: Remove NOTIFICATION_HISTORY_URLS_DELETED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed local variables in tests Created 6 years 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 // 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 27 matching lines...) Expand all
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; 44 struct KeywordSearchUpdatedDetails;
45 struct KeywordSearchDeletedDetails; 45 struct KeywordSearchDeletedDetails;
46 class URLDatabase; 46 class URLDatabase;
47 class URLRow; 47 class URLRow;
48 struct URLsDeletedDetails;
49 struct URLsModifiedDetails;
50 48
51 class InMemoryHistoryBackend : public HistoryServiceObserver, 49 class InMemoryHistoryBackend : public HistoryServiceObserver,
52 public content::NotificationObserver { 50 public content::NotificationObserver {
53 public: 51 public:
54 InMemoryHistoryBackend(); 52 InMemoryHistoryBackend();
55 ~InMemoryHistoryBackend() override; 53 ~InMemoryHistoryBackend() override;
56 54
57 // Initializes the backend from the history database pointed to by the 55 // Initializes the backend from the history database pointed to by the
58 // full path in |history_filename|. 56 // full path in |history_filename|.
59 bool Init(const base::FilePath& history_filename); 57 bool Init(const base::FilePath& history_filename);
60 58
61 // Does initialization work when this object is attached to the history 59 // Does initialization work when this object is attached to the history
62 // system on the main thread. The argument is the profile with which the 60 // system on the main thread. The argument is the profile with which the
63 // attached history service is under. 61 // attached history service is under.
64 void AttachToHistoryService(Profile* profile, 62 void AttachToHistoryService(Profile* profile,
65 HistoryService* history_service); 63 HistoryService* history_service);
66 64
67 // Deletes all search terms for the specified keyword. 65 // Deletes all search terms for the specified keyword.
68 void DeleteAllSearchTermsForKeyword(KeywordID keyword_id); 66 void DeleteAllSearchTermsForKeyword(KeywordID keyword_id);
69 67
70 // Returns the underlying database associated with this backend. The current 68 // Returns the underlying database associated with this backend. The current
71 // autocomplete code was written fro this, but it should probably be removed 69 // autocomplete code was written fro this, but it should probably be removed
72 // so that it can deal directly with this object, rather than the DB. 70 // so that it can deal directly with this object, rather than the DB.
73 InMemoryDatabase* db() const { 71 InMemoryDatabase* db() const {
74 return db_.get(); 72 return db_.get();
75 } 73 }
76 74
75 // Notification callback.
76 void Observe(int type,
77 const content::NotificationSource& source,
78 const content::NotificationDetails& details) override;
79
80 private:
81 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAll);
82 FRIEND_TEST_ALL_PREFIXES(InMemoryHistoryBackendTest, OnURLsDeletedEnMasse);
83 friend class HistoryBackendTestBase;
84 friend class InMemoryHistoryBackendTest;
85
77 // HistoryServiceObserver: 86 // HistoryServiceObserver:
78 void OnURLVisited(HistoryService* history_service, 87 void OnURLVisited(HistoryService* history_service,
79 ui::PageTransition transition, 88 ui::PageTransition transition,
80 const URLRow& row, 89 const URLRow& row,
81 const RedirectList& redirects, 90 const RedirectList& redirects,
82 base::Time visit_time) override; 91 base::Time visit_time) override;
83 void OnURLsModified(HistoryService* history_service, 92 void OnURLsModified(HistoryService* history_service,
84 const URLRows& changed_urls) override; 93 const URLRows& changed_urls) override;
85 94 void OnURLsDeleted(HistoryService* history_service,
86 // Notification callback. 95 bool all_history,
87 void Observe(int type, 96 bool expired,
88 const content::NotificationSource& source, 97 const URLRows& deleted_rows,
89 const content::NotificationDetails& details) override; 98 const std::set<GURL>& favicon_urls) override;
90
91 private:
92 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAll);
93 99
94 // Handler for HISTORY_URL_VISITED and HISTORY_URLS_MODIFIED. 100 // Handler for HISTORY_URL_VISITED and HISTORY_URLS_MODIFIED.
95 void OnURLVisitedOrModified(const URLRow& url_row); 101 void OnURLVisitedOrModified(const URLRow& url_row);
96 102
97 // Handler for HISTORY_URLS_DELETED.
98 void OnURLsDeleted(const URLsDeletedDetails& details);
99
100 // Handler for HISTORY_KEYWORD_SEARCH_TERM_UPDATED. 103 // Handler for HISTORY_KEYWORD_SEARCH_TERM_UPDATED.
101 void OnKeywordSearchTermUpdated(const KeywordSearchUpdatedDetails& details); 104 void OnKeywordSearchTermUpdated(const KeywordSearchUpdatedDetails& details);
102 105
103 // Handler for HISTORY_KEYWORD_SEARCH_TERM_DELETED. 106 // Handler for HISTORY_KEYWORD_SEARCH_TERM_DELETED.
104 void OnKeywordSearchTermDeleted(const KeywordSearchDeletedDetails& details); 107 void OnKeywordSearchTermDeleted(const KeywordSearchDeletedDetails& details);
105 108
106 content::NotificationRegistrar registrar_; 109 content::NotificationRegistrar registrar_;
107 110
108 scoped_ptr<InMemoryDatabase> db_; 111 scoped_ptr<InMemoryDatabase> db_;
109 112
110 // The profile that this object is attached. May be NULL before 113 // The profile that this object is attached. May be NULL before
111 // initialization. 114 // initialization.
112 Profile* profile_; 115 Profile* profile_;
113 ScopedObserver<HistoryService, HistoryServiceObserver> 116 ScopedObserver<HistoryService, HistoryServiceObserver>
114 history_service_observer_; 117 history_service_observer_;
115 HistoryService* history_service_; 118 HistoryService* history_service_;
116 119
117 DISALLOW_COPY_AND_ASSIGN(InMemoryHistoryBackend); 120 DISALLOW_COPY_AND_ASSIGN(InMemoryHistoryBackend);
118 }; 121 };
119 122
120 } // namespace history 123 } // namespace history
121 124
122 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_HISTORY_BACKEND_H_ 125 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_HISTORY_BACKEND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698