Chromium Code Reviews| Index: base/sys_info_linux.cc |
| diff --git a/base/sys_info_linux.cc b/base/sys_info_linux.cc |
| index 03fdac28e58c9326eec145774544d0a2bd585575..80ccbbfdd3a2bc70803c87a2fe167fc91ff0be7e 100644 |
| --- a/base/sys_info_linux.cc |
| +++ b/base/sys_info_linux.cc |
| @@ -46,4 +46,25 @@ size_t SysInfo::MaxSharedMemorySize() { |
| return static_cast<size_t>(limit); |
| } |
| +// static |
| +std::string SysInfo::CPUModelName() { |
| + static const char kModelNamePrefix[] = "model name"; |
|
Mark Mentovai
2012/09/06 13:39:13
“static” is useless here.
Hongbo Min
2012/09/06 14:09:09
Remove it already.
|
| + std::string contents; |
| + file_util::ReadFileToString(FilePath("/proc/cpuinfo"), &contents); |
| + DCHECK(!contents.empty()); |
| + if (!contents.empty()) { |
| + std::istringstream iss(contents); |
| + std::string line; |
| + while (std::getline(iss, line)){ |
| + if (line.empty()) break; |
|
Mark Mentovai
2012/09/06 13:39:13
This is sort of redundant given what happens next,
Hongbo Min
2012/09/06 14:09:09
Good catch. Thanks.
|
| + if (line.compare(0, strlen(kModelNamePrefix), kModelNamePrefix) == 0) { |
| + size_t pos = line.find(": "); |
| + return line.substr(pos + 2); |
| + } |
| + } |
| + } |
| + |
| + return "unknown"; |
| +} |
| + |
| } // namespace base |