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

Side by Side Diff: base/process/process_metrics.cc

Issue 23155002: Implement ToValue() for SystemMetrics, SystemMemoryInfoKB, DiskInfo, and SwapInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@meminfo
Patch Set: removing rate stats, compute them later Created 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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/process/process_metrics.h" 5 #include "base/process/process_metrics.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 8
9 namespace base { 9 namespace base {
10 10
11 SystemMetrics SystemMetrics::Sample() { 11 SystemMetrics SystemMetrics::Sample() {
12 SystemMetrics system_metrics; 12 SystemMetrics system_metrics;
13 13
14 system_metrics.committed_memory_ = GetSystemCommitCharge(); 14 system_metrics.committed_memory_ = GetSystemCommitCharge();
15 #if defined(OS_LINUX) || defined(OS_ANDROID) 15 #if defined(OS_LINUX) || defined(OS_ANDROID)
16 GetSystemMemoryInfo(&system_metrics.memory_info_); 16 GetSystemMemoryInfo(&system_metrics.memory_info_);
17 #endif 17 #endif
18 #if defined(OS_LINUX) 18 #if defined(OS_LINUX)
19 GetSystemDiskInfo(&system_metrics.disk_info_); 19 GetSystemDiskInfo(&system_metrics.disk_info_);
20 #endif 20 #endif
21 #if defined(OS_CHROMEOS) 21 #if defined(OS_CHROMEOS)
22 GetSwapInfo(&system_metrics.swap_info_); 22 GetSwapInfo(&system_metrics.swap_info_);
23 #endif 23 #endif
24 24
25 return system_metrics; 25 return system_metrics;
26 } 26 }
27 27
28 Value* SystemMetrics::AsValue() const {
29 DictionaryValue* res = new base::DictionaryValue();
30
31 res->SetInteger("committed_memory", committed_memory_);
32 #if defined(OS_LINUX) || defined(OS_ANDROID)
33 res->Set("meminfo", memory_info_.AsValue());
34 #endif
35 #if defined(OS_LINUX)
36 res->Set("diskinfo", disk_info_.AsValue());
37 #endif
38 #if defined(OS_CHROMEOS)
39 res->Set("swapinfo", swap_info_.AsValue());
40 #endif
41
42 return res;
43 }
44
28 } // namespace base 45 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698