Don't leave aborted URLs in the omnibox unless we're on the NTP.
[chromium-blink-merge.git] / base / process / process_metrics.cc
blob95fb87ddf624e9bd7f2b540565b008f228d1d64a
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/process/process_metrics.h"
7 #include "base/logging.h"
8 #include "base/values.h"
10 namespace base {
12 SystemMetrics::SystemMetrics() {
13 committed_memory_ = 0;
16 SystemMetrics SystemMetrics::Sample() {
17 SystemMetrics system_metrics;
19 system_metrics.committed_memory_ = GetSystemCommitCharge();
20 #if defined(OS_LINUX) || defined(OS_ANDROID)
21 GetSystemMemoryInfo(&system_metrics.memory_info_);
22 GetSystemDiskInfo(&system_metrics.disk_info_);
23 #endif
24 #if defined(OS_CHROMEOS)
25 GetSwapInfo(&system_metrics.swap_info_);
26 #endif
28 return system_metrics;
31 scoped_ptr<Value> SystemMetrics::ToValue() const {
32 scoped_ptr<DictionaryValue> res(new DictionaryValue());
34 res->SetInteger("committed_memory", static_cast<int>(committed_memory_));
35 #if defined(OS_LINUX) || defined(OS_ANDROID)
36 res->Set("meminfo", memory_info_.ToValue().release());
37 res->Set("diskinfo", disk_info_.ToValue().release());
38 #endif
39 #if defined(OS_CHROMEOS)
40 res->Set("swapinfo", swap_info_.ToValue().release());
41 #endif
43 return res.PassAs<Value>();
46 double ProcessMetrics::GetPlatformIndependentCPUUsage() {
47 #if defined(OS_WIN)
48 return GetCPUUsage() * processor_count_;
49 #else
50 return GetCPUUsage();
51 #endif
54 #if !defined(OS_MACOSX)
55 int ProcessMetrics::GetIdleWakeupsPerSecond() {
56 NOTIMPLEMENTED(); // http://crbug.com/20488
57 return 0;
59 #endif // !defined(OS_MACOSX)
61 } // namespace base