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

Side by Side Diff: base/sys_info_posix.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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/sys_info.h" 5 #include "base/sys_info.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 #endif 84 #endif
85 85
86 // static 86 // static
87 int64_t SysInfo::AmountOfVirtualMemory() { 87 int64_t SysInfo::AmountOfVirtualMemory() {
88 return g_lazy_virtual_memory.Get().value(); 88 return g_lazy_virtual_memory.Get().value();
89 } 89 }
90 90
91 // static 91 // static
92 int64_t SysInfo::AmountOfFreeDiskSpace(const FilePath& path) { 92 int64_t SysInfo::AmountOfFreeDiskSpace(const FilePath& path) {
93 base::ThreadRestrictions::AssertIOAllowed(); 93 int64_t available, unused;
94 if (!GetDiskSpaceInfo(path, &available, &unused))
95 return -1;
96 return available;
97 }
98
99 // static
100 bool SysInfo::GetDiskSpaceInfo(const FilePath& path,
101 int64_t* available_bytes,
102 int64_t* total_bytes) {
103 ThreadRestrictions::AssertIOAllowed();
94 104
95 struct statvfs stats; 105 struct statvfs stats;
96 if (HANDLE_EINTR(statvfs(path.value().c_str(), &stats)) != 0) 106 if (HANDLE_EINTR(statvfs(path.value().c_str(), &stats)) != 0)
97 return -1; 107 return false;
98 return static_cast<int64_t>(stats.f_bavail) * stats.f_frsize; 108
109 *available_bytes = static_cast<int64_t>(stats.f_bavail) * stats.f_frsize;
110 *total_bytes = static_cast<int64_t>(stats.f_blocks) * stats.f_frsize;
111 return true;
99 } 112 }
100 113
101 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) 114 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
102 // static 115 // static
103 std::string SysInfo::OperatingSystemName() { 116 std::string SysInfo::OperatingSystemName() {
104 struct utsname info; 117 struct utsname info;
105 if (uname(&info) < 0) { 118 if (uname(&info) < 0) {
106 NOTREACHED(); 119 NOTREACHED();
107 return std::string(); 120 return std::string();
108 } 121 }
(...skipping 28 matching lines...) Expand all
137 } 150 }
138 return arch; 151 return arch;
139 } 152 }
140 153
141 // static 154 // static
142 size_t SysInfo::VMAllocationGranularity() { 155 size_t SysInfo::VMAllocationGranularity() {
143 return getpagesize(); 156 return getpagesize();
144 } 157 }
145 158
146 } // namespace base 159 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698