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

Unified Diff: components/offline_pages/archive_manager.cc

Issue 1988973002: [Offline pages] Moving disk size related calls to Archive Manager, reorganizing UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@archive-manager
Patch Set: Addressing feedback 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
« no previous file with comments | « components/offline_pages/archive_manager.h ('k') | components/offline_pages/archive_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/offline_pages/archive_manager.cc
diff --git a/components/offline_pages/archive_manager.cc b/components/offline_pages/archive_manager.cc
index 6c9bbbc4db3d68df52a46228440e517813ecf89e..9dfeabbe0b0c82460a888db52c37535e5edea693 100644
--- a/components/offline_pages/archive_manager.cc
+++ b/components/offline_pages/archive_manager.cc
@@ -10,6 +10,7 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/sequenced_task_runner.h"
+#include "base/sys_info.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/offline_pages/archive_manager.h"
@@ -17,6 +18,9 @@ namespace offline_pages {
namespace {
+using StorageStatsCallback =
+ base::Callback<void(const ArchiveManager::StorageStats& storage_stats)>;
+
void EnsureArchivesDirCreatedImpl(const base::FilePath& archives_dir) {
CHECK(base::CreateDirectory(archives_dir));
}
@@ -53,6 +57,16 @@ void GetAllArchivesImpl(
task_runner->PostTask(FROM_HERE, base::Bind(callback, archive_paths));
}
+void GetStorageStatsImpl(const base::FilePath& archive_dir,
+ scoped_refptr<base::SequencedTaskRunner> task_runner,
+ const StorageStatsCallback& callback) {
+ ArchiveManager::StorageStats storage_stats;
+ storage_stats.free_disk_space =
+ base::SysInfo::AmountOfFreeDiskSpace(archive_dir);
+ storage_stats.total_archives_size = base::ComputeDirectorySize(archive_dir);
+ task_runner->PostTask(FROM_HERE, base::Bind(callback, storage_stats));
+}
+
} // namespace
ArchiveManager::ArchiveManager(
@@ -97,4 +111,11 @@ void ArchiveManager::GetAllArchives(
base::ThreadTaskRunnerHandle::Get(), callback));
}
+void ArchiveManager::GetStorageStats(
+ const StorageStatsCallback& callback) const {
+ task_runner_->PostTask(
+ FROM_HERE, base::Bind(GetStorageStatsImpl, archives_dir_,
+ base::ThreadTaskRunnerHandle::Get(), callback));
+}
+
} // namespace offline_pages
« no previous file with comments | « components/offline_pages/archive_manager.h ('k') | components/offline_pages/archive_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698