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

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: Add AmountOfTotalDiskSpace() instead of GetDiskSpaceInfo(). 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
« base/sys_info_win.cc ('K') | « base/sys_info_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..79268a61a297bf966605004646d272d27ea637d9 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), \
@@ -1860,21 +1848,16 @@ bool QuotaManager::GetVolumeInfo(const base::FilePath& path,
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))
+
+ int64_t available = base::SysInfo::AmountOfFreeDiskSpace(path);
+ if (available < 0)
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)
+ int64_t total = base::SysInfo::AmountOfTotalDiskSpace(path);
+ if (total < 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
+
+ *available_space = static_cast<uint64_t>(available);
+ *total_size = static_cast<uint64_t>(total);
return true;
}
« base/sys_info_win.cc ('K') | « base/sys_info_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698