Chromium Code Reviews| Index: base/process/process_metrics_linux.cc |
| diff --git a/base/process/process_metrics_linux.cc b/base/process/process_metrics_linux.cc |
| index 9ebd3c7918e548e6acf42dbd3489e30f08a5f58f..7b19b58160bc9031ab77521b4dd021d51c676cc5 100644 |
| --- a/base/process/process_metrics_linux.cc |
| +++ b/base/process/process_metrics_linux.cc |
| @@ -514,6 +514,37 @@ SystemMemoryInfoKB::SystemMemoryInfoKB() { |
| #endif |
| } |
| +Value* SystemMemoryInfoKB::AsValue() const { |
|
nduca
2013/08/14 18:08:58
this hsould be in process_metrics.cc with #ifdefs
|
| + DictionaryValue* res = new base::DictionaryValue(); |
| + |
| + res->SetInteger("total", total); |
| + res->SetInteger("free", free); |
| + res->SetInteger("buffers", buffers); |
| + res->SetInteger("cached", cached); |
| + res->SetInteger("active_anon", active_anon); |
| + res->SetInteger("inactive_anon", inactive_anon); |
| + res->SetInteger("active_file", active_file); |
| + res->SetInteger("inactive_file", inactive_file); |
| + res->SetInteger("swap_total", swap_total); |
| + res->SetInteger("swap_free", swap_free); |
| + res->SetInteger("swap_used", swap_total - swap_free); |
| + res->SetInteger("dirty", dirty); |
| + res->SetInteger("pswpin", pswpin); |
| + res->SetInteger("pswpout", pswpout); |
| + res->SetInteger("pgmajfault", pgmajfault); |
| + res->SetInteger("bytes_swpin_per_sec", bytes_swpin_per_sec); |
| + res->SetInteger("bytes_swpout_per_sec", bytes_swpout_per_sec); |
| + res->SetInteger("pgmajfault_per_sec", pgmajfault_per_sec); |
| +#ifdef OS_CHROMEOS |
| + res->SetInteger("shmem", shmem); |
| + res->SetInteger("slab", slab); |
| + res->SetInteger("gem_objects", gem_objects); |
| + res->SetInteger("gem_size", gem_size); |
| +#endif |
| + |
| + return res; |
| +} |
| + |
| bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo) { |
| // Synchronously reading files in /proc is safe. |
| ThreadRestrictions::ScopedAllowIO allow_io; |
| @@ -641,6 +672,15 @@ SystemDiskInfo::SystemDiskInfo() { |
| bytes_written_per_sec = 0; |
| } |
| +Value* SystemDiskInfo::AsValue() const { |
| + DictionaryValue* res = new base::DictionaryValue(); |
| + |
| + res->SetInteger("bytes_read_per_sec",bytes_read_per_sec); |
| + res->SetInteger("bytes_written_per_sec", bytes_written_per_sec); |
| + |
| + return res; |
| +} |
| + |
| bool ValidDiskName(const std::string& candidate) { |
| if (candidate.length() < 3) |
| return false; |
| @@ -746,6 +786,21 @@ bool GetSystemDiskInfo(SystemDiskInfo* diskinfo) { |
| } |
| #if defined(OS_CHROMEOS) |
| +Value* SwapInfo::AsValue() const { |
| + DictionaryValue* res = new base::DictionaryValue(); |
| + |
| + res->SetInteger("num_reads", num_reads); |
| + res->SetInteger("num_writes", num_writes); |
| + res->SetInteger("orig_data_size", orig_data_size); |
| + res->SetInteger("compr_data_size", compr_data_size); |
| + res->SetInteger("mem_used_total", mem_used_total); |
| + if (compr_data_size > 0) { |
|
nduca
2013/08/14 18:08:58
one line ifs dont get braces
|
| + res->SetInteger("compression_ratio", orig_data_size / compr_data_size); |
| + } |
| + |
| + return res; |
| +} |
| + |
| void GetSwapInfo(SwapInfo* swap_info) { |
| // Synchronously reading files in /sys/block/zram0 is safe. |
| ThreadRestrictions::ScopedAllowIO allow_io; |