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

Unified Diff: base/sys_info_linux.cc

Issue 10914060: Refine systemInfo.cpu API defintions and provide systemInfo.cpu.get impl for Windows and Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
Index: base/sys_info_linux.cc
diff --git a/base/sys_info_linux.cc b/base/sys_info_linux.cc
index 03fdac28e58c9326eec145774544d0a2bd585575..dcdd35216a76f88f77ab957302a82d84e305840e 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";
+ 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)){
Mihai Parparita -not on Chrome 2012/09/05 23:58:39 Nit: space after while.
Hongbo Min 2012/09/06 01:43:53 Done.
+ if (line.empty()) break;
+ if (line.compare(0, strlen(kModelNamePrefix), kModelNamePrefix) == 0) {
+ size_t pos = line.find(": ");
+ return line.substr(pos + 2);
+ }
+ }
+ }
+
+ return "unknown";
+}
+
} // namespace base

Powered by Google App Engine
This is Rietveld 408576698