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

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

Issue 655003004: Use scoped_ptr::Pass instead of scoped_ptr::PassAs<T>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« base/metrics/histogram.cc ('K') | « base/process/process_metrics.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <dirent.h> 7 #include <dirent.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <sys/time.h> 10 #include <sys/time.h>
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 res->SetInteger("pswpin", pswpin); 517 res->SetInteger("pswpin", pswpin);
518 res->SetInteger("pswpout", pswpout); 518 res->SetInteger("pswpout", pswpout);
519 res->SetInteger("pgmajfault", pgmajfault); 519 res->SetInteger("pgmajfault", pgmajfault);
520 #ifdef OS_CHROMEOS 520 #ifdef OS_CHROMEOS
521 res->SetInteger("shmem", shmem); 521 res->SetInteger("shmem", shmem);
522 res->SetInteger("slab", slab); 522 res->SetInteger("slab", slab);
523 res->SetInteger("gem_objects", gem_objects); 523 res->SetInteger("gem_objects", gem_objects);
524 res->SetInteger("gem_size", gem_size); 524 res->SetInteger("gem_size", gem_size);
525 #endif 525 #endif
526 526
527 return res.PassAs<Value>(); 527 return res.Pass();
528 } 528 }
529 529
530 // exposed for testing 530 // exposed for testing
531 bool ParseProcMeminfo(const std::string& meminfo_data, 531 bool ParseProcMeminfo(const std::string& meminfo_data,
532 SystemMemoryInfoKB* meminfo) { 532 SystemMemoryInfoKB* meminfo) {
533 // The format of /proc/meminfo is: 533 // The format of /proc/meminfo is:
534 // 534 //
535 // MemTotal: 8235324 kB 535 // MemTotal: 8235324 kB
536 // MemFree: 1628304 kB 536 // MemFree: 1628304 kB
537 // Buffers: 429596 kB 537 // Buffers: 429596 kB
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 res->SetDouble("sectors_read", static_cast<double>(sectors_read)); 724 res->SetDouble("sectors_read", static_cast<double>(sectors_read));
725 res->SetDouble("read_time", static_cast<double>(read_time)); 725 res->SetDouble("read_time", static_cast<double>(read_time));
726 res->SetDouble("writes", static_cast<double>(writes)); 726 res->SetDouble("writes", static_cast<double>(writes));
727 res->SetDouble("writes_merged", static_cast<double>(writes_merged)); 727 res->SetDouble("writes_merged", static_cast<double>(writes_merged));
728 res->SetDouble("sectors_written", static_cast<double>(sectors_written)); 728 res->SetDouble("sectors_written", static_cast<double>(sectors_written));
729 res->SetDouble("write_time", static_cast<double>(write_time)); 729 res->SetDouble("write_time", static_cast<double>(write_time));
730 res->SetDouble("io", static_cast<double>(io)); 730 res->SetDouble("io", static_cast<double>(io));
731 res->SetDouble("io_time", static_cast<double>(io_time)); 731 res->SetDouble("io_time", static_cast<double>(io_time));
732 res->SetDouble("weighted_io_time", static_cast<double>(weighted_io_time)); 732 res->SetDouble("weighted_io_time", static_cast<double>(weighted_io_time));
733 733
734 return res.PassAs<Value>(); 734 return res.Pass();
735 } 735 }
736 736
737 bool IsValidDiskName(const std::string& candidate) { 737 bool IsValidDiskName(const std::string& candidate) {
738 if (candidate.length() < 3) 738 if (candidate.length() < 3)
739 return false; 739 return false;
740 if (candidate[1] == 'd' && 740 if (candidate[1] == 'd' &&
741 (candidate[0] == 'h' || candidate[0] == 's' || candidate[0] == 'v')) { 741 (candidate[0] == 'h' || candidate[0] == 's' || candidate[0] == 'v')) {
742 // [hsv]d[a-z]+ case 742 // [hsv]d[a-z]+ case
743 for (size_t i = 2; i < candidate.length(); ++i) { 743 for (size_t i = 2; i < candidate.length(); ++i) {
744 if (!islower(candidate[i])) 744 if (!islower(candidate[i]))
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 res->SetDouble("num_writes", static_cast<double>(num_writes)); 849 res->SetDouble("num_writes", static_cast<double>(num_writes));
850 res->SetDouble("orig_data_size", static_cast<double>(orig_data_size)); 850 res->SetDouble("orig_data_size", static_cast<double>(orig_data_size));
851 res->SetDouble("compr_data_size", static_cast<double>(compr_data_size)); 851 res->SetDouble("compr_data_size", static_cast<double>(compr_data_size));
852 res->SetDouble("mem_used_total", static_cast<double>(mem_used_total)); 852 res->SetDouble("mem_used_total", static_cast<double>(mem_used_total));
853 if (compr_data_size > 0) 853 if (compr_data_size > 0)
854 res->SetDouble("compression_ratio", static_cast<double>(orig_data_size) / 854 res->SetDouble("compression_ratio", static_cast<double>(orig_data_size) /
855 static_cast<double>(compr_data_size)); 855 static_cast<double>(compr_data_size));
856 else 856 else
857 res->SetDouble("compression_ratio", 0); 857 res->SetDouble("compression_ratio", 0);
858 858
859 return res.PassAs<Value>(); 859 return res.Pass();
860 } 860 }
861 861
862 void GetSwapInfo(SwapInfo* swap_info) { 862 void GetSwapInfo(SwapInfo* swap_info) {
863 // Synchronously reading files in /sys/block/zram0 does not hit the disk. 863 // Synchronously reading files in /sys/block/zram0 does not hit the disk.
864 ThreadRestrictions::ScopedAllowIO allow_io; 864 ThreadRestrictions::ScopedAllowIO allow_io;
865 865
866 FilePath zram_path("/sys/block/zram0"); 866 FilePath zram_path("/sys/block/zram0");
867 uint64 orig_data_size = ReadFileToUint64(zram_path.Append("orig_data_size")); 867 uint64 orig_data_size = ReadFileToUint64(zram_path.Append("orig_data_size"));
868 if (orig_data_size <= 4096) { 868 if (orig_data_size <= 4096) {
869 // A single page is compressed at startup, and has a high compression 869 // A single page is compressed at startup, and has a high compression
(...skipping 18 matching lines...) Expand all
888 #if defined(OS_LINUX) 888 #if defined(OS_LINUX)
889 int ProcessMetrics::GetIdleWakeupsPerSecond() { 889 int ProcessMetrics::GetIdleWakeupsPerSecond() {
890 uint64 wake_ups; 890 uint64 wake_ups;
891 const char kWakeupStat[] = "se.statistics.nr_wakeups"; 891 const char kWakeupStat[] = "se.statistics.nr_wakeups";
892 return ReadProcSchedAndGetFieldAsUint64(process_, kWakeupStat, &wake_ups) ? 892 return ReadProcSchedAndGetFieldAsUint64(process_, kWakeupStat, &wake_ups) ?
893 CalculateIdleWakeupsPerSecond(wake_ups) : 0; 893 CalculateIdleWakeupsPerSecond(wake_ups) : 0;
894 } 894 }
895 #endif // defined(OS_LINUX) 895 #endif // defined(OS_LINUX)
896 896
897 } // namespace base 897 } // namespace base
OLDNEW
« base/metrics/histogram.cc ('K') | « base/process/process_metrics.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698