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

Unified Diff: base/sys_info_win.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: base/sys_info_win.cc
diff --git a/base/sys_info_win.cc b/base/sys_info_win.cc
index d2c7bcddc148d1693946fbb26086f676f85b1423..7ffb8e1a13c79bd3f2c2ed29938677865d198805 100644
--- a/base/sys_info_win.cc
+++ b/base/sys_info_win.cc
@@ -56,14 +56,29 @@ int64_t SysInfo::AmountOfVirtualMemory() {
// static
int64_t SysInfo::AmountOfFreeDiskSpace(const FilePath& path) {
+ int64_t available, unused;
+ if (!GetDiskSpaceInfo(path, &available, &unused))
+ return -1;
+ return available;
+}
+
+// static
+bool SysInfo::GetDiskSpaceInfo(const FilePath& path,
+ int64_t* available_bytes,
+ int64_t* total_bytes) {
ThreadRestrictions::AssertIOAllowed();
ULARGE_INTEGER available, total, free;
if (!GetDiskFreeSpaceExW(path.value().c_str(), &available, &total, &free))
- return -1;
-
- int64_t rv = static_cast<int64_t>(available.QuadPart);
- return rv < 0 ? std::numeric_limits<int64_t>::max() : rv;
+ return false;
+
+ *available_bytes = static_cast<int64_t>(available.QuadPart);
+ if (*available_bytes < 0)
+ *available_bytes = std::numeric_limits<int64_t>::max();
+ *total_bytes = static_cast<int64_t>(total.QuadPart);
+ if (*total_bytes < 0)
+ *total_bytes = std::numeric_limits<int64_t>::max();
+ return true;
}
std::string SysInfo::OperatingSystemName() {

Powered by Google App Engine
This is Rietveld 408576698