Chromium Code Reviews| OLD | NEW |
|---|---|
| 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() { | 11 SystemMetrics::SystemMetrics() { |
| 12 committed_memory_ = 0; | 12 committed_memory_ = 0; |
| 13 } | 13 } |
| 14 | 14 |
| 15 SystemMetrics SystemMetrics::Sample() { | 15 SystemMetrics SystemMetrics::Sample() { |
| 16 SystemMetrics system_metrics; | 16 SystemMetrics system_metrics; |
| 17 | 17 |
| 18 system_metrics.committed_memory_ = GetSystemCommitCharge(); | 18 system_metrics.committed_memory_ = GetSystemCommitCharge(); |
| 19 #if defined(OS_LINUX) || defined(OS_ANDROID) | 19 #if defined(OS_LINUX) || defined(OS_ANDROID) |
| 20 GetSystemMemoryInfo(&system_metrics.memory_info_); | 20 GetSystemMemoryInfo(&system_metrics.memory_info_); |
| 21 GetSystemDiskInfo(&system_metrics.disk_info_); | 21 GetSystemDiskInfo(&system_metrics.disk_info_); |
| 22 #endif | 22 #endif |
| 23 #if defined(OS_CHROMEOS) | 23 #if defined(OS_CHROMEOS) |
| 24 GetSwapInfo(&system_metrics.swap_info_); | 24 GetSwapInfo(&system_metrics.swap_info_); |
| 25 #endif | 25 #endif |
| 26 | 26 |
| 27 return system_metrics; | 27 return system_metrics; |
| 28 } | 28 } |
| 29 | 29 |
| 30 scoped_ptr<Value> SystemMetrics::ToValue() const { | |
| 31 scoped_ptr<DictionaryValue> res(new DictionaryValue()); | |
| 32 | |
| 33 res->SetInteger("committed_memory", committed_memory_); | |
| 34 #if defined(OS_LINUX) || defined(OS_ANDROID) | |
| 35 res->Set("meminfo", memory_info_.ToValue().release()); | |
|
darin (slow to review)
2013/09/05 07:32:10
I see. DictionaryValue::Set should probably take s
| |
| 36 res->Set("diskinfo", disk_info_.ToValue().release()); | |
| 37 #endif | |
| 38 #if defined(OS_CHROMEOS) | |
| 39 res->Set("swapinfo", swap_info_.ToValue().release()); | |
| 40 #endif | |
| 41 | |
| 42 return res.PassAs<Value>(); | |
| 43 } | |
| 44 | |
| 30 } // namespace base | 45 } // namespace base |
| OLD | NEW |