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

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: Rebase to tip Created 5 years, 10 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 // 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 10 matching lines...) Expand all
21 #define CHROME_BROWSER_HISTORY_IN_MEMORY_HISTORY_BACKEND_H_ 21 #define CHROME_BROWSER_HISTORY_IN_MEMORY_HISTORY_BACKEND_H_
22 22
23 #include <string> 23 #include <string>
24 24
25 #include "base/basictypes.h" 25 #include "base/basictypes.h"
26 #include "base/gtest_prod_util.h" 26 #include "base/gtest_prod_util.h"
27 #include "base/memory/scoped_ptr.h" 27 #include "base/memory/scoped_ptr.h"
28 #include "base/scoped_observer.h" 28 #include "base/scoped_observer.h"
29 #include "components/history/core/browser/history_service_observer.h" 29 #include "components/history/core/browser/history_service_observer.h"
30 #include "components/history/core/browser/keyword_id.h" 30 #include "components/history/core/browser/keyword_id.h"
31 #include "content/public/browser/notification_observer.h"
32 #include "content/public/browser/notification_registrar.h"
33 31
34 class HistoryService; 32 class HistoryService;
35 class Profile;
36 33
37 namespace base { 34 namespace base {
38 class FilePath; 35 class FilePath;
39 } 36 }
40 37
41 namespace history { 38 namespace history {
42 39
43 class InMemoryDatabase; 40 class InMemoryDatabase;
44 class URLDatabase; 41 class URLDatabase;
45 class URLRow; 42 class URLRow;
46 struct URLsDeletedDetails;
47 struct URLsModifiedDetails;
48 43
49 class InMemoryHistoryBackend : public HistoryServiceObserver, 44 class InMemoryHistoryBackend : public HistoryServiceObserver {
50 public content::NotificationObserver {
51 public: 45 public:
52 InMemoryHistoryBackend(); 46 InMemoryHistoryBackend();
53 ~InMemoryHistoryBackend() override; 47 ~InMemoryHistoryBackend() override;
54 48
55 // Initializes the backend from the history database pointed to by the 49 // Initializes the backend from the history database pointed to by the
56 // full path in |history_filename|. 50 // full path in |history_filename|.
57 bool Init(const base::FilePath& history_filename); 51 bool Init(const base::FilePath& history_filename);
58 52
59 // Does initialization work when this object is attached to the history 53 // Does initialization work when this object is attached to the history
60 // system on the main thread. The argument is the profile with which the 54 // system on the main thread. The argument is the profile with which the
61 // attached history service is under. 55 // attached history service is under.
62 void AttachToHistoryService(Profile* profile, 56 void AttachToHistoryService(HistoryService* history_service);
63 HistoryService* history_service);
64 57
65 // Deletes all search terms for the specified keyword. 58 // Deletes all search terms for the specified keyword.
66 void DeleteAllSearchTermsForKeyword(KeywordID keyword_id); 59 void DeleteAllSearchTermsForKeyword(KeywordID keyword_id);
67 60
68 // Returns the underlying database associated with this backend. The current 61 // Returns the underlying database associated with this backend. The current
69 // autocomplete code was written fro this, but it should probably be removed 62 // autocomplete code was written fro this, but it should probably be removed
70 // so that it can deal directly with this object, rather than the DB. 63 // so that it can deal directly with this object, rather than the DB.
71 InMemoryDatabase* db() const { 64 InMemoryDatabase* db() const {
72 return db_.get(); 65 return db_.get();
73 } 66 }
74 67
68 private:
69 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAll);
70 FRIEND_TEST_ALL_PREFIXES(InMemoryHistoryBackendTest, OnURLsDeletedEnMasse);
71 friend class HistoryBackendTestBase;
72 friend class InMemoryHistoryBackendTest;
73
75 // HistoryServiceObserver: 74 // HistoryServiceObserver:
76 void OnURLVisited(HistoryService* history_service, 75 void OnURLVisited(HistoryService* history_service,
77 ui::PageTransition transition, 76 ui::PageTransition transition,
78 const URLRow& row, 77 const URLRow& row,
79 const RedirectList& redirects, 78 const RedirectList& redirects,
80 base::Time visit_time) override; 79 base::Time visit_time) override;
81 void OnURLsModified(HistoryService* history_service, 80 void OnURLsModified(HistoryService* history_service,
82 const URLRows& changed_urls) override; 81 const URLRows& changed_urls) override;
82 void OnURLsDeleted(HistoryService* history_service,
83 bool all_history,
84 bool expired,
85 const URLRows& deleted_rows,
86 const std::set<GURL>& favicon_urls) override;
83 void OnKeywordSearchTermUpdated(HistoryService* history_service, 87 void OnKeywordSearchTermUpdated(HistoryService* history_service,
84 const URLRow& row, 88 const URLRow& row,
85 KeywordID keyword_id, 89 KeywordID keyword_id,
86 const base::string16& term) override; 90 const base::string16& term) override;
87 void OnKeywordSearchTermDeleted(HistoryService* history_service, 91 void OnKeywordSearchTermDeleted(HistoryService* history_service,
88 URLID url_id) override; 92 URLID url_id) override;
89 93
90 // Notification callback.
91 void Observe(int type,
92 const content::NotificationSource& source,
93 const content::NotificationDetails& details) override;
94
95 private: 94 private:
96 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAll); 95 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAll);
97 96
98 // Handler for HISTORY_URL_VISITED and HISTORY_URLS_MODIFIED. 97 // Handler for HISTORY_URL_VISITED and HISTORY_URLS_MODIFIED.
99 void OnURLVisitedOrModified(const URLRow& url_row); 98 void OnURLVisitedOrModified(const URLRow& url_row);
100 99
101 // Handler for HISTORY_URLS_DELETED.
102 void OnURLsDeleted(const URLsDeletedDetails& details);
103
104 content::NotificationRegistrar registrar_;
105
106 scoped_ptr<InMemoryDatabase> db_; 100 scoped_ptr<InMemoryDatabase> db_;
107 101
108 // The profile that this object is attached. May be NULL before
109 // initialization.
110 Profile* profile_;
111 ScopedObserver<HistoryService, HistoryServiceObserver> 102 ScopedObserver<HistoryService, HistoryServiceObserver>
112 history_service_observer_; 103 history_service_observer_;
113 HistoryService* history_service_;
114 104
115 DISALLOW_COPY_AND_ASSIGN(InMemoryHistoryBackend); 105 DISALLOW_COPY_AND_ASSIGN(InMemoryHistoryBackend);
116 }; 106 };
117 107
118 } // namespace history 108 } // namespace history
119 109
120 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_HISTORY_BACKEND_H_ 110 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_HISTORY_BACKEND_H_
OLDNEW
« no previous file with comments | « chrome/browser/history/history_unittest.cc ('k') | chrome/browser/history/in_memory_history_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698