Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: chrome/browser/history/expire_history_backend.cc

Issue 16392011: Move FileEnumerator to its own file, do some refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix incorrect includes Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/file_select_helper.cc ('k') | chrome/browser/history/text_database_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « chrome/browser/file_select_helper.cc ('k') | chrome/browser/history/text_database_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698