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

Unified Diff: chrome/browser/extensions/api/system_info_cpu/cpu_info_provider_linux.cc

Issue 15817008: Move systemInfo.cpu API out out experimental namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 7 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: chrome/browser/extensions/api/system_info_cpu/cpu_info_provider_linux.cc
diff --git a/chrome/browser/extensions/api/system_info_cpu/cpu_info_provider_linux.cc b/chrome/browser/extensions/api/system_info_cpu/cpu_info_provider_linux.cc
deleted file mode 100644
index f76bd293c961c0be2cd547d31c2480bfde714dee..0000000000000000000000000000000000000000
--- a/chrome/browser/extensions/api/system_info_cpu/cpu_info_provider_linux.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/extensions/api/system_info_cpu/cpu_info_provider.h"
-
-#include <cstdio>
-#include <sstream>
-
-#include "base/file_util.h"
-#include "base/format_macros.h"
-
-namespace extensions {
-
-namespace {
-
-const char kProcStat[] = "/proc/stat";
-
-} // namespace
-
-bool CpuInfoProvider::QueryCpuTimePerProcessor(std::vector<CpuTime>* times) {
- DCHECK(times);
-
- std::string contents;
- if (!file_util::ReadFileToString(base::FilePath(kProcStat), &contents))
- return false;
-
- std::istringstream iss(contents);
- uint64 user = 0, nice = 0, sys = 0, idle = 0;
- std::string line;
-
- // Skip the first line because it is just an aggregated number of
- // all cpuN lines.
- std::getline(iss, line);
- std::vector<CpuTime> results;
- while (std::getline(iss, line)) {
- if (line.compare(0, 3, "cpu") != 0)
- continue;
-
- sscanf(line.c_str(), "%*s %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64,
- &user, &nice, &sys, &idle);
-
- CpuTime time;
- time.kernel = sys;
- time.user = user + nice;
- time.idle = idle;
- results.push_back(time);
- }
- times->swap(results);
- return true;
-}
-
-} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698