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/history/expire_history_backend.h

Issue 690733002: Cleanup HistoryBackend and ExpireHistoryBackend interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@android-cleanup
Patch Set: Created 6 years, 1 month 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_HISTORY_EXPIRE_HISTORY_BACKEND_H_ 5 #ifndef CHROME_BROWSER_HISTORY_EXPIRE_HISTORY_BACKEND_H_
6 #define CHROME_BROWSER_HISTORY_EXPIRE_HISTORY_BACKEND_H_ 6 #define CHROME_BROWSER_HISTORY_EXPIRE_HISTORY_BACKEND_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "components/history/core/browser/history_types.h" 17 #include "components/history/core/browser/history_types.h"
18 18
19 class GURL; 19 class GURL;
20 class TestingProfile; 20 class TestingProfile;
21 21
22 namespace history { 22 namespace history {
23 23
24 class HistoryClient; 24 class HistoryClient;
25 class HistoryDatabase; 25 class HistoryDatabase;
26 struct HistoryDetails; 26 struct HistoryDetails;
droger 2014/10/29 17:55:11 Remove.
sdefresne 2014/10/30 10:54:30 Done.
27 class ThumbnailDatabase; 27 class ThumbnailDatabase;
28 28
29 // Delegate used to broadcast notifications to the main thread. 29 // Delegate used to broadcast notifications to the main thread.
30 class BroadcastNotificationDelegate { 30 class ExpireHistoryBackendDelegate {
31 public: 31 public:
32 // Schedules a broadcast of the given notification on the application main
33 // thread.
34 virtual void BroadcastNotifications(int type,
35 scoped_ptr<HistoryDetails> details) = 0;
36
37 // Tells typed url sync code to handle URL modifications or deletions. 32 // Tells typed url sync code to handle URL modifications or deletions.
38 virtual void NotifySyncURLsModified(URLRows* rows) = 0; 33 virtual void NotifyURLsModified(const URLRows& rows) = 0;
39 virtual void NotifySyncURLsDeleted(bool all_history, 34 virtual void NotifyURLsDeleted(bool all_history,
40 bool expired, 35 bool expired,
41 URLRows* rows) = 0; 36 const URLRows& rows,
37 const std::set<GURL>& favicon_urls) = 0;
42 38
43 protected: 39 protected:
44 virtual ~BroadcastNotificationDelegate() {} 40 virtual ~ExpireHistoryBackendDelegate() {}
45 }; 41 };
46 42
47 // Encapsulates visit expiration criteria and type of visits to expire. 43 // Encapsulates visit expiration criteria and type of visits to expire.
48 class ExpiringVisitsReader { 44 class ExpiringVisitsReader {
49 public: 45 public:
50 virtual ~ExpiringVisitsReader() {} 46 virtual ~ExpiringVisitsReader() {}
51 // Populates |visits| from |db|, using provided |end_time| and |max_visits| 47 // Populates |visits| from |db|, using provided |end_time| and |max_visits|
52 // cap. 48 // cap.
53 virtual bool Read(base::Time end_time, HistoryDatabase* db, 49 virtual bool Read(base::Time end_time, HistoryDatabase* db,
54 VisitVector* visits, int max_visits) const = 0; 50 VisitVector* visits, int max_visits) const = 0;
55 }; 51 };
56 52
57 typedef std::vector<const ExpiringVisitsReader*> ExpiringVisitsReaders; 53 typedef std::vector<const ExpiringVisitsReader*> ExpiringVisitsReaders;
58 54
59 // Helper component to HistoryBackend that manages expiration and deleting of 55 // Helper component to HistoryBackend that manages expiration and deleting of
60 // history. 56 // history.
61 // 57 //
62 // It will automatically start periodically expiring old history once you call 58 // It will automatically start periodically expiring old history once you call
63 // StartExpiringOldStuff(). 59 // StartExpiringOldStuff().
64 class ExpireHistoryBackend { 60 class ExpireHistoryBackend {
65 public: 61 public:
66 // The delegate pointer must be non-NULL. We will NOT take ownership of it. 62 // The delegate pointer must be non-NULL. We will NOT take ownership of it.
67 // HistoryClient may be NULL. The HistoryClient is used when expiring URLS so 63 // HistoryClient may be NULL. The HistoryClient is used when expiring URLS so
68 // that we don't remove any URLs or favicons that are bookmarked (visits are 64 // that we don't remove any URLs or favicons that are bookmarked (visits are
69 // removed though). 65 // removed though).
70 ExpireHistoryBackend(BroadcastNotificationDelegate* delegate, 66 ExpireHistoryBackend(ExpireHistoryBackendDelegate* delegate,
71 HistoryClient* history_client); 67 HistoryClient* history_client);
72 ~ExpireHistoryBackend(); 68 ~ExpireHistoryBackend();
73 69
74 // Completes initialization by setting the databases that this class will use. 70 // Completes initialization by setting the databases that this class will use.
75 void SetDatabases(HistoryDatabase* main_db, 71 void SetDatabases(HistoryDatabase* main_db,
76 ThumbnailDatabase* thumb_db); 72 ThumbnailDatabase* thumb_db);
77 73
78 // Begins periodic expiration of history older than the given threshold. This 74 // Begins periodic expiration of history older than the given threshold. This
79 // will continue until the object is deleted. 75 // will continue until the object is deleted.
80 void StartExpiringOldStuff(base::TimeDelta expiration_threshold); 76 void StartExpiringOldStuff(base::TimeDelta expiration_threshold);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 236
241 // Returns the reader for all visits. This method is only used by the unit 237 // Returns the reader for all visits. This method is only used by the unit
242 // tests. 238 // tests.
243 const ExpiringVisitsReader* GetAllVisitsReader(); 239 const ExpiringVisitsReader* GetAllVisitsReader();
244 240
245 // Returns the reader for AUTO_SUBFRAME visits. This method is only used by 241 // Returns the reader for AUTO_SUBFRAME visits. This method is only used by
246 // the unit tests. 242 // the unit tests.
247 const ExpiringVisitsReader* GetAutoSubframeVisitsReader(); 243 const ExpiringVisitsReader* GetAutoSubframeVisitsReader();
248 244
249 // Non-owning pointer to the notification delegate (guaranteed non-NULL). 245 // Non-owning pointer to the notification delegate (guaranteed non-NULL).
250 BroadcastNotificationDelegate* delegate_; 246 ExpireHistoryBackendDelegate* delegate_;
251 247
252 // Non-owning pointers to the databases we deal with (MAY BE NULL). 248 // Non-owning pointers to the databases we deal with (MAY BE NULL).
253 HistoryDatabase* main_db_; // Main history database. 249 HistoryDatabase* main_db_; // Main history database.
254 ThumbnailDatabase* thumb_db_; // Thumbnails and favicons. 250 ThumbnailDatabase* thumb_db_; // Thumbnails and favicons.
255 251
256 // The threshold for "old" history where we will automatically delete it. 252 // The threshold for "old" history where we will automatically delete it.
257 base::TimeDelta expiration_threshold_; 253 base::TimeDelta expiration_threshold_;
258 254
259 // List of all distinct types of readers. This list is used to populate the 255 // List of all distinct types of readers. This list is used to populate the
260 // work queue. 256 // work queue.
(...skipping 19 matching lines...) Expand all
280 // Used to generate runnable methods to do timers on this class. They will be 276 // Used to generate runnable methods to do timers on this class. They will be
281 // automatically canceled when this class is deleted. 277 // automatically canceled when this class is deleted.
282 base::WeakPtrFactory<ExpireHistoryBackend> weak_factory_; 278 base::WeakPtrFactory<ExpireHistoryBackend> weak_factory_;
283 279
284 DISALLOW_COPY_AND_ASSIGN(ExpireHistoryBackend); 280 DISALLOW_COPY_AND_ASSIGN(ExpireHistoryBackend);
285 }; 281 };
286 282
287 } // namespace history 283 } // namespace history
288 284
289 #endif // CHROME_BROWSER_HISTORY_EXPIRE_HISTORY_BACKEND_H_ 285 #endif // CHROME_BROWSER_HISTORY_EXPIRE_HISTORY_BACKEND_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/history/expire_history_backend.cc » ('j') | chrome/browser/history/expire_history_backend.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698