| OLD | NEW |
| 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 #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 <functional> | 8 #include <functional> |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 // But since these uses are most valuable when you're actually on the site, | 41 // But since these uses are most valuable when you're actually on the site, |
| 42 // and because these can take up the bulk of your history, we get a lot of | 42 // and because these can take up the bulk of your history, we get a lot of |
| 43 // space savings by deleting them quickly. | 43 // space savings by deleting them quickly. |
| 44 const int kEarlyExpirationAdvanceDays = 3; | 44 const int kEarlyExpirationAdvanceDays = 3; |
| 45 | 45 |
| 46 // Reads all types of visits starting from beginning of time to the given end | 46 // Reads all types of visits starting from beginning of time to the given end |
| 47 // time. This is the most general reader. | 47 // time. This is the most general reader. |
| 48 class AllVisitsReader : public ExpiringVisitsReader { | 48 class AllVisitsReader : public ExpiringVisitsReader { |
| 49 public: | 49 public: |
| 50 virtual bool Read(Time end_time, HistoryDatabase* db, | 50 virtual bool Read(Time end_time, HistoryDatabase* db, |
| 51 VisitVector* visits, int max_visits) const { | 51 VisitVector* visits, int max_visits) const OVERRIDE { |
| 52 DCHECK(db) << "must have a database to operate upon"; | 52 DCHECK(db) << "must have a database to operate upon"; |
| 53 DCHECK(visits) << "visit vector has to exist in order to populate it"; | 53 DCHECK(visits) << "visit vector has to exist in order to populate it"; |
| 54 | 54 |
| 55 db->GetAllVisitsInRange(Time(), end_time, max_visits, visits); | 55 db->GetAllVisitsInRange(Time(), end_time, max_visits, visits); |
| 56 // When we got the maximum number of visits we asked for, we say there could | 56 // When we got the maximum number of visits we asked for, we say there could |
| 57 // be additional things to expire now. | 57 // be additional things to expire now. |
| 58 return static_cast<int>(visits->size()) == max_visits; | 58 return static_cast<int>(visits->size()) == max_visits; |
| 59 } | 59 } |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 // Reads only AUTO_SUBFRAME visits, within a computed range. The range is | 62 // Reads only AUTO_SUBFRAME visits, within a computed range. The range is |
| 63 // computed as follows: | 63 // computed as follows: |
| 64 // * |begin_time| is read from the meta table. This value is updated whenever | 64 // * |begin_time| is read from the meta table. This value is updated whenever |
| 65 // there are no more additional visits to expire by this reader. | 65 // there are no more additional visits to expire by this reader. |
| 66 // * |end_time| is advanced forward by a constant (kEarlyExpirationAdvanceDay), | 66 // * |end_time| is advanced forward by a constant (kEarlyExpirationAdvanceDay), |
| 67 // but not past the current time. | 67 // but not past the current time. |
| 68 class AutoSubframeVisitsReader : public ExpiringVisitsReader { | 68 class AutoSubframeVisitsReader : public ExpiringVisitsReader { |
| 69 public: | 69 public: |
| 70 virtual bool Read(Time end_time, HistoryDatabase* db, | 70 virtual bool Read(Time end_time, HistoryDatabase* db, |
| 71 VisitVector* visits, int max_visits) const { | 71 VisitVector* visits, int max_visits) const OVERRIDE { |
| 72 DCHECK(db) << "must have a database to operate upon"; | 72 DCHECK(db) << "must have a database to operate upon"; |
| 73 DCHECK(visits) << "visit vector has to exist in order to populate it"; | 73 DCHECK(visits) << "visit vector has to exist in order to populate it"; |
| 74 | 74 |
| 75 Time begin_time = db->GetEarlyExpirationThreshold(); | 75 Time begin_time = db->GetEarlyExpirationThreshold(); |
| 76 // Advance |end_time| to expire early. | 76 // Advance |end_time| to expire early. |
| 77 Time early_end_time = end_time + | 77 Time early_end_time = end_time + |
| 78 TimeDelta::FromDays(kEarlyExpirationAdvanceDays); | 78 TimeDelta::FromDays(kEarlyExpirationAdvanceDays); |
| 79 | 79 |
| 80 // We don't want to set the early expiration threshold to a time in the | 80 // We don't want to set the early expiration threshold to a time in the |
| 81 // future. | 81 // future. |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 // We use the bookmark service to determine if a URL is bookmarked. The | 746 // We use the bookmark service to determine if a URL is bookmarked. The |
| 747 // bookmark service is loaded on a separate thread and may not be done by the | 747 // bookmark service is loaded on a separate thread and may not be done by the |
| 748 // time we get here. We therefor block until the bookmarks have finished | 748 // time we get here. We therefor block until the bookmarks have finished |
| 749 // loading. | 749 // loading. |
| 750 if (bookmark_service_) | 750 if (bookmark_service_) |
| 751 bookmark_service_->BlockTillLoaded(); | 751 bookmark_service_->BlockTillLoaded(); |
| 752 return bookmark_service_; | 752 return bookmark_service_; |
| 753 } | 753 } |
| 754 | 754 |
| 755 } // namespace history | 755 } // namespace history |
| OLD | NEW |