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

Side by Side 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: code refinement for mac and ios impl 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 28 matching lines...) Expand all
39 DCHECK(static_cast<uint64>(limit) <= std::numeric_limits<size_t>::max()); 39 DCHECK(static_cast<uint64>(limit) <= std::numeric_limits<size_t>::max());
40 limit_valid = true; 40 limit_valid = true;
41 } else { 41 } else {
42 NOTREACHED(); 42 NOTREACHED();
43 return 0; 43 return 0;
44 } 44 }
45 } 45 }
46 return static_cast<size_t>(limit); 46 return static_cast<size_t>(limit);
47 } 47 }
48 48
49 // static
50 std::string SysInfo::CPUModelName() {
51 const char kModelNamePrefix[] = "model name";
52 std::string contents;
53 file_util::ReadFileToString(FilePath("/proc/cpuinfo"), &contents);
54 DCHECK(!contents.empty());
55 if (!contents.empty()) {
56 std::istringstream iss(contents);
57 std::string line;
58 while (std::getline(iss, line)){
59 if (line.compare(0, strlen(kModelNamePrefix), kModelNamePrefix) == 0) {
60 size_t pos = line.find(": ");
61 return line.substr(pos + 2);
62 }
63 }
64 }
65
66 return "unknown";
67 }
68
49 } // namespace base 69 } // namespace base
OLDNEW
« base/sys_info.h ('K') | « 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