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

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

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 years, 8 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
« no previous file with comments | « base/process/process_metrics.cc ('k') | base/process/process_metrics_unittest.cc » ('j') | 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 <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 shmem = 0; 552 shmem = 0;
553 slab = 0; 553 slab = 0;
554 gem_objects = -1; 554 gem_objects = -1;
555 gem_size = -1; 555 gem_size = -1;
556 #endif 556 #endif
557 } 557 }
558 558
559 SystemMemoryInfoKB::SystemMemoryInfoKB(const SystemMemoryInfoKB& other) = 559 SystemMemoryInfoKB::SystemMemoryInfoKB(const SystemMemoryInfoKB& other) =
560 default; 560 default;
561 561
562 scoped_ptr<Value> SystemMemoryInfoKB::ToValue() const { 562 std::unique_ptr<Value> SystemMemoryInfoKB::ToValue() const {
563 scoped_ptr<DictionaryValue> res(new DictionaryValue()); 563 std::unique_ptr<DictionaryValue> res(new DictionaryValue());
564 564
565 res->SetInteger("total", total); 565 res->SetInteger("total", total);
566 res->SetInteger("free", free); 566 res->SetInteger("free", free);
567 res->SetInteger("buffers", buffers); 567 res->SetInteger("buffers", buffers);
568 res->SetInteger("cached", cached); 568 res->SetInteger("cached", cached);
569 res->SetInteger("active_anon", active_anon); 569 res->SetInteger("active_anon", active_anon);
570 res->SetInteger("inactive_anon", inactive_anon); 570 res->SetInteger("inactive_anon", inactive_anon);
571 res->SetInteger("active_file", active_file); 571 res->SetInteger("active_file", active_file);
572 res->SetInteger("inactive_file", inactive_file); 572 res->SetInteger("inactive_file", inactive_file);
573 res->SetInteger("swap_total", swap_total); 573 res->SetInteger("swap_total", swap_total);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 writes_merged = 0; 765 writes_merged = 0;
766 sectors_written = 0; 766 sectors_written = 0;
767 write_time = 0; 767 write_time = 0;
768 io = 0; 768 io = 0;
769 io_time = 0; 769 io_time = 0;
770 weighted_io_time = 0; 770 weighted_io_time = 0;
771 } 771 }
772 772
773 SystemDiskInfo::SystemDiskInfo(const SystemDiskInfo& other) = default; 773 SystemDiskInfo::SystemDiskInfo(const SystemDiskInfo& other) = default;
774 774
775 scoped_ptr<Value> SystemDiskInfo::ToValue() const { 775 std::unique_ptr<Value> SystemDiskInfo::ToValue() const {
776 scoped_ptr<DictionaryValue> res(new DictionaryValue()); 776 std::unique_ptr<DictionaryValue> res(new DictionaryValue());
777 777
778 // Write out uint64_t variables as doubles. 778 // Write out uint64_t variables as doubles.
779 // Note: this may discard some precision, but for JS there's no other option. 779 // Note: this may discard some precision, but for JS there's no other option.
780 res->SetDouble("reads", static_cast<double>(reads)); 780 res->SetDouble("reads", static_cast<double>(reads));
781 res->SetDouble("reads_merged", static_cast<double>(reads_merged)); 781 res->SetDouble("reads_merged", static_cast<double>(reads_merged));
782 res->SetDouble("sectors_read", static_cast<double>(sectors_read)); 782 res->SetDouble("sectors_read", static_cast<double>(sectors_read));
783 res->SetDouble("read_time", static_cast<double>(read_time)); 783 res->SetDouble("read_time", static_cast<double>(read_time));
784 res->SetDouble("writes", static_cast<double>(writes)); 784 res->SetDouble("writes", static_cast<double>(writes));
785 res->SetDouble("writes_merged", static_cast<double>(writes_merged)); 785 res->SetDouble("writes_merged", static_cast<double>(writes_merged));
786 res->SetDouble("sectors_written", static_cast<double>(sectors_written)); 786 res->SetDouble("sectors_written", static_cast<double>(sectors_written));
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 diskinfo->io += io; 891 diskinfo->io += io;
892 diskinfo->io_time += io_time; 892 diskinfo->io_time += io_time;
893 diskinfo->weighted_io_time += weighted_io_time; 893 diskinfo->weighted_io_time += weighted_io_time;
894 } 894 }
895 } 895 }
896 896
897 return true; 897 return true;
898 } 898 }
899 899
900 #if defined(OS_CHROMEOS) 900 #if defined(OS_CHROMEOS)
901 scoped_ptr<Value> SwapInfo::ToValue() const { 901 std::unique_ptr<Value> SwapInfo::ToValue() const {
902 scoped_ptr<DictionaryValue> res(new DictionaryValue()); 902 std::unique_ptr<DictionaryValue> res(new DictionaryValue());
903 903
904 // Write out uint64_t variables as doubles. 904 // Write out uint64_t variables as doubles.
905 // Note: this may discard some precision, but for JS there's no other option. 905 // Note: this may discard some precision, but for JS there's no other option.
906 res->SetDouble("num_reads", static_cast<double>(num_reads)); 906 res->SetDouble("num_reads", static_cast<double>(num_reads));
907 res->SetDouble("num_writes", static_cast<double>(num_writes)); 907 res->SetDouble("num_writes", static_cast<double>(num_writes));
908 res->SetDouble("orig_data_size", static_cast<double>(orig_data_size)); 908 res->SetDouble("orig_data_size", static_cast<double>(orig_data_size));
909 res->SetDouble("compr_data_size", static_cast<double>(compr_data_size)); 909 res->SetDouble("compr_data_size", static_cast<double>(compr_data_size));
910 res->SetDouble("mem_used_total", static_cast<double>(mem_used_total)); 910 res->SetDouble("mem_used_total", static_cast<double>(mem_used_total));
911 if (compr_data_size > 0) 911 if (compr_data_size > 0)
912 res->SetDouble("compression_ratio", static_cast<double>(orig_data_size) / 912 res->SetDouble("compression_ratio", static_cast<double>(orig_data_size) /
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 #if defined(OS_LINUX) 947 #if defined(OS_LINUX)
948 int ProcessMetrics::GetIdleWakeupsPerSecond() { 948 int ProcessMetrics::GetIdleWakeupsPerSecond() {
949 uint64_t wake_ups; 949 uint64_t wake_ups;
950 const char kWakeupStat[] = "se.statistics.nr_wakeups"; 950 const char kWakeupStat[] = "se.statistics.nr_wakeups";
951 return ReadProcSchedAndGetFieldAsUint64(process_, kWakeupStat, &wake_ups) ? 951 return ReadProcSchedAndGetFieldAsUint64(process_, kWakeupStat, &wake_ups) ?
952 CalculateIdleWakeupsPerSecond(wake_ups) : 0; 952 CalculateIdleWakeupsPerSecond(wake_ups) : 0;
953 } 953 }
954 #endif // defined(OS_LINUX) 954 #endif // defined(OS_LINUX)
955 955
956 } // namespace base 956 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process_metrics.cc ('k') | base/process/process_metrics_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698