Index: base/process/process_metrics_linux.cc |
diff --git a/base/process/process_metrics_linux.cc b/base/process/process_metrics_linux.cc |
index 95e2a3e6ab0a55b284642351c1aa59a3112fa3f9..dc95a51e40700fafc150de442aaae3cb6a930349 100644 |
--- a/base/process/process_metrics_linux.cc |
+++ b/base/process/process_metrics_linux.cc |
@@ -513,6 +513,34 @@ SystemMemoryInfoKB::SystemMemoryInfoKB() { |
#endif |
} |
+Value* SystemMemoryInfoKB::AsValue() const { |
+ 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); |
+#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; |
@@ -638,6 +666,26 @@ SystemDiskInfo::SystemDiskInfo() { |
weighted_io_time = 0; |
} |
+Value* SystemDiskInfo::AsValue() const { |
+ DictionaryValue* res = new base::DictionaryValue(); |
+ |
+ // Write out uint64 variables as doubles. |
+ // Note: this may discard some precision, but for JS there's no other option. |
+ res->SetDouble("reads", static_cast<double>(reads)); |
+ res->SetDouble("reads_merged", static_cast<double>(reads_merged)); |
+ res->SetDouble("sectors_read", static_cast<double>(sectors_read)); |
+ res->SetDouble("read_time", static_cast<double>(read_time)); |
+ res->SetDouble("writes", static_cast<double>(writes)); |
+ res->SetDouble("writes_merged", static_cast<double>(writes_merged)); |
+ res->SetDouble("sectors_written", static_cast<double>(sectors_written)); |
+ res->SetDouble("write_time", static_cast<double>(write_time)); |
+ res->SetDouble("io", static_cast<double>(io)); |
+ res->SetDouble("io_time", static_cast<double>(io_time)); |
+ res->SetDouble("weighted_io_time", static_cast<double>(weighted_io_time)); |
+ |
+ return res; |
+} |
+ |
bool IsValidDiskName(const std::string& candidate) { |
if (candidate.length() < 3) |
return false; |
@@ -743,6 +791,23 @@ bool GetSystemDiskInfo(SystemDiskInfo* diskinfo) { |
} |
#if defined(OS_CHROMEOS) |
+Value* SwapInfo::AsValue() const { |
+ DictionaryValue* res = new base::DictionaryValue(); |
+ |
+ // Write out uint64 variables as doubles. |
+ // Note: this may discard some precision, but for JS there's no other option. |
+ res->SetDouble("num_reads", static_cast<double>(num_reads)); |
+ res->SetDouble("num_writes", static_cast<double>(num_writes)); |
+ res->SetDouble("orig_data_size", static_cast<double>(orig_data_size)); |
+ res->SetDouble("compr_data_size", static_cast<double>(compr_data_size)); |
+ res->SetDouble("mem_used_total", static_cast<double>(mem_used_total)); |
+ if (compr_data_size > 0) { |
+ 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; |