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