Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Unified Diff: base/cpu.cc

Issue 188443003: Parsing /proc/cpuinfo for model on Android and Aura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« AUTHORS ('K') | « AUTHORS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
}
« AUTHORS ('K') | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698