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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/files/file_enumerator.h" |
14 #include "base/logging.h" | 15 #include "base/logging.h" |
15 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
16 #include "chrome/browser/bookmarks/bookmark_service.h" | 17 #include "chrome/browser/bookmarks/bookmark_service.h" |
17 #include "chrome/browser/history/archived_database.h" | 18 #include "chrome/browser/history/archived_database.h" |
18 #include "chrome/browser/history/history_database.h" | 19 #include "chrome/browser/history/history_database.h" |
19 #include "chrome/browser/history/history_notifications.h" | 20 #include "chrome/browser/history/history_notifications.h" |
20 #include "chrome/browser/history/text_database.h" | 21 #include "chrome/browser/history/text_database.h" |
21 #include "chrome/browser/history/text_database_manager.h" | 22 #include "chrome/browser/history/text_database_manager.h" |
22 #include "chrome/browser/history/thumbnail_database.h" | 23 #include "chrome/browser/history/thumbnail_database.h" |
23 #include "chrome/common/chrome_notification_types.h" | 24 #include "chrome/common/chrome_notification_types.h" |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 Time::Exploded exploded; | 748 Time::Exploded exploded; |
748 Time::Now().LocalExplode(&exploded); | 749 Time::Now().LocalExplode(&exploded); |
749 int cutoff_month = | 750 int cutoff_month = |
750 exploded.year * 12 + exploded.month - kStoreHistoryIndexesForMonths; | 751 exploded.year * 12 + exploded.month - kStoreHistoryIndexesForMonths; |
751 TextDatabase::DBIdent cutoff_id = | 752 TextDatabase::DBIdent cutoff_id = |
752 (cutoff_month / 12) * 100 + (cutoff_month % 12); | 753 (cutoff_month / 12) * 100 + (cutoff_month % 12); |
753 | 754 |
754 base::FilePath::StringType history_index_files_pattern = | 755 base::FilePath::StringType history_index_files_pattern = |
755 TextDatabase::file_base(); | 756 TextDatabase::file_base(); |
756 history_index_files_pattern.append(FILE_PATH_LITERAL("*")); | 757 history_index_files_pattern.append(FILE_PATH_LITERAL("*")); |
757 file_util::FileEnumerator file_enumerator( | 758 base::FileEnumerator file_enumerator( |
758 text_db_->GetDir(), false, file_util::FileEnumerator::FILES, | 759 text_db_->GetDir(), false, base::FileEnumerator::FILES, |
759 history_index_files_pattern); | 760 history_index_files_pattern); |
760 for (base::FilePath file = file_enumerator.Next(); !file.empty(); | 761 for (base::FilePath file = file_enumerator.Next(); !file.empty(); |
761 file = file_enumerator.Next()) { | 762 file = file_enumerator.Next()) { |
762 TextDatabase::DBIdent file_id = TextDatabase::FileNameToID(file); | 763 TextDatabase::DBIdent file_id = TextDatabase::FileNameToID(file); |
763 if (file_id < cutoff_id) | 764 if (file_id < cutoff_id) |
764 file_util::Delete(file, false); | 765 file_util::Delete(file, false); |
765 } | 766 } |
766 } | 767 } |
767 | 768 |
768 BookmarkService* ExpireHistoryBackend::GetBookmarkService() { | 769 BookmarkService* ExpireHistoryBackend::GetBookmarkService() { |
769 // We use the bookmark service to determine if a URL is bookmarked. The | 770 // 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 | 771 // 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 | 772 // time we get here. We therefor block until the bookmarks have finished |
772 // loading. | 773 // loading. |
773 if (bookmark_service_) | 774 if (bookmark_service_) |
774 bookmark_service_->BlockTillLoaded(); | 775 bookmark_service_->BlockTillLoaded(); |
775 return bookmark_service_; | 776 return bookmark_service_; |
776 } | 777 } |
777 | 778 |
778 } // namespace history | 779 } // namespace history |
OLD | NEW |