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

Side by Side Diff: chrome/browser/extensions/api/system_cpu/cpu_info_provider_linux.cc

Issue 428613003: Make compile with gcc 4.7 work (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: no mojo Created 6 years, 4 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
« no previous file with comments | « build/common.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/extensions/api/system_cpu/cpu_info_provider.h" 5 #include "chrome/browser/extensions/api/system_cpu/cpu_info_provider.h"
6 6
7 #include <cstdio> 7 #include <cstdio>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 20 matching lines...) Expand all
31 31
32 // Skip the first line because it is just an aggregated number of 32 // Skip the first line because it is just an aggregated number of
33 // all cpuN lines. 33 // all cpuN lines.
34 std::getline(iss, line); 34 std::getline(iss, line);
35 size_t i = 0; 35 size_t i = 0;
36 while (std::getline(iss, line)) { 36 while (std::getline(iss, line)) {
37 if (line.compare(0, 3, "cpu") != 0) 37 if (line.compare(0, 3, "cpu") != 0)
38 continue; 38 continue;
39 39
40 uint64 user = 0, nice = 0, sys = 0, idle = 0; 40 uint64 user = 0, nice = 0, sys = 0, idle = 0;
41 int vals = sscanf(line.c_str(), "%*s %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64, 41 int vals = sscanf(line.c_str(),
42 "%*s %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64,
42 &user, &nice, &sys, &idle); 43 &user, &nice, &sys, &idle);
43 DCHECK_EQ(4, vals); 44 DCHECK_EQ(4, vals);
44 45
45 DCHECK(i < infos->size()); 46 DCHECK(i < infos->size());
46 infos->at(i)->usage.kernel = static_cast<double>(sys); 47 infos->at(i)->usage.kernel = static_cast<double>(sys);
47 infos->at(i)->usage.user = static_cast<double>(user + nice); 48 infos->at(i)->usage.user = static_cast<double>(user + nice);
48 infos->at(i)->usage.idle = static_cast<double>(idle); 49 infos->at(i)->usage.idle = static_cast<double>(idle);
49 infos->at(i)->usage.total = static_cast<double>(sys + user + nice + idle); 50 infos->at(i)->usage.total = static_cast<double>(sys + user + nice + idle);
50 ++i; 51 ++i;
51 } 52 }
52 DCHECK_EQ(infos->size(), i); 53 DCHECK_EQ(infos->size(), i);
53 return true; 54 return true;
54 } 55 }
55 56
56 } // namespace extensions 57 } // namespace extensions
OLDNEW
« no previous file with comments | « build/common.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698