OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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::GetCurrent() { | 11 SystemMetrics SystemMetrics::GetCurrent() { |
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) | |
16 GetSystemMemoryInfo(&system_metrics.memory_info_); | 15 GetSystemMemoryInfo(&system_metrics.memory_info_); |
| 16 GetSystemDiskInfo(&system_metrics.disk_info_); |
| 17 #ifdef OS_CHROMEOS |
| 18 GetSwapInfo(&system_metrics.swap_info_); |
17 #endif | 19 #endif |
18 | 20 |
19 return system_metrics; | 21 return system_metrics; |
20 } | 22 } |
21 | 23 |
| 24 Value* SystemMetrics::AsValue() const { |
| 25 DictionaryValue* res = new base::DictionaryValue(); |
| 26 |
| 27 res->SetInteger("committed_memory", committed_memory_); |
| 28 res->Set("meminfo", memory_info_.AsValue()); |
| 29 res->Set("diskinfo", disk_info_.AsValue()); |
| 30 #ifdef OS_CHROMEOS |
| 31 res->Set("swapinfo", swap_info_.AsValue()); |
| 32 #endif |
| 33 |
| 34 return res; |
| 35 } |
| 36 |
22 } // namespace base | 37 } // namespace base |
OLD | NEW |