OLD | NEW |
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 TimeDelta::FromDays(kEarlyExpirationAdvanceDays); | 66 TimeDelta::FromDays(kEarlyExpirationAdvanceDays); |
67 | 67 |
68 // We don't want to set the early expiration threshold to a time in the | 68 // We don't want to set the early expiration threshold to a time in the |
69 // future. | 69 // future. |
70 Time now = Time::Now(); | 70 Time now = Time::Now(); |
71 if (early_end_time > now) | 71 if (early_end_time > now) |
72 early_end_time = now; | 72 early_end_time = now; |
73 | 73 |
74 db->GetVisitsInRangeForTransition(begin_time, early_end_time, | 74 db->GetVisitsInRangeForTransition(begin_time, early_end_time, |
75 max_visits, | 75 max_visits, |
76 PageTransition::AUTO_SUBFRAME, | 76 content::PAGE_TRANSITION_AUTO_SUBFRAME, |
77 visits); | 77 visits); |
78 bool more = static_cast<int>(visits->size()) == max_visits; | 78 bool more = static_cast<int>(visits->size()) == max_visits; |
79 if (!more) | 79 if (!more) |
80 db->UpdateEarlyExpirationThreshold(early_end_time); | 80 db->UpdateEarlyExpirationThreshold(early_end_time); |
81 | 81 |
82 return more; | 82 return more; |
83 } | 83 } |
84 }; | 84 }; |
85 | 85 |
86 // Returns true if this visit is worth archiving. Otherwise, this visit is not | 86 // Returns true if this visit is worth archiving. Otherwise, this visit is not |
87 // worth saving (for example, subframe navigations and redirects) and we can | 87 // worth saving (for example, subframe navigations and redirects) and we can |
88 // just delete it when it gets old. | 88 // just delete it when it gets old. |
89 bool ShouldArchiveVisit(const VisitRow& visit) { | 89 bool ShouldArchiveVisit(const VisitRow& visit) { |
90 int no_qualifier = PageTransition::StripQualifier(visit.transition); | 90 int no_qualifier = content::PageTransitionStripQualifier(visit.transition); |
91 | 91 |
92 // These types of transitions are always "important" and the user will want | 92 // These types of transitions are always "important" and the user will want |
93 // to see them. | 93 // to see them. |
94 if (no_qualifier == PageTransition::TYPED || | 94 if (no_qualifier == content::PAGE_TRANSITION_TYPED || |
95 no_qualifier == PageTransition::AUTO_BOOKMARK || | 95 no_qualifier == content::PAGE_TRANSITION_AUTO_BOOKMARK || |
96 no_qualifier == PageTransition::START_PAGE) | 96 no_qualifier == content::PAGE_TRANSITION_START_PAGE) |
97 return true; | 97 return true; |
98 | 98 |
99 // Only archive these "less important" transitions when they were the final | 99 // Only archive these "less important" transitions when they were the final |
100 // navigation and not part of a redirect chain. | 100 // navigation and not part of a redirect chain. |
101 if ((no_qualifier == PageTransition::LINK || | 101 if ((no_qualifier == content::PAGE_TRANSITION_LINK || |
102 no_qualifier == PageTransition::FORM_SUBMIT || | 102 no_qualifier == content::PAGE_TRANSITION_FORM_SUBMIT || |
103 no_qualifier == PageTransition::KEYWORD || | 103 no_qualifier == content::PAGE_TRANSITION_KEYWORD || |
104 no_qualifier == PageTransition::GENERATED) && | 104 no_qualifier == content::PAGE_TRANSITION_GENERATED) && |
105 visit.transition & PageTransition::CHAIN_END) | 105 visit.transition & content::PAGE_TRANSITION_CHAIN_END) |
106 return true; | 106 return true; |
107 | 107 |
108 // The transition types we ignore are AUTO_SUBFRAME and MANUAL_SUBFRAME. | 108 // The transition types we ignore are AUTO_SUBFRAME and MANUAL_SUBFRAME. |
109 return false; | 109 return false; |
110 } | 110 } |
111 | 111 |
112 // The number of visits we will expire very time we check for old items. This | 112 // 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. | 113 // Prevents us from doing too much work any given time. |
114 const int kNumExpirePerIteration = 10; | 114 const int kNumExpirePerIteration = 10; |
115 | 115 |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 DeleteDependencies* dependencies) { | 453 DeleteDependencies* dependencies) { |
454 // First find all unique URLs and the number of visits we're deleting for | 454 // First find all unique URLs and the number of visits we're deleting for |
455 // each one. | 455 // each one. |
456 std::map<URLID, ChangedURL> changed_urls; | 456 std::map<URLID, ChangedURL> changed_urls; |
457 for (size_t i = 0; i < visits.size(); i++) { | 457 for (size_t i = 0; i < visits.size(); i++) { |
458 ChangedURL& cur = changed_urls[visits[i].url_id]; | 458 ChangedURL& cur = changed_urls[visits[i].url_id]; |
459 // NOTE: This code must stay in sync with HistoryBackend::AddPageVisit(). | 459 // NOTE: This code must stay in sync with HistoryBackend::AddPageVisit(). |
460 // TODO(pkasting): http://b/1148304 We shouldn't be marking so many URLs as | 460 // TODO(pkasting): http://b/1148304 We shouldn't be marking so many URLs as |
461 // typed, which would help eliminate the need for this code (we still would | 461 // typed, which would help eliminate the need for this code (we still would |
462 // need to handle RELOAD transitions specially, though). | 462 // need to handle RELOAD transitions specially, though). |
463 PageTransition::Type transition = | 463 content::PageTransition transition = |
464 PageTransition::StripQualifier(visits[i].transition); | 464 content::PageTransitionStripQualifier(visits[i].transition); |
465 if (transition != PageTransition::RELOAD) | 465 if (transition != content::PAGE_TRANSITION_RELOAD) |
466 cur.visit_count++; | 466 cur.visit_count++; |
467 if ((transition == PageTransition::TYPED && | 467 if ((transition == content::PAGE_TRANSITION_TYPED && |
468 !PageTransition::IsRedirect(visits[i].transition)) || | 468 !content::PageTransitionIsRedirect(visits[i].transition)) || |
469 transition == PageTransition::KEYWORD_GENERATED) | 469 transition == content::PAGE_TRANSITION_KEYWORD_GENERATED) |
470 cur.typed_count++; | 470 cur.typed_count++; |
471 } | 471 } |
472 | 472 |
473 // Check each unique URL with deleted visits. | 473 // Check each unique URL with deleted visits. |
474 BookmarkService* bookmark_service = GetBookmarkService(); | 474 BookmarkService* bookmark_service = GetBookmarkService(); |
475 for (std::map<URLID, ChangedURL>::const_iterator i = changed_urls.begin(); | 475 for (std::map<URLID, ChangedURL>::const_iterator i = changed_urls.begin(); |
476 i != changed_urls.end(); ++i) { | 476 i != changed_urls.end(); ++i) { |
477 // The unique URL rows should already be filled into the dependencies. | 477 // The unique URL rows should already be filled into the dependencies. |
478 URLRow& url_row = dependencies->affected_urls[i->first]; | 478 URLRow& url_row = dependencies->affected_urls[i->first]; |
479 if (!url_row.id()) | 479 if (!url_row.id()) |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 // We use the bookmark service to determine if a URL is bookmarked. The | 701 // We use the bookmark service to determine if a URL is bookmarked. The |
702 // bookmark service is loaded on a separate thread and may not be done by the | 702 // bookmark service is loaded on a separate thread and may not be done by the |
703 // time we get here. We therefor block until the bookmarks have finished | 703 // time we get here. We therefor block until the bookmarks have finished |
704 // loading. | 704 // loading. |
705 if (bookmark_service_) | 705 if (bookmark_service_) |
706 bookmark_service_->BlockTillLoaded(); | 706 bookmark_service_->BlockTillLoaded(); |
707 return bookmark_service_; | 707 return bookmark_service_; |
708 } | 708 } |
709 | 709 |
710 } // namespace history | 710 } // namespace history |
OLD | NEW |