Chromium Code Reviews| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 } else { | 54 } else { |
| 55 NOTREACHED(); | 55 NOTREACHED(); |
| 56 return 0; | 56 return 0; |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 return static_cast<size_t>(limit); | 59 return static_cast<size_t>(limit); |
| 60 } | 60 } |
| 61 | 61 |
| 62 // static | 62 // static |
| 63 std::string SysInfo::CPUModelName() { | 63 std::string SysInfo::CPUModelName() { |
| 64 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | |
| 65 const char kHardwarePrefix[] = "Hardware"; | |
| 66 #else | |
| 64 const char kModelNamePrefix[] = "model name"; | 67 const char kModelNamePrefix[] = "model name"; |
| 68 #endif | |
| 65 std::string contents; | 69 std::string contents; |
| 66 file_util::ReadFileToString(FilePath("/proc/cpuinfo"), &contents); | 70 file_util::ReadFileToString(FilePath("/proc/cpuinfo"), &contents); |
| 67 DCHECK(!contents.empty()); | 71 DCHECK(!contents.empty()); |
| 68 if (!contents.empty()) { | 72 if (!contents.empty()) { |
| 69 std::istringstream iss(contents); | 73 std::istringstream iss(contents); |
| 70 std::string line; | 74 std::string line; |
| 71 while (std::getline(iss, line)){ | 75 while (std::getline(iss, line)) { |
| 76 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | |
|
darin (slow to review)
2013/05/03 06:07:09
nit: #ifdefs suck. i'd be tempted to generalize t
zel
2013/05/03 18:02:16
Down to one #ifdef now. Even if I split this in a
| |
| 77 if (line.compare(0, strlen(kHardwarePrefix), kHardwarePrefix) == 0) { | |
| 78 #else | |
| 72 if (line.compare(0, strlen(kModelNamePrefix), kModelNamePrefix) == 0) { | 79 if (line.compare(0, strlen(kModelNamePrefix), kModelNamePrefix) == 0) { |
| 80 #endif | |
| 73 size_t pos = line.find(": "); | 81 size_t pos = line.find(": "); |
| 74 return line.substr(pos + 2); | 82 return line.substr(pos + 2); |
| 75 } | 83 } |
| 76 } | 84 } |
| 77 } | 85 } |
| 78 return std::string(); | 86 return std::string(); |
| 79 } | 87 } |
| 80 | 88 |
| 81 } // namespace base | 89 } // namespace base |
| OLD | NEW |