Chromium Code Reviews| Index: components/offline_pages/archive_manager.cc |
| diff --git a/components/offline_pages/archive_manager.cc b/components/offline_pages/archive_manager.cc |
| index 019dcc50a7d7658157a0dd4e82809f08c1355f54..ffc7b68c21b07f59713ab20cab20fea7a4945a89 100644 |
| --- a/components/offline_pages/archive_manager.cc |
| +++ b/components/offline_pages/archive_manager.cc |
| @@ -4,6 +4,7 @@ |
| #include "base/bind.h" |
| #include "base/callback.h" |
| +#include "base/files/file_enumerator.h" |
| #include "base/files/file_util.h" |
| #include "base/location.h" |
| #include "base/logging.h" |
| @@ -35,6 +36,26 @@ void CompleteBooleanCallback(const base::Callback<void(bool)>& callback, |
| bool* exists) { |
| callback.Run(*exists); |
| } |
| + |
| +void GetAllArchivesImpl(const base::FilePath& archive_dir, |
| + std::set<base::FilePath>* archive_paths) { |
| + DCHECK(archive_paths); |
| + archive_paths->clear(); |
| + base::FileEnumerator file_enumerator(archive_dir, false, |
| + base::FileEnumerator::FILES); |
| + for (base::FilePath archive_path = file_enumerator.Next(); |
| + !archive_path.empty(); |
| + archive_path = file_enumerator.Next()) { |
| + archive_paths->insert(archive_path); |
| + } |
| +} |
| + |
| +void GetAllArchivesImplDone( |
| + const base::Callback<void(const std::set<base::FilePath>&)>& callback, |
| + std::set<base::FilePath>* archive_paths) { |
| + callback.Run(*archive_paths); |
| +} |
| + |
| } // namespace |
| ArchiveManager::ArchiveManager( |
| @@ -73,4 +94,13 @@ void ArchiveManager::DeleteMultipleArchives( |
| base::Bind(CompleteBooleanCallback, callback, base::Owned(result))); |
| } |
| +void ArchiveManager::GetAllArchives( |
| + const base::Callback<void(const std::set<base::FilePath>&)>& callback) |
| + const { |
| + std::set<base::FilePath>* archive_paths = new std::set<base::FilePath>(); |
| + task_runner_->PostTaskAndReply( |
| + FROM_HERE, base::Bind(GetAllArchivesImpl, archives_dir_, archive_paths), |
| + base::Bind(GetAllArchivesImplDone, callback, base::Owned(archive_paths))); |
|
jianli
2016/05/17 21:48:13
I think you don't need GetAllArchivesImplDone.
fgorski
2016/05/17 22:50:29
Changed per offline discussion.
|
| +} |
| + |
| } // namespace offline_pages |