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 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 InitWorkQueue(); | 585 InitWorkQueue(); |
586 delay = TimeDelta::FromMinutes(kExpirationEmptyDelayMin); | 586 delay = TimeDelta::FromMinutes(kExpirationEmptyDelayMin); |
587 } else { | 587 } else { |
588 delay = TimeDelta::FromSeconds(kExpirationDelaySec); | 588 delay = TimeDelta::FromSeconds(kExpirationDelaySec); |
589 } | 589 } |
590 | 590 |
591 MessageLoop::current()->PostDelayedTask( | 591 MessageLoop::current()->PostDelayedTask( |
592 FROM_HERE, | 592 FROM_HERE, |
593 base::Bind(&ExpireHistoryBackend::DoArchiveIteration, | 593 base::Bind(&ExpireHistoryBackend::DoArchiveIteration, |
594 weak_factory_.GetWeakPtr()), | 594 weak_factory_.GetWeakPtr()), |
595 delay.InMilliseconds()); | 595 delay); |
596 } | 596 } |
597 | 597 |
598 void ExpireHistoryBackend::DoArchiveIteration() { | 598 void ExpireHistoryBackend::DoArchiveIteration() { |
599 DCHECK(!work_queue_.empty()) << "queue has to be non-empty"; | 599 DCHECK(!work_queue_.empty()) << "queue has to be non-empty"; |
600 | 600 |
601 const ExpiringVisitsReader* reader = work_queue_.front(); | 601 const ExpiringVisitsReader* reader = work_queue_.front(); |
602 bool more_to_expire = ArchiveSomeOldHistory(GetCurrentArchiveTime(), reader, | 602 bool more_to_expire = ArchiveSomeOldHistory(GetCurrentArchiveTime(), reader, |
603 kNumExpirePerIteration); | 603 kNumExpirePerIteration); |
604 | 604 |
605 work_queue_.pop(); | 605 work_queue_.pop(); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 // Can't expire old history index files because we | 680 // Can't expire old history index files because we |
681 // don't know where they're located. | 681 // don't know where they're located. |
682 return; | 682 return; |
683 } | 683 } |
684 | 684 |
685 TimeDelta delay = TimeDelta::FromMinutes(kIndexExpirationDelayMin); | 685 TimeDelta delay = TimeDelta::FromMinutes(kIndexExpirationDelayMin); |
686 MessageLoop::current()->PostDelayedTask( | 686 MessageLoop::current()->PostDelayedTask( |
687 FROM_HERE, | 687 FROM_HERE, |
688 base::Bind(&ExpireHistoryBackend::DoExpireHistoryIndexFiles, | 688 base::Bind(&ExpireHistoryBackend::DoExpireHistoryIndexFiles, |
689 weak_factory_.GetWeakPtr()), | 689 weak_factory_.GetWeakPtr()), |
690 delay.InMilliseconds()); | 690 delay); |
691 } | 691 } |
692 | 692 |
693 void ExpireHistoryBackend::DoExpireHistoryIndexFiles() { | 693 void ExpireHistoryBackend::DoExpireHistoryIndexFiles() { |
694 Time::Exploded exploded; | 694 Time::Exploded exploded; |
695 Time::Now().LocalExplode(&exploded); | 695 Time::Now().LocalExplode(&exploded); |
696 int cutoff_month = | 696 int cutoff_month = |
697 exploded.year * 12 + exploded.month - kStoreHistoryIndexesForMonths; | 697 exploded.year * 12 + exploded.month - kStoreHistoryIndexesForMonths; |
698 TextDatabase::DBIdent cutoff_id = | 698 TextDatabase::DBIdent cutoff_id = |
699 (cutoff_month / 12) * 100 + (cutoff_month % 12); | 699 (cutoff_month / 12) * 100 + (cutoff_month % 12); |
700 | 700 |
(...skipping 14 matching lines...) Expand all Loading... |
715 // We use the bookmark service to determine if a URL is bookmarked. The | 715 // We use the bookmark service to determine if a URL is bookmarked. The |
716 // bookmark service is loaded on a separate thread and may not be done by the | 716 // bookmark service is loaded on a separate thread and may not be done by the |
717 // time we get here. We therefor block until the bookmarks have finished | 717 // time we get here. We therefor block until the bookmarks have finished |
718 // loading. | 718 // loading. |
719 if (bookmark_service_) | 719 if (bookmark_service_) |
720 bookmark_service_->BlockTillLoaded(); | 720 bookmark_service_->BlockTillLoaded(); |
721 return bookmark_service_; | 721 return bookmark_service_; |
722 } | 722 } |
723 | 723 |
724 } // namespace history | 724 } // namespace history |
OLD | NEW |