| OLD | NEW |
| 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 <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 DCHECK(static_cast<uint64>(limit) <= std::numeric_limits<size_t>::max()); | 39 DCHECK(static_cast<uint64>(limit) <= std::numeric_limits<size_t>::max()); |
| 40 limit_valid = true; | 40 limit_valid = true; |
| 41 } else { | 41 } else { |
| 42 NOTREACHED(); | 42 NOTREACHED(); |
| 43 return 0; | 43 return 0; |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 return static_cast<size_t>(limit); | 46 return static_cast<size_t>(limit); |
| 47 } | 47 } |
| 48 | 48 |
| 49 // static |
| 50 std::string SysInfo::CPUModelName() { |
| 51 const char kModelNamePrefix[] = "model name"; |
| 52 std::string contents; |
| 53 file_util::ReadFileToString(FilePath("/proc/cpuinfo"), &contents); |
| 54 DCHECK(!contents.empty()); |
| 55 if (!contents.empty()) { |
| 56 std::istringstream iss(contents); |
| 57 std::string line; |
| 58 while (std::getline(iss, line)){ |
| 59 if (line.compare(0, strlen(kModelNamePrefix), kModelNamePrefix) == 0) { |
| 60 size_t pos = line.find(": "); |
| 61 return line.substr(pos + 2); |
| 62 } |
| 63 } |
| 64 } |
| 65 |
| 66 return "unknown"; |
| 67 } |
| 68 |
| 49 } // namespace base | 69 } // namespace base |
| OLD | NEW |