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

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: Fixed styling issue 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 #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/history/shortcuts_database.h" 21 #include "chrome/browser/history/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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 bool DeleteShortcutsWithIDs( 124 bool DeleteShortcutsWithIDs(
122 const history::ShortcutsDatabase::ShortcutIDs& shortcut_ids); 125 const history::ShortcutsDatabase::ShortcutIDs& shortcut_ids);
123 126
124 // Deletes all shortcuts whose URLs begin with |url|. If |exact_match| is 127 // Deletes all shortcuts whose URLs begin with |url|. If |exact_match| is
125 // true, only shortcuts from exactly |url| are deleted. 128 // true, only shortcuts from exactly |url| are deleted.
126 bool DeleteShortcutsWithURL(const GURL& url, bool exact_match); 129 bool DeleteShortcutsWithURL(const GURL& url, bool exact_match);
127 130
128 // Deletes all of the shortcuts. 131 // Deletes all of the shortcuts.
129 bool DeleteAllShortcuts(); 132 bool DeleteAllShortcuts();
130 133
134 // history::HistoryServiceObserver:
Peter Kasting 2014/12/11 19:59:35 Nit: Please move this to just below the private No
nshaik 2014/12/12 05:40:56 Done.
135 void OnURLsDeleted(HistoryService* history_service,
136 bool all_history,
137 bool expired,
138 const history::URLRows& deleted_rows,
139 const std::set<GURL>& favicon_urls) override;
140
131 Profile* profile_; 141 Profile* profile_;
132 CurrentState current_state_; 142 CurrentState current_state_;
133 ObserverList<ShortcutsBackendObserver> observer_list_; 143 ObserverList<ShortcutsBackendObserver> observer_list_;
134 scoped_refptr<history::ShortcutsDatabase> db_; 144 scoped_refptr<history::ShortcutsDatabase> db_;
135 145
136 // The |temp_shortcuts_map_| and |temp_guid_map_| used for temporary storage 146 // The |temp_shortcuts_map_| and |temp_guid_map_| used for temporary storage
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_;
147 157
148 // For some unit-test only. 158 // For some unit-test only.
149 bool no_db_access_; 159 bool no_db_access_;
150 160
161 ScopedObserver<HistoryService, HistoryServiceObserver>
Peter Kasting 2014/12/11 19:59:35 Nit: I would probably move this above the |no_db_a
nshaik 2014/12/12 05:40:56 Done.
162 history_service_observer_;
163
151 DISALLOW_COPY_AND_ASSIGN(ShortcutsBackend); 164 DISALLOW_COPY_AND_ASSIGN(ShortcutsBackend);
152 }; 165 };
153 166
154 #endif // CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_BACKEND_H_ 167 #endif // CHROME_BROWSER_AUTOCOMPLETE_SHORTCUTS_BACKEND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698