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

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: 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 base::ThreadRestrictions::AssertIOAllowed();
94 94
95 struct statvfs stats; 95 struct statvfs stats;
96 if (HANDLE_EINTR(statvfs(path.value().c_str(), &stats)) != 0) 96 if (HANDLE_EINTR(statvfs(path.value().c_str(), &stats)) != 0)
97 return -1; 97 return -1;
98 return static_cast<int64_t>(stats.f_bavail) * stats.f_frsize; 98 return static_cast<int64_t>(stats.f_bavail) * stats.f_frsize;
Dan Beam 2016/06/09 17:20:13 nit: maybe use GetDiskSpaceInfo() to implement Amo
fukino 2016/06/10 01:33:36 Done. I updated this to use GetDiskSpaceInfo() in
99 } 99 }
100 100
101 // static
102 bool SysInfo::GetDiskSpaceInfo(const FilePath& path,
103 int64_t* available_bytes,
104 int64_t* total_bytes) {
105 ThreadRestrictions::AssertIOAllowed();
106
107 struct statvfs stats;
108 if (HANDLE_EINTR(statvfs(path.value().c_str(), &stats)) != 0)
109 return false;
110
111 *available_bytes = static_cast<uint64_t>(stats.f_bavail) * stats.f_frsize;
112 *total_bytes = static_cast<uint64_t>(stats.f_blocks) * stats.f_frsize;
113 return true;
114 }
115
101 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) 116 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
102 // static 117 // static
103 std::string SysInfo::OperatingSystemName() { 118 std::string SysInfo::OperatingSystemName() {
104 struct utsname info; 119 struct utsname info;
105 if (uname(&info) < 0) { 120 if (uname(&info) < 0) {
106 NOTREACHED(); 121 NOTREACHED();
107 return std::string(); 122 return std::string();
108 } 123 }
109 return std::string(info.sysname); 124 return std::string(info.sysname);
110 } 125 }
(...skipping 26 matching lines...) Expand all
137 } 152 }
138 return arch; 153 return arch;
139 } 154 }
140 155
141 // static 156 // static
142 size_t SysInfo::VMAllocationGranularity() { 157 size_t SysInfo::VMAllocationGranularity() {
143 return getpagesize(); 158 return getpagesize();
144 } 159 }
145 160
146 } // namespace base 161 } // namespace base
OLDNEW
« no previous file with comments | « base/sys_info.h ('k') | base/sys_info_unittest.cc » ('j') | base/sys_info_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698