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

Unified Diff: components/offline_pages/archive_manager.cc

Issue 1981093002: [Offline pages] Hooking up Archive Manager to Offline Page Model (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@archive-manager
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698