OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <mach/mach.h> | 7 #include <mach/mach.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <sys/sysctl.h> | 10 #include <sys/sysctl.h> |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 | 94 |
95 // static | 95 // static |
96 std::string SysInfo::CPUModelName() { | 96 std::string SysInfo::CPUModelName() { |
97 char name[256]; | 97 char name[256]; |
98 size_t len = arraysize(name); | 98 size_t len = arraysize(name); |
99 if (sysctlbyname("machdep.cpu.brand_string", &name, &len, NULL, 0) == 0) | 99 if (sysctlbyname("machdep.cpu.brand_string", &name, &len, NULL, 0) == 0) |
100 return name; | 100 return name; |
101 return std::string(); | 101 return std::string(); |
102 } | 102 } |
103 | 103 |
104 // static | |
105 std::string SysInfo::HardwareModelName() { | |
106 char model[256]; | |
107 size_t len = sizeof(model); | |
108 if (sysctlbyname("hw.model", model, &len, NULL, 0) == 0) | |
109 return std::string(model, 0, len); | |
Mark Mentovai
2017/05/04 16:29:13
This is weird. I don’t think that there’s a std::s
Alexei Svitkine (slow)
2017/05/04 16:44:07
Good catch - done for both Mac and iOS and made CP
| |
110 return std::string(); | |
111 } | |
112 | |
104 } // namespace base | 113 } // namespace base |
OLD | NEW |