Chromium Code Reviews| Index: base/sys_info_ios.mm |
| diff --git a/base/sys_info_ios.mm b/base/sys_info_ios.mm |
| index 9a329b9f0924bbdefce908cd51de4a6488c574f0..e544848abbea62bb31ff068b2ce74bf0e7d361db 100644 |
| --- a/base/sys_info_ios.mm |
| +++ b/base/sys_info_ios.mm |
| @@ -20,6 +20,23 @@ |
| namespace base { |
| +namespace { |
| + |
| +// Queries sysctlbyname() for the given key and returns the value from the |
| +// system or the empty string on failure. |
| +std::string GetSysctlValue(const char* key_name) { |
| + char value[256]; |
| + size_t len = arraysize(value); |
| + if (sysctlbyname(key_name, &value, &len, nullptr, 0) == 0) { |
| + DCHECK_GE(len, 1u); |
| + DCHECK_EQ('\0', value[len - 1]); |
| + return std::string(value, len - 1); |
| + } |
| + return std::string(); |
| +} |
| + |
| +} // namespace |
| + |
| // static |
| std::string SysInfo::OperatingSystemName() { |
| static dispatch_once_t get_system_name_once; |
| @@ -94,11 +111,12 @@ int64_t SysInfo::AmountOfAvailablePhysicalMemory() { |
| // static |
| std::string SysInfo::CPUModelName() { |
| - char name[256]; |
| - size_t len = arraysize(name); |
| - if (sysctlbyname("machdep.cpu.brand_string", &name, &len, NULL, 0) == 0) |
| - return name; |
| - return std::string(); |
| + return GetSysctlValue("machdep.cpu.brand_string"); |
| +} |
| + |
| +// static |
| +std::string SysInfo::HardwareModelName() { |
| + return GetSysctlValue("hw.model"); |
|
pkl (ping after 24h if needed)
2017/05/04 19:50:22
I patched this CL and tested it on a real device (
Alexei Svitkine (slow)
2017/05/04 20:01:41
Wow - that's pretty strange. Thanks for checking!
|
| } |
| } // namespace base |