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

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
« no previous file with comments | « base/sys_info_ios.mm ('k') | base/sys_info_mac.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sys_info_linux.cc
diff --git a/base/sys_info_linux.cc b/base/sys_info_linux.cc
index 03fdac28e58c9326eec145774544d0a2bd585575..59dfee06c52ee1e6d575c058f1dea41ec465731f 100644
--- a/base/sys_info_linux.cc
+++ b/base/sys_info_linux.cc
@@ -46,4 +46,23 @@ size_t SysInfo::MaxSharedMemorySize() {
return static_cast<size_t>(limit);
}
+// static
+std::string SysInfo::CPUModelName() {
+ 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)){
+ if (line.compare(0, strlen(kModelNamePrefix), kModelNamePrefix) == 0) {
+ size_t pos = line.find(": ");
+ return line.substr(pos + 2);
+ }
+ }
+ }
+ return std::string();
+}
+
} // namespace base
« no previous file with comments | « base/sys_info_ios.mm ('k') | base/sys_info_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698