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

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

Issue 7995: Move Time, TimeDelta and TimeTicks into namespace base. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 ~ExpireHistoryBackend(); 52 ~ExpireHistoryBackend();
53 53
54 // Completes initialization by setting the databases that this class will use. 54 // Completes initialization by setting the databases that this class will use.
55 void SetDatabases(HistoryDatabase* main_db, 55 void SetDatabases(HistoryDatabase* main_db,
56 ArchivedDatabase* archived_db, 56 ArchivedDatabase* archived_db,
57 ThumbnailDatabase* thumb_db, 57 ThumbnailDatabase* thumb_db,
58 TextDatabaseManager* text_db); 58 TextDatabaseManager* text_db);
59 59
60 // Begins periodic expiration of history older than the given threshold. This 60 // Begins periodic expiration of history older than the given threshold. This
61 // will continue until the object is deleted. 61 // will continue until the object is deleted.
62 void StartArchivingOldStuff(TimeDelta expiration_threshold); 62 void StartArchivingOldStuff(base::TimeDelta expiration_threshold);
63 63
64 // Deletes everything associated with a URL. 64 // Deletes everything associated with a URL.
65 void DeleteURL(const GURL& url); 65 void DeleteURL(const GURL& url);
66 66
67 // Removes all visits in the given time range, updating the URLs accordingly. 67 // Removes all visits in the given time range, updating the URLs accordingly.
68 void ExpireHistoryBetween(Time begin_time, Time end_time); 68 void ExpireHistoryBetween(base::Time begin_time, base::Time end_time);
69 69
70 // Archives all visits before and including the given time, updating the URLs 70 // Archives all visits before and including the given time, updating the URLs
71 // accordingly. This function is intended for migrating old databases 71 // accordingly. This function is intended for migrating old databases
72 // (which encompased all time) to the tiered structure and testing, and 72 // (which encompased all time) to the tiered structure and testing, and
73 // probably isn't useful for anything else. 73 // probably isn't useful for anything else.
74 void ArchiveHistoryBefore(Time end_time); 74 void ArchiveHistoryBefore(base::Time end_time);
75 75
76 // Returns the current time that we are archiving stuff to. This will return 76 // Returns the current time that we are archiving stuff to. This will return
77 // the threshold in absolute time rather than a delta, so the caller should 77 // the threshold in absolute time rather than a delta, so the caller should
78 // not save it. 78 // not save it.
79 Time GetCurrentArchiveTime() const { 79 base::Time GetCurrentArchiveTime() const {
80 return Time::Now() - expiration_threshold_; 80 return base::Time::Now() - expiration_threshold_;
81 } 81 }
82 82
83 private: 83 private:
84 //friend class ExpireHistoryTest_DeleteFaviconsIfPossible_Test; 84 //friend class ExpireHistoryTest_DeleteFaviconsIfPossible_Test;
85 FRIEND_TEST(ExpireHistoryTest, DeleteTextIndexForURL); 85 FRIEND_TEST(ExpireHistoryTest, DeleteTextIndexForURL);
86 FRIEND_TEST(ExpireHistoryTest, DeleteFaviconsIfPossible); 86 FRIEND_TEST(ExpireHistoryTest, DeleteFaviconsIfPossible);
87 FRIEND_TEST(ExpireHistoryTest, ArchiveSomeOldHistory); 87 FRIEND_TEST(ExpireHistoryTest, ArchiveSomeOldHistory);
88 friend class TestingProfile; 88 friend class TestingProfile;
89 89
90 struct DeleteDependencies { 90 struct DeleteDependencies {
91 // The time range affected. These can be is_null() to be unbounded in one 91 // The time range affected. These can be is_null() to be unbounded in one
92 // or both directions. 92 // or both directions.
93 Time begin_time, end_time; 93 base::Time begin_time, end_time;
94 94
95 // ----- Filled by DeleteVisitRelatedInfo or manually if a function doesn't 95 // ----- Filled by DeleteVisitRelatedInfo or manually if a function doesn't
96 // call that function. ----- 96 // call that function. -----
97 97
98 // The unique URL rows affected by this delete. 98 // The unique URL rows affected by this delete.
99 std::map<URLID, URLRow> affected_urls; 99 std::map<URLID, URLRow> affected_urls;
100 100
101 // ----- Filled by DeleteOneURL ----- 101 // ----- Filled by DeleteOneURL -----
102 102
103 // The URLs deleted during this operation. 103 // The URLs deleted during this operation.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 201
202 // Deletes the favicons listed in the set if unused. Fails silently (we don't 202 // Deletes the favicons listed in the set if unused. Fails silently (we don't
203 // care about favicons so much, so don't want to stop everything if it fails). 203 // care about favicons so much, so don't want to stop everything if it fails).
204 void DeleteFaviconsIfPossible(const std::set<FavIconID>& favicon_id); 204 void DeleteFaviconsIfPossible(const std::set<FavIconID>& favicon_id);
205 205
206 // Broadcast the URL deleted notification. 206 // Broadcast the URL deleted notification.
207 void BroadcastDeleteNotifications(DeleteDependencies* dependencies); 207 void BroadcastDeleteNotifications(DeleteDependencies* dependencies);
208 208
209 // Schedules a call to DoArchiveIteration at the given time in the 209 // Schedules a call to DoArchiveIteration at the given time in the
210 // future. 210 // future.
211 void ScheduleArchive(TimeDelta delay); 211 void ScheduleArchive(base::TimeDelta delay);
212 212
213 // Calls ArchiveSomeOldHistory to expire some amount of old history, and 213 // Calls ArchiveSomeOldHistory to expire some amount of old history, and
214 // schedules another call to happen in the future. 214 // schedules another call to happen in the future.
215 void DoArchiveIteration(); 215 void DoArchiveIteration();
216 216
217 // Tries to expire the oldest |max_visits| visits from history that are older 217 // Tries to expire the oldest |max_visits| visits from history that are older
218 // than |time_threshold|. The return value indicates if we think there might 218 // than |time_threshold|. The return value indicates if we think there might
219 // be more history to expire with the current time threshold (it does not 219 // be more history to expire with the current time threshold (it does not
220 // indicate success or failure). 220 // indicate success or failure).
221 bool ArchiveSomeOldHistory(Time time_threshold, int max_visits); 221 bool ArchiveSomeOldHistory(base::Time time_threshold, int max_visits);
222 222
223 // Tries to detect possible bad history or inconsistencies in the database 223 // Tries to detect possible bad history or inconsistencies in the database
224 // and deletes items. For example, URLs with no visits. 224 // and deletes items. For example, URLs with no visits.
225 void ParanoidExpireHistory(); 225 void ParanoidExpireHistory();
226 226
227 // Returns the BookmarkService, blocking until it is loaded. This may return 227 // Returns the BookmarkService, blocking until it is loaded. This may return
228 // NULL. 228 // NULL.
229 BookmarkService* GetBookmarkService(); 229 BookmarkService* GetBookmarkService();
230 230
231 // Non-owning pointer to the notification delegate (guaranteed non-NULL). 231 // Non-owning pointer to the notification delegate (guaranteed non-NULL).
232 BroadcastNotificationDelegate* delegate_; 232 BroadcastNotificationDelegate* delegate_;
233 233
234 // Non-owning pointers to the databases we deal with (MAY BE NULL). 234 // Non-owning pointers to the databases we deal with (MAY BE NULL).
235 HistoryDatabase* main_db_; // Main history database. 235 HistoryDatabase* main_db_; // Main history database.
236 ArchivedDatabase* archived_db_; // Old history. 236 ArchivedDatabase* archived_db_; // Old history.
237 ThumbnailDatabase* thumb_db_; // Thumbnails and favicons. 237 ThumbnailDatabase* thumb_db_; // Thumbnails and favicons.
238 TextDatabaseManager* text_db_; // Full text index. 238 TextDatabaseManager* text_db_; // Full text index.
239 239
240 // Used to generate runnable methods to do timers on this class. They will be 240 // Used to generate runnable methods to do timers on this class. They will be
241 // automatically canceled when this class is deleted. 241 // automatically canceled when this class is deleted.
242 ScopedRunnableMethodFactory<ExpireHistoryBackend> factory_; 242 ScopedRunnableMethodFactory<ExpireHistoryBackend> factory_;
243 243
244 // The threshold for "old" history where we will automatically expire it to 244 // The threshold for "old" history where we will automatically expire it to
245 // the archived database. 245 // the archived database.
246 TimeDelta expiration_threshold_; 246 base::TimeDelta expiration_threshold_;
247 247
248 // The BookmarkService; may be null. This is owned by the Profile. 248 // The BookmarkService; may be null. This is owned by the Profile.
249 // 249 //
250 // Use GetBookmarkService to access this, which makes sure the service is 250 // Use GetBookmarkService to access this, which makes sure the service is
251 // loaded. 251 // loaded.
252 BookmarkService* bookmark_service_; 252 BookmarkService* bookmark_service_;
253 253
254 DISALLOW_EVIL_CONSTRUCTORS(ExpireHistoryBackend); 254 DISALLOW_EVIL_CONSTRUCTORS(ExpireHistoryBackend);
255 }; 255 };
256 256
257 } // namespace history 257 } // namespace history
258 258
259 #endif // CHROME_BROWSER_HISTORY_EXPIRE_HISTORY_BACKEND_H__ 259 #endif // CHROME_BROWSER_HISTORY_EXPIRE_HISTORY_BACKEND_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698