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

Unified Diff: chrome/browser/extensions/api/system_info_cpu/cpu_info_provider_mac.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_mac.cc
diff --git a/chrome/browser/extensions/api/system_info_cpu/cpu_info_provider_mac.cc b/chrome/browser/extensions/api/system_info_cpu/cpu_info_provider_mac.cc
deleted file mode 100644
index 3ffdc78e633fc8689872eaa8ba5546095643000d..0000000000000000000000000000000000000000
--- a/chrome/browser/extensions/api/system_info_cpu/cpu_info_provider_mac.cc
+++ /dev/null
@@ -1,52 +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 <mach/mach_host.h>
-
-#include "base/mac/scoped_mach_port.h"
-
-namespace extensions {
-
-bool CpuInfoProvider::QueryCpuTimePerProcessor(std::vector<CpuTime>* times) {
- natural_t num_of_processors;
- base::mac::ScopedMachPort host(mach_host_self());
- mach_msg_type_number_t type;
- processor_cpu_load_info_data_t* cpu_infos;
-
- if (host_processor_info(host.get(),
- PROCESSOR_CPU_LOAD_INFO,
- &num_of_processors,
- reinterpret_cast<processor_info_array_t*>(&cpu_infos),
- &type) == KERN_SUCCESS) {
- std::vector<CpuTime> results;
- int64 user = 0, nice = 0, sys = 0, idle = 0;
-
- for (natural_t i = 0; i < num_of_processors; ++i) {
- CpuTime time;
-
- user = static_cast<int64>(cpu_infos[i].cpu_ticks[CPU_STATE_USER]);
- sys = static_cast<int64>(cpu_infos[i].cpu_ticks[CPU_STATE_SYSTEM]);
- nice = static_cast<int64>(cpu_infos[i].cpu_ticks[CPU_STATE_NICE]);
- idle = static_cast<int64>(cpu_infos[i].cpu_ticks[CPU_STATE_IDLE]);
-
- time.kernel = sys;
- time.user = user + nice;
- time.idle = idle;
- results.push_back(time);
- }
-
- vm_deallocate(mach_task_self(),
- reinterpret_cast<vm_address_t>(cpu_infos),
- num_of_processors * sizeof(processor_cpu_load_info));
-
- times->swap(results);
- return true;
- }
-
- return false;
-}
-
-} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698