Chromium Code Reviews| Index: base/sys_info_mac.cc |
| diff --git a/base/sys_info_mac.cc b/base/sys_info_mac.cc |
| index 1a1d23c236f6856ebb55157a0dcd56706ca4d6ef..f18983d88a075abb9fae9312d70f23d3a0c6971a 100644 |
| --- a/base/sys_info_mac.cc |
| +++ b/base/sys_info_mac.cc |
| @@ -8,6 +8,8 @@ |
| #include <CoreServices/CoreServices.h> |
| #include <mach/mach_host.h> |
| #include <mach/mach_init.h> |
| +#include <sys/sysctl.h> |
| +#include <sys/types.h> |
| #include "base/logging.h" |
| #include "base/stringprintf.h" |
| @@ -54,4 +56,12 @@ int64 SysInfo::AmountOfPhysicalMemory() { |
| return static_cast<int64>(hostinfo.max_mem); |
| } |
| +// static |
| +std::string SysInfo::CPUModelName() { |
| + char model_name[256] = { 0 }; |
|
Mark Mentovai
2012/09/06 14:17:56
You don’t need the { 0 } at all It’s fine to leave
Hongbo Min
2012/09/06 14:33:45
Done.
|
| + size_t len = 256; |
|
Mark Mentovai
2012/09/06 14:17:56
Not 256, but arraysize(model_name).
Hongbo Min
2012/09/06 14:33:45
Done.
|
| + sysctlbyname("machdep.cpu.brand_string", &model_name, &len, NULL, 0); |
|
Mark Mentovai
2012/09/06 14:17:56
You should check the return value, and return an e
Hongbo Min
2012/09/06 14:33:45
Done.
|
| + return std::string(model_name); |
| +} |
| + |
| } // namespace base |