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