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

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

Issue 8343077: Make history expiration more aggressive. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/browser/history/expire_history_backend.h" 5 #include "chrome/browser/history/expire_history_backend.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 11 matching lines...) Expand all
22 22
23 using base::Time; 23 using base::Time;
24 using base::TimeDelta; 24 using base::TimeDelta;
25 25
26 namespace history { 26 namespace history {
27 27
28 namespace { 28 namespace {
29 29
30 // The number of days by which the expiration threshold is advanced for items 30 // The number of days by which the expiration threshold is advanced for items
31 // that we want to expire early, such as those of AUTO_SUBFRAME transition type. 31 // that we want to expire early, such as those of AUTO_SUBFRAME transition type.
32 const int kEarlyExpirationAdvanceDays = 30; 32 //
33 // Early expiration stuff is kept around only for edge cases, as subframes
34 // don't appear in history and the vast majority of them are ads anyway. The
35 // main use case for these is if you're on a site with links to different
36 // frames, you'll be able to see those links as visited, and we'll also be
37 // able to get redirect information for those URLs.
38 //
39 // But since these uses are most valuable when you're actually on the site,
40 // and because these can take up the bulk of your history, we get a lot of
41 // space savings by deleting them quickly.
42 const int kEarlyExpirationAdvanceDays = 3;
33 43
34 // Reads all types of visits starting from beginning of time to the given end 44 // Reads all types of visits starting from beginning of time to the given end
35 // time. This is the most general reader. 45 // time. This is the most general reader.
36 class AllVisitsReader : public ExpiringVisitsReader { 46 class AllVisitsReader : public ExpiringVisitsReader {
37 public: 47 public:
38 virtual bool Read(Time end_time, HistoryDatabase* db, 48 virtual bool Read(Time end_time, HistoryDatabase* db,
39 VisitVector* visits, int max_visits) const { 49 VisitVector* visits, int max_visits) const {
40 DCHECK(db) << "must have a database to operate upon"; 50 DCHECK(db) << "must have a database to operate upon";
41 DCHECK(visits) << "visit vector has to exist in order to populate it"; 51 DCHECK(visits) << "visit vector has to exist in order to populate it";
42 52
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 no_qualifier == content::PAGE_TRANSITION_GENERATED) && 114 no_qualifier == content::PAGE_TRANSITION_GENERATED) &&
105 visit.transition & content::PAGE_TRANSITION_CHAIN_END) 115 visit.transition & content::PAGE_TRANSITION_CHAIN_END)
106 return true; 116 return true;
107 117
108 // The transition types we ignore are AUTO_SUBFRAME and MANUAL_SUBFRAME. 118 // The transition types we ignore are AUTO_SUBFRAME and MANUAL_SUBFRAME.
109 return false; 119 return false;
110 } 120 }
111 121
112 // The number of visits we will expire very time we check for old items. This 122 // The number of visits we will expire very time we check for old items. This
113 // Prevents us from doing too much work any given time. 123 // Prevents us from doing too much work any given time.
114 const int kNumExpirePerIteration = 10; 124 const int kNumExpirePerIteration = 32;
115 125
116 // The number of seconds between checking for items that should be expired when 126 // The number of seconds between checking for items that should be expired when
117 // we think there might be more items to expire. This timeout is used when the 127 // we think there might be more items to expire. This timeout is used when the
118 // last expiration found at least kNumExpirePerIteration and we want to check 128 // last expiration found at least kNumExpirePerIteration and we want to check
119 // again "soon." 129 // again "soon."
120 const int kExpirationDelaySec = 30; 130 const int kExpirationDelaySec = 30;
121 131
122 // The number of minutes between checking, as with kExpirationDelaySec, but 132 // The number of minutes between checking, as with kExpirationDelaySec, but
123 // when we didn't find enough things to expire last time. If there was no 133 // when we didn't find enough things to expire last time. If there was no
124 // history to expire last iteration, it's likely there is nothing next 134 // history to expire last iteration, it's likely there is nothing next
125 // iteration, so we want to wait longer before checking to avoid wasting CPU. 135 // iteration, so we want to wait longer before checking to avoid wasting CPU.
126 const int kExpirationEmptyDelayMin = 5; 136 const int kExpirationEmptyDelayMin = 5;
127 137
128 // The number of minutes that we wait for before scheduling a task to 138 // The number of minutes that we wait for before scheduling a task to
129 // delete old history index files. 139 // delete old history index files.
130 const int kIndexExpirationDelayMin = 2; 140 const int kIndexExpirationDelayMin = 2;
131 141
132 // The number of the most recent months for which we do not want to delete 142 // The number of the most recent months for which we do not want to delete
133 // the history index files. 143 // the history index files.
134 const int kStoreHistoryIndexesForMonths = 12; 144 const int kStoreHistoryIndexesForMonths = 3;
135 145
136 } // namespace 146 } // namespace
137 147
138 struct ExpireHistoryBackend::DeleteDependencies { 148 struct ExpireHistoryBackend::DeleteDependencies {
139 // The time range affected. These can be is_null() to be unbounded in one 149 // The time range affected. These can be is_null() to be unbounded in one
140 // or both directions. 150 // or both directions.
141 base::Time begin_time, end_time; 151 base::Time begin_time, end_time;
142 152
143 // ----- Filled by DeleteVisitRelatedInfo or manually if a function doesn't 153 // ----- Filled by DeleteVisitRelatedInfo or manually if a function doesn't
144 // call that function. ----- 154 // call that function. -----
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 // We use the bookmark service to determine if a URL is bookmarked. The 707 // We use the bookmark service to determine if a URL is bookmarked. The
698 // bookmark service is loaded on a separate thread and may not be done by the 708 // bookmark service is loaded on a separate thread and may not be done by the
699 // time we get here. We therefor block until the bookmarks have finished 709 // time we get here. We therefor block until the bookmarks have finished
700 // loading. 710 // loading.
701 if (bookmark_service_) 711 if (bookmark_service_)
702 bookmark_service_->BlockTillLoaded(); 712 bookmark_service_->BlockTillLoaded();
703 return bookmark_service_; 713 return bookmark_service_;
704 } 714 }
705 715
706 } // namespace history 716 } // namespace history
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698