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

Unified Diff: storage/browser/quota/quota_manager.cc

Issue 2052663003: Move implementation of QuotaManager.getVolumeInfo to base::SysInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. Created 4 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 side-by-side diff with in-line comments
Download patch
Index: storage/browser/quota/quota_manager.cc
diff --git a/storage/browser/quota/quota_manager.cc b/storage/browser/quota/quota_manager.cc
index ad23d41ec835b534f3dccd2a9d79f377282f810c..6494f3b4066a3503cd44f0402e25266eaaf894bc 100644
--- a/storage/browser/quota/quota_manager.cc
+++ b/storage/browser/quota/quota_manager.cc
@@ -36,18 +36,6 @@
#include "storage/browser/quota/usage_tracker.h"
#include "storage/common/quota/quota_types.h"
-// Platform specific includes for GetVolumeInfo().
-#if defined(OS_WIN)
-#include <windows.h>
-#elif defined(OS_POSIX)
-#if defined(OS_ANDROID)
-#include <sys/vfs.h>
-#define statvfs statfs // Android uses a statvfs-like statfs struct and call.
-#else
-#include <sys/statvfs.h>
-#endif
-#endif
-
#define UMA_HISTOGRAM_MBYTES(name, sample) \
UMA_HISTOGRAM_CUSTOM_COUNTS( \
(name), static_cast<int>((sample) / kMBytes), \
@@ -890,7 +878,7 @@ QuotaManager::QuotaManager(
temporary_quota_initialized_(false),
temporary_quota_override_(-1),
special_storage_policy_(special_storage_policy),
- get_volume_info_fn_(&QuotaManager::GetVolumeInfo),
+ get_volume_info_fn_(&base::SysInfo::GetDiskSpaceInfo),
storage_monitor_(new StorageMonitor(this)),
weak_factory_(this) {}
@@ -1666,8 +1654,8 @@ void QuotaManager::GetUsageAndQuotaForEviction(
void QuotaManager::AsyncGetVolumeInfo(
const VolumeInfoCallback& callback) {
DCHECK(io_thread_->BelongsToCurrentThread());
- uint64_t* available_space = new uint64_t(0);
- uint64_t* total_space = new uint64_t(0);
+ int64_t* available_space = new int64_t(0);
+ int64_t* total_space = new int64_t(0);
PostTaskAndReplyWithResult(
db_thread_.get(),
FROM_HERE,
@@ -1684,7 +1672,7 @@ void QuotaManager::AsyncGetVolumeInfo(
void QuotaManager::DidGetVolumeInfo(
const VolumeInfoCallback& callback,
- uint64_t* available_space, uint64_t* total_space, bool success) {
+ int64_t* available_space, int64_t* total_space, bool success) {
DCHECK(io_thread_->BelongsToCurrentThread());
callback.Run(success, *available_space, *total_space);
}
@@ -1845,7 +1833,7 @@ int64_t QuotaManager::CallGetAmountOfFreeDiskSpace(
LOG(WARNING) << "Create directory failed for path" << profile_path.value();
return 0;
}
- uint64_t available, total;
+ int64_t available, total;
Lei Zhang 2016/06/10 05:46:37 style: One variable declaration per line please.
fukino 2016/06/10 12:10:09 In the new patch, this line doesn't need to be cha
if (!get_volume_info_fn(profile_path, &available, &total)) {
return 0;
}
@@ -1854,28 +1842,4 @@ int64_t QuotaManager::CallGetAmountOfFreeDiskSpace(
return static_cast<int64_t>(available);
}
-//static
-bool QuotaManager::GetVolumeInfo(const base::FilePath& path,
- uint64_t* available_space,
- uint64_t* total_size) {
- // Inspired by similar code in the base::SysInfo class.
- base::ThreadRestrictions::AssertIOAllowed();
-#if defined(OS_WIN)
- ULARGE_INTEGER available, total, free;
- if (!GetDiskFreeSpaceExW(path.value().c_str(), &available, &total, &free))
- return false;
- *available_space = static_cast<uint64_t>(available.QuadPart);
- *total_size = static_cast<uint64_t>(total.QuadPart);
-#elif defined(OS_POSIX)
- struct statvfs stats;
- if (HANDLE_EINTR(statvfs(path.value().c_str(), &stats)) != 0)
- return false;
- *available_space = static_cast<uint64_t>(stats.f_bavail) * stats.f_frsize;
- *total_size = static_cast<uint64_t>(stats.f_blocks) * stats.f_frsize;
-#else
-#error Not implemented
-#endif
- return true;
-}
-
} // namespace storage

Powered by Google App Engine
This is Rietveld 408576698