Chromium Code Reviews| Index: base/cpu.cc |
| diff --git a/base/cpu.cc b/base/cpu.cc |
| index 66207a1e0b8b0539b99a72b85435936f847803bb..5c23dfe070d0fb5f8182e41922078026ac523d16 100644 |
| --- a/base/cpu.cc |
| +++ b/base/cpu.cc |
| @@ -9,6 +9,7 @@ |
| #include <algorithm> |
| #include "base/basictypes.h" |
| +#include "base/file_util.h" |
| #include "build/build_config.h" |
| #if defined(ARCH_CPU_X86_FAMILY) |
| @@ -158,12 +159,22 @@ void CPU::Initialize() { |
| has_non_stop_time_stamp_counter_ = (cpu_info[3] & (1 << 8)) != 0; |
| } |
| #elif defined(ARCH_CPU_ARM_FAMILY) |
| - // TODO(piman): Expand this. ARM has a CPUID register, but it's not available |
| - // in user mode. /proc/cpuinfo has some information, but it's non standard, |
| - // platform-specific, and not accessible from the sandbox. |
| - // For some purposes, this first approximation is enough. |
| - // crbug.com/313454 |
| - cpu_brand_.assign("ARM"); |
| +#if defined(USE_AURA) || defined(OS_ANDROID) |
| + const char kProcessorPrefix[] = "Processor"; |
| + std::string contents; |
| + ReadFileToString(FilePath("/proc/cpuinfo"), &contents); |
|
Mark Mentovai
2014/03/06 14:41:55
How is this file formatted on ARM?
It’s probably
rptr
2014/03/08 06:26:59
This is how /proc/cpuinfo looks in Samsung Galaxy
|
| + DCHECK(!contents.empty()); |
| + if (!contents.empty()) { |
| + std::istringstream iss(contents); |
| + std::string line; |
| + while (std::getline(iss, line)) { |
| + if (line.compare(0, strlen(kProcessorPrefix), kProcessorPrefix) == 0) { |
| + size_t pos = line.find(": "); |
|
Mark Mentovai
2014/03/07 15:19:18
What if ": " was not found?
|
| + cpu_brand_.assign(line.substr(pos + 2)); |
|
vivekg
2014/03/07 11:59:52
You probably need to break here to avoid processin
|
| + } |
| + } |
| + } |
| +#endif |
| #endif |
| } |