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

Side by Side Diff: chrome/browser/autocomplete/shortcuts_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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_BACKEND_H_ 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_BACKEND_H_
6 #define CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_BACKEND_H_ 6 #define CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_BACKEND_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "base/scoped_observer.h"
17 #include "base/strings/string16.h" 18 #include "base/strings/string16.h"
18 #include "base/synchronization/lock.h" 19 #include "base/synchronization/lock.h"
19 #include "base/time/time.h" 20 #include "base/time/time.h"
20 #include "chrome/browser/autocomplete/shortcuts_database.h" 21 #include "chrome/browser/autocomplete/shortcuts_database.h"
22 #include "components/history/core/browser/history_service_observer.h"
21 #include "components/keyed_service/core/refcounted_keyed_service.h" 23 #include "components/keyed_service/core/refcounted_keyed_service.h"
22 #include "components/omnibox/autocomplete_match.h" 24 #include "components/omnibox/autocomplete_match.h"
23 #include "content/public/browser/notification_observer.h" 25 #include "content/public/browser/notification_observer.h"
24 #include "content/public/browser/notification_registrar.h" 26 #include "content/public/browser/notification_registrar.h"
25 #include "url/gurl.h" 27 #include "url/gurl.h"
26 28
27 class Profile; 29 class Profile;
28 30
29 namespace history { 31 namespace history {
30 class ShortcutsDatabase; 32 class ShortcutsDatabase;
31 }; // namespace history 33 }; // namespace history
32 34
33 // This class manages the shortcut provider backend - access to database on the 35 // This class manages the shortcut provider backend - access to database on the
34 // db thread, etc. 36 // db thread, etc.
35 class ShortcutsBackend : public RefcountedKeyedService, 37 class ShortcutsBackend : public RefcountedKeyedService,
36 public content::NotificationObserver { 38 public content::NotificationObserver,
39 public history::HistoryServiceObserver {
37 public: 40 public:
38 typedef std::multimap<base::string16, 41 typedef std::multimap<base::string16,
39 const history::ShortcutsDatabase::Shortcut> ShortcutMap; 42 const history::ShortcutsDatabase::Shortcut> ShortcutMap;
40 43
41 // |profile| is necessary for profile notifications only and can be NULL in 44 // |profile| is necessary for profile notifications only and can be NULL in
42 // unit-tests. For unit testing, set |suppress_db| to true to prevent creation 45 // unit-tests. For unit testing, set |suppress_db| to true to prevent creation
43 // of the database, in which case all operations are performed in memory only. 46 // of the database, in which case all operations are performed in memory only.
44 ShortcutsBackend(Profile* profile, bool suppress_db); 47 ShortcutsBackend(Profile* profile, bool suppress_db);
45 48
46 // The interface is guaranteed to be called on the thread AddObserver() 49 // The interface is guaranteed to be called on the thread AddObserver()
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 const AutocompleteMatch& match, Profile* profile); 100 const AutocompleteMatch& match, Profile* profile);
98 101
99 // RefcountedKeyedService: 102 // RefcountedKeyedService:
100 void ShutdownOnUIThread() override; 103 void ShutdownOnUIThread() override;
101 104
102 // content::NotificationObserver: 105 // content::NotificationObserver:
103 void Observe(int type, 106 void Observe(int type,
104 const content::NotificationSource& source, 107 const content::NotificationSource& source,
105 const content::NotificationDetails& details) override; 108 const content::NotificationDetails& details) override;
106 109
110 // history::HistoryServiceObserver:
111 void OnURLsDeleted(HistoryService* history_service,
112 bool all_history,
113 bool expired,
114 const history::URLRows& deleted_rows,
115 const std::set<GURL>& favicon_urls) override;
116
107 // Internal initialization of the back-end. Posted by Init() to the DB thread. 117 // Internal initialization of the back-end. Posted by Init() to the DB thread.
108 // On completion posts InitCompleted() back to UI thread. 118 // On completion posts InitCompleted() back to UI thread.
109 void InitInternal(); 119 void InitInternal();
110 120
111 // Finishes initialization on UI thread, notifies all observers. 121 // Finishes initialization on UI thread, notifies all observers.
112 void InitCompleted(); 122 void InitCompleted();
113 123
114 // Adds the Shortcut to the database. 124 // Adds the Shortcut to the database.
115 bool AddShortcut(const history::ShortcutsDatabase::Shortcut& shortcut); 125 bool AddShortcut(const history::ShortcutsDatabase::Shortcut& shortcut);
116 126
(...skipping 20 matching lines...) Expand all
137 // between InitInternal() and InitComplete() to avoid doing a potentially huge 147 // between InitInternal() and InitComplete() to avoid doing a potentially huge
138 // copy. 148 // copy.
139 scoped_ptr<ShortcutMap> temp_shortcuts_map_; 149 scoped_ptr<ShortcutMap> temp_shortcuts_map_;
140 scoped_ptr<GuidMap> temp_guid_map_; 150 scoped_ptr<GuidMap> temp_guid_map_;
141 151
142 ShortcutMap shortcuts_map_; 152 ShortcutMap shortcuts_map_;
143 // This is a helper map for quick access to a shortcut by guid. 153 // This is a helper map for quick access to a shortcut by guid.
144 GuidMap guid_map_; 154 GuidMap guid_map_;
145 155
146 content::NotificationRegistrar notification_registrar_; 156 content::NotificationRegistrar notification_registrar_;
157 ScopedObserver<HistoryService, HistoryServiceObserver>
158 history_service_observer_;
147 159
148 // For some unit-test only. 160 // For some unit-test only.
149 bool no_db_access_; 161 bool no_db_access_;
150 162
151 DISALLOW_COPY_AND_ASSIGN(ShortcutsBackend); 163 DISALLOW_COPY_AND_ASSIGN(ShortcutsBackend);
152 }; 164 };
153 165
154 #endif // CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_BACKEND_H_ 166 #endif // CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_BACKEND_H_
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/history_quick_provider_unittest.cc ('k') | chrome/browser/autocomplete/shortcuts_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698