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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 base::TimeDelta::FromDays(kEarlyExpirationAdvanceDays); | 79 base::TimeDelta::FromDays(kEarlyExpirationAdvanceDays); |
80 | 80 |
81 // We don't want to set the early expiration threshold to a time in the | 81 // We don't want to set the early expiration threshold to a time in the |
82 // future. | 82 // future. |
83 base::Time now = base::Time::Now(); | 83 base::Time now = base::Time::Now(); |
84 if (early_end_time > now) | 84 if (early_end_time > now) |
85 early_end_time = now; | 85 early_end_time = now; |
86 | 86 |
87 db->GetVisitsInRangeForTransition(begin_time, early_end_time, | 87 db->GetVisitsInRangeForTransition(begin_time, early_end_time, |
88 max_visits, | 88 max_visits, |
89 content::PAGE_TRANSITION_AUTO_SUBFRAME, | 89 ui::PAGE_TRANSITION_AUTO_SUBFRAME, |
90 visits); | 90 visits); |
91 bool more = static_cast<int>(visits->size()) == max_visits; | 91 bool more = static_cast<int>(visits->size()) == max_visits; |
92 if (!more) | 92 if (!more) |
93 db->UpdateEarlyExpirationThreshold(early_end_time); | 93 db->UpdateEarlyExpirationThreshold(early_end_time); |
94 | 94 |
95 return more; | 95 return more; |
96 } | 96 } |
97 }; | 97 }; |
98 | 98 |
99 // The number of visits we will expire very time we check for old items. This | 99 // The number of visits we will expire very time we check for old items. This |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 DeleteEffects* effects) { | 392 DeleteEffects* effects) { |
393 // First find all unique URLs and the number of visits we're deleting for | 393 // First find all unique URLs and the number of visits we're deleting for |
394 // each one. | 394 // each one. |
395 std::map<URLID, ChangedURL> changed_urls; | 395 std::map<URLID, ChangedURL> changed_urls; |
396 for (size_t i = 0; i < visits.size(); i++) { | 396 for (size_t i = 0; i < visits.size(); i++) { |
397 ChangedURL& cur = changed_urls[visits[i].url_id]; | 397 ChangedURL& cur = changed_urls[visits[i].url_id]; |
398 // NOTE: This code must stay in sync with HistoryBackend::AddPageVisit(). | 398 // NOTE: This code must stay in sync with HistoryBackend::AddPageVisit(). |
399 // TODO(pkasting): http://b/1148304 We shouldn't be marking so many URLs as | 399 // TODO(pkasting): http://b/1148304 We shouldn't be marking so many URLs as |
400 // typed, which would help eliminate the need for this code (we still would | 400 // typed, which would help eliminate the need for this code (we still would |
401 // need to handle RELOAD transitions specially, though). | 401 // need to handle RELOAD transitions specially, though). |
402 content::PageTransition transition = | 402 ui::PageTransition transition = |
403 content::PageTransitionStripQualifier(visits[i].transition); | 403 ui::PageTransitionStripQualifier(visits[i].transition); |
404 if (transition != content::PAGE_TRANSITION_RELOAD) | 404 if (transition != ui::PAGE_TRANSITION_RELOAD) |
405 cur.visit_count++; | 405 cur.visit_count++; |
406 if ((transition == content::PAGE_TRANSITION_TYPED && | 406 if ((transition == ui::PAGE_TRANSITION_TYPED && |
407 !content::PageTransitionIsRedirect(visits[i].transition)) || | 407 !ui::PageTransitionIsRedirect(visits[i].transition)) || |
408 transition == content::PAGE_TRANSITION_KEYWORD_GENERATED) | 408 transition == ui::PAGE_TRANSITION_KEYWORD_GENERATED) |
409 cur.typed_count++; | 409 cur.typed_count++; |
410 } | 410 } |
411 | 411 |
412 // Check each unique URL with deleted visits. | 412 // Check each unique URL with deleted visits. |
413 HistoryClient* history_client = GetHistoryClient(); | 413 HistoryClient* history_client = GetHistoryClient(); |
414 for (std::map<URLID, ChangedURL>::const_iterator i = changed_urls.begin(); | 414 for (std::map<URLID, ChangedURL>::const_iterator i = changed_urls.begin(); |
415 i != changed_urls.end(); ++i) { | 415 i != changed_urls.end(); ++i) { |
416 // The unique URL rows should already be filled in. | 416 // The unique URL rows should already be filled in. |
417 URLRow& url_row = effects->affected_urls[i->first]; | 417 URLRow& url_row = effects->affected_urls[i->first]; |
418 if (!url_row.id()) | 418 if (!url_row.id()) |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 HistoryClient* ExpireHistoryBackend::GetHistoryClient() { | 516 HistoryClient* ExpireHistoryBackend::GetHistoryClient() { |
517 // We use the history client to determine if a URL is bookmarked. The data is | 517 // We use the history client to determine if a URL is bookmarked. The data is |
518 // loaded on a separate thread and may not be done by the time we get here. | 518 // loaded on a separate thread and may not be done by the time we get here. |
519 // We therefore block until the bookmarks have finished loading. | 519 // We therefore block until the bookmarks have finished loading. |
520 if (history_client_) | 520 if (history_client_) |
521 history_client_->BlockUntilBookmarksLoaded(); | 521 history_client_->BlockUntilBookmarksLoaded(); |
522 return history_client_; | 522 return history_client_; |
523 } | 523 } |
524 | 524 |
525 } // namespace history | 525 } // namespace history |
OLD | NEW |