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 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 TimeDelta delay; | 628 TimeDelta delay; |
629 if (work_queue_.empty()) { | 629 if (work_queue_.empty()) { |
630 // If work queue is empty, reset the work queue to contain all tasks and | 630 // If work queue is empty, reset the work queue to contain all tasks and |
631 // schedule next iteration after a longer delay. | 631 // schedule next iteration after a longer delay. |
632 InitWorkQueue(); | 632 InitWorkQueue(); |
633 delay = TimeDelta::FromMinutes(kExpirationEmptyDelayMin); | 633 delay = TimeDelta::FromMinutes(kExpirationEmptyDelayMin); |
634 } else { | 634 } else { |
635 delay = TimeDelta::FromSeconds(kExpirationDelaySec); | 635 delay = TimeDelta::FromSeconds(kExpirationDelaySec); |
636 } | 636 } |
637 | 637 |
638 MessageLoop::current()->PostDelayedTask( | 638 base::MessageLoop::current()->PostDelayedTask( |
639 FROM_HERE, | 639 FROM_HERE, |
640 base::Bind(&ExpireHistoryBackend::DoArchiveIteration, | 640 base::Bind(&ExpireHistoryBackend::DoArchiveIteration, |
641 weak_factory_.GetWeakPtr()), | 641 weak_factory_.GetWeakPtr()), |
642 delay); | 642 delay); |
643 } | 643 } |
644 | 644 |
645 void ExpireHistoryBackend::DoArchiveIteration() { | 645 void ExpireHistoryBackend::DoArchiveIteration() { |
646 DCHECK(!work_queue_.empty()) << "queue has to be non-empty"; | 646 DCHECK(!work_queue_.empty()) << "queue has to be non-empty"; |
647 | 647 |
648 const ExpiringVisitsReader* reader = work_queue_.front(); | 648 const ExpiringVisitsReader* reader = work_queue_.front(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 } | 724 } |
725 | 725 |
726 void ExpireHistoryBackend::ScheduleExpireHistoryIndexFiles() { | 726 void ExpireHistoryBackend::ScheduleExpireHistoryIndexFiles() { |
727 if (!text_db_) { | 727 if (!text_db_) { |
728 // Can't expire old history index files because we | 728 // Can't expire old history index files because we |
729 // don't know where they're located. | 729 // don't know where they're located. |
730 return; | 730 return; |
731 } | 731 } |
732 | 732 |
733 TimeDelta delay = TimeDelta::FromMinutes(kIndexExpirationDelayMin); | 733 TimeDelta delay = TimeDelta::FromMinutes(kIndexExpirationDelayMin); |
734 MessageLoop::current()->PostDelayedTask( | 734 base::MessageLoop::current()->PostDelayedTask( |
735 FROM_HERE, | 735 FROM_HERE, |
736 base::Bind(&ExpireHistoryBackend::DoExpireHistoryIndexFiles, | 736 base::Bind(&ExpireHistoryBackend::DoExpireHistoryIndexFiles, |
737 weak_factory_.GetWeakPtr()), | 737 weak_factory_.GetWeakPtr()), |
738 delay); | 738 delay); |
739 } | 739 } |
740 | 740 |
741 void ExpireHistoryBackend::DoExpireHistoryIndexFiles() { | 741 void ExpireHistoryBackend::DoExpireHistoryIndexFiles() { |
742 if (!text_db_) { | 742 if (!text_db_) { |
743 // The text database may have been closed since the task was scheduled. | 743 // The text database may have been closed since the task was scheduled. |
744 return; | 744 return; |
(...skipping 24 matching lines...) Expand all Loading... |
769 // We use the bookmark service to determine if a URL is bookmarked. The | 769 // We use the bookmark service to determine if a URL is bookmarked. The |
770 // bookmark service is loaded on a separate thread and may not be done by the | 770 // bookmark service is loaded on a separate thread and may not be done by the |
771 // time we get here. We therefor block until the bookmarks have finished | 771 // time we get here. We therefor block until the bookmarks have finished |
772 // loading. | 772 // loading. |
773 if (bookmark_service_) | 773 if (bookmark_service_) |
774 bookmark_service_->BlockTillLoaded(); | 774 bookmark_service_->BlockTillLoaded(); |
775 return bookmark_service_; | 775 return bookmark_service_; |
776 } | 776 } |
777 | 777 |
778 } // namespace history | 778 } // namespace history |
OLD | NEW |