Loading metricsd/collectors/averaged_statistics_collector_test.cc +3 −2 Original line number Original line Diff line number Diff line Loading @@ -16,11 +16,12 @@ #include "averaged_statistics_collector.h" #include "averaged_statistics_collector.h" #include <memory> #include <inttypes.h> #include <inttypes.h> #include <base/files/file_util.h> #include <base/files/file_util.h> #include <base/files/scoped_temp_dir.h> #include <base/files/scoped_temp_dir.h> #include <base/memory/scoped_ptr.h> #include <base/strings/stringprintf.h> #include <base/strings/stringprintf.h> #include <gtest/gtest.h> #include <gtest/gtest.h> Loading Loading @@ -62,7 +63,7 @@ class AveragedStatisticsTest : public testing::Test { } } // Collector used for tests. // Collector used for tests. scoped_ptr<AveragedStatisticsCollector> collector_; std::unique_ptr<AveragedStatisticsCollector> collector_; // Temporary directory used for tests. // Temporary directory used for tests. base::ScopedTempDir temp_dir_; base::ScopedTempDir temp_dir_; Loading metricsd/include/metrics/timer.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -19,10 +19,10 @@ #ifndef METRICS_TIMER_H_ #ifndef METRICS_TIMER_H_ #define METRICS_TIMER_H_ #define METRICS_TIMER_H_ #include <memory> #include <string> #include <string> #include <base/macros.h> #include <base/macros.h> #include <base/memory/scoped_ptr.h> #include <base/time/time.h> #include <base/time/time.h> #include <gtest/gtest_prod.h> // for FRIEND_TEST #include <gtest/gtest_prod.h> // for FRIEND_TEST Loading Loading @@ -121,7 +121,7 @@ class Timer : public TimerInterface { TimerState timer_state_; TimerState timer_state_; // Wrapper for the calls to the system clock. // Wrapper for the calls to the system clock. scoped_ptr<ClockWrapper> clock_wrapper_; std::unique_ptr<ClockWrapper> clock_wrapper_; DISALLOW_COPY_AND_ASSIGN(Timer); DISALLOW_COPY_AND_ASSIGN(Timer); }; }; Loading metricsd/metrics_collector.cc +5 −3 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,8 @@ #include <sysexits.h> #include <sysexits.h> #include <time.h> #include <time.h> #include <memory> #include <base/bind.h> #include <base/bind.h> #include <base/files/file_path.h> #include <base/files/file_path.h> #include <base/files/file_util.h> #include <base/files/file_util.h> Loading Loading @@ -665,7 +667,7 @@ void MetricsCollector::SendKernelCrashesCumulativeCountStats() { } } void MetricsCollector::SendAndResetDailyUseSample( void MetricsCollector::SendAndResetDailyUseSample( const scoped_ptr<PersistentInteger>& use) { const unique_ptr<PersistentInteger>& use) { SendSample(use->Name(), SendSample(use->Name(), use->GetAndClear(), use->GetAndClear(), 1, // value of first bucket 1, // value of first bucket Loading @@ -674,7 +676,7 @@ void MetricsCollector::SendAndResetDailyUseSample( } } void MetricsCollector::SendAndResetCrashIntervalSample( void MetricsCollector::SendAndResetCrashIntervalSample( const scoped_ptr<PersistentInteger>& interval) { const unique_ptr<PersistentInteger>& interval) { SendSample(interval->Name(), SendSample(interval->Name(), interval->GetAndClear(), interval->GetAndClear(), 1, // value of first bucket 1, // value of first bucket Loading @@ -683,7 +685,7 @@ void MetricsCollector::SendAndResetCrashIntervalSample( } } void MetricsCollector::SendAndResetCrashFrequencySample( void MetricsCollector::SendAndResetCrashFrequencySample( const scoped_ptr<PersistentInteger>& frequency) { const unique_ptr<PersistentInteger>& frequency) { SendSample(frequency->Name(), SendSample(frequency->Name(), frequency->GetAndClear(), frequency->GetAndClear(), 1, // value of first bucket 1, // value of first bucket Loading metricsd/metrics_collector.h +29 −29 Original line number Original line Diff line number Diff line Loading @@ -20,11 +20,11 @@ #include <stdint.h> #include <stdint.h> #include <map> #include <map> #include <memory> #include <string> #include <string> #include <vector> #include <vector> #include <base/files/file_path.h> #include <base/files/file_path.h> #include <base/memory/scoped_ptr.h> #include <base/time/time.h> #include <base/time/time.h> #include <brillo/daemons/dbus_daemon.h> #include <brillo/daemons/dbus_daemon.h> #include <libweaved/command.h> #include <libweaved/command.h> Loading @@ -38,6 +38,7 @@ #include "persistent_integer.h" #include "persistent_integer.h" using chromeos_metrics::PersistentInteger; using chromeos_metrics::PersistentInteger; using std::unique_ptr; class MetricsCollector : public brillo::DBusDaemon { class MetricsCollector : public brillo::DBusDaemon { public: public: Loading Loading @@ -151,18 +152,17 @@ class MetricsCollector : public brillo::DBusDaemon { // Sends a sample representing the number of seconds of active use // Sends a sample representing the number of seconds of active use // for a 24-hour period and reset |use|. // for a 24-hour period and reset |use|. void SendAndResetDailyUseSample( void SendAndResetDailyUseSample(const unique_ptr<PersistentInteger>& use); const scoped_ptr<PersistentInteger>& use); // Sends a sample representing a time interval between two crashes of the // Sends a sample representing a time interval between two crashes of the // same type and reset |interval|. // same type and reset |interval|. void SendAndResetCrashIntervalSample( void SendAndResetCrashIntervalSample( const scoped_ptr<PersistentInteger>& interval); const unique_ptr<PersistentInteger>& interval); // Sends a sample representing a frequency of crashes of some type and reset // Sends a sample representing a frequency of crashes of some type and reset // |frequency|. // |frequency|. void SendAndResetCrashFrequencySample( void SendAndResetCrashFrequencySample( const scoped_ptr<PersistentInteger>& frequency); const unique_ptr<PersistentInteger>& frequency); // Initializes vm and disk stats reporting. // Initializes vm and disk stats reporting. void StatsReporterInit(); void StatsReporterInit(); Loading Loading @@ -241,36 +241,36 @@ class MetricsCollector : public brillo::DBusDaemon { base::TimeDelta latest_cpu_use_microseconds_; base::TimeDelta latest_cpu_use_microseconds_; // Persistent values and accumulators for crash statistics. // Persistent values and accumulators for crash statistics. scoped_ptr<PersistentInteger> daily_cycle_; unique_ptr<PersistentInteger> daily_cycle_; scoped_ptr<PersistentInteger> weekly_cycle_; unique_ptr<PersistentInteger> weekly_cycle_; scoped_ptr<PersistentInteger> version_cycle_; unique_ptr<PersistentInteger> version_cycle_; // Active use accumulated in a day. // Active use accumulated in a day. scoped_ptr<PersistentInteger> daily_active_use_; unique_ptr<PersistentInteger> daily_active_use_; // Active use accumulated since the latest version update. // Active use accumulated since the latest version update. scoped_ptr<PersistentInteger> version_cumulative_active_use_; unique_ptr<PersistentInteger> version_cumulative_active_use_; // The CPU time accumulator. This contains the CPU time, in milliseconds, // The CPU time accumulator. This contains the CPU time, in milliseconds, // used by the system since the most recent OS version update. // used by the system since the most recent OS version update. scoped_ptr<PersistentInteger> version_cumulative_cpu_use_; unique_ptr<PersistentInteger> version_cumulative_cpu_use_; scoped_ptr<PersistentInteger> user_crash_interval_; unique_ptr<PersistentInteger> user_crash_interval_; scoped_ptr<PersistentInteger> kernel_crash_interval_; unique_ptr<PersistentInteger> kernel_crash_interval_; scoped_ptr<PersistentInteger> unclean_shutdown_interval_; unique_ptr<PersistentInteger> unclean_shutdown_interval_; scoped_ptr<PersistentInteger> any_crashes_daily_count_; unique_ptr<PersistentInteger> any_crashes_daily_count_; scoped_ptr<PersistentInteger> any_crashes_weekly_count_; unique_ptr<PersistentInteger> any_crashes_weekly_count_; scoped_ptr<PersistentInteger> user_crashes_daily_count_; unique_ptr<PersistentInteger> user_crashes_daily_count_; scoped_ptr<PersistentInteger> user_crashes_weekly_count_; unique_ptr<PersistentInteger> user_crashes_weekly_count_; scoped_ptr<PersistentInteger> kernel_crashes_daily_count_; unique_ptr<PersistentInteger> kernel_crashes_daily_count_; scoped_ptr<PersistentInteger> kernel_crashes_weekly_count_; unique_ptr<PersistentInteger> kernel_crashes_weekly_count_; scoped_ptr<PersistentInteger> kernel_crashes_version_count_; unique_ptr<PersistentInteger> kernel_crashes_version_count_; scoped_ptr<PersistentInteger> unclean_shutdowns_daily_count_; unique_ptr<PersistentInteger> unclean_shutdowns_daily_count_; scoped_ptr<PersistentInteger> unclean_shutdowns_weekly_count_; unique_ptr<PersistentInteger> unclean_shutdowns_weekly_count_; scoped_ptr<CpuUsageCollector> cpu_usage_collector_; unique_ptr<CpuUsageCollector> cpu_usage_collector_; scoped_ptr<DiskUsageCollector> disk_usage_collector_; unique_ptr<DiskUsageCollector> disk_usage_collector_; scoped_ptr<AveragedStatisticsCollector> averaged_stats_collector_; unique_ptr<AveragedStatisticsCollector> averaged_stats_collector_; std::unique_ptr<weaved::Device> device_; std::unique_ptr<weaved::Device> device_; }; }; Loading metricsd/persistent_integer_test.cc +3 −2 Original line number Original line Diff line number Diff line Loading @@ -14,12 +14,13 @@ * limitations under the License. * limitations under the License. */ */ #include <gtest/gtest.h> #include <memory> #include <base/compiler_specific.h> #include <base/compiler_specific.h> #include <base/files/file_enumerator.h> #include <base/files/file_enumerator.h> #include <base/files/file_util.h> #include <base/files/file_util.h> #include <base/files/scoped_temp_dir.h> #include <base/files/scoped_temp_dir.h> #include <gtest/gtest.h> #include "persistent_integer.h" #include "persistent_integer.h" Loading @@ -38,7 +39,7 @@ class PersistentIntegerTest : public testing::Test { }; }; TEST_F(PersistentIntegerTest, BasicChecks) { TEST_F(PersistentIntegerTest, BasicChecks) { scoped_ptr<PersistentInteger> pi( std::unique_ptr<PersistentInteger> pi( new PersistentInteger(kBackingFileName, temp_dir_.path())); new PersistentInteger(kBackingFileName, temp_dir_.path())); // Test initialization. // Test initialization. Loading Loading
metricsd/collectors/averaged_statistics_collector_test.cc +3 −2 Original line number Original line Diff line number Diff line Loading @@ -16,11 +16,12 @@ #include "averaged_statistics_collector.h" #include "averaged_statistics_collector.h" #include <memory> #include <inttypes.h> #include <inttypes.h> #include <base/files/file_util.h> #include <base/files/file_util.h> #include <base/files/scoped_temp_dir.h> #include <base/files/scoped_temp_dir.h> #include <base/memory/scoped_ptr.h> #include <base/strings/stringprintf.h> #include <base/strings/stringprintf.h> #include <gtest/gtest.h> #include <gtest/gtest.h> Loading Loading @@ -62,7 +63,7 @@ class AveragedStatisticsTest : public testing::Test { } } // Collector used for tests. // Collector used for tests. scoped_ptr<AveragedStatisticsCollector> collector_; std::unique_ptr<AveragedStatisticsCollector> collector_; // Temporary directory used for tests. // Temporary directory used for tests. base::ScopedTempDir temp_dir_; base::ScopedTempDir temp_dir_; Loading
metricsd/include/metrics/timer.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -19,10 +19,10 @@ #ifndef METRICS_TIMER_H_ #ifndef METRICS_TIMER_H_ #define METRICS_TIMER_H_ #define METRICS_TIMER_H_ #include <memory> #include <string> #include <string> #include <base/macros.h> #include <base/macros.h> #include <base/memory/scoped_ptr.h> #include <base/time/time.h> #include <base/time/time.h> #include <gtest/gtest_prod.h> // for FRIEND_TEST #include <gtest/gtest_prod.h> // for FRIEND_TEST Loading Loading @@ -121,7 +121,7 @@ class Timer : public TimerInterface { TimerState timer_state_; TimerState timer_state_; // Wrapper for the calls to the system clock. // Wrapper for the calls to the system clock. scoped_ptr<ClockWrapper> clock_wrapper_; std::unique_ptr<ClockWrapper> clock_wrapper_; DISALLOW_COPY_AND_ASSIGN(Timer); DISALLOW_COPY_AND_ASSIGN(Timer); }; }; Loading
metricsd/metrics_collector.cc +5 −3 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,8 @@ #include <sysexits.h> #include <sysexits.h> #include <time.h> #include <time.h> #include <memory> #include <base/bind.h> #include <base/bind.h> #include <base/files/file_path.h> #include <base/files/file_path.h> #include <base/files/file_util.h> #include <base/files/file_util.h> Loading Loading @@ -665,7 +667,7 @@ void MetricsCollector::SendKernelCrashesCumulativeCountStats() { } } void MetricsCollector::SendAndResetDailyUseSample( void MetricsCollector::SendAndResetDailyUseSample( const scoped_ptr<PersistentInteger>& use) { const unique_ptr<PersistentInteger>& use) { SendSample(use->Name(), SendSample(use->Name(), use->GetAndClear(), use->GetAndClear(), 1, // value of first bucket 1, // value of first bucket Loading @@ -674,7 +676,7 @@ void MetricsCollector::SendAndResetDailyUseSample( } } void MetricsCollector::SendAndResetCrashIntervalSample( void MetricsCollector::SendAndResetCrashIntervalSample( const scoped_ptr<PersistentInteger>& interval) { const unique_ptr<PersistentInteger>& interval) { SendSample(interval->Name(), SendSample(interval->Name(), interval->GetAndClear(), interval->GetAndClear(), 1, // value of first bucket 1, // value of first bucket Loading @@ -683,7 +685,7 @@ void MetricsCollector::SendAndResetCrashIntervalSample( } } void MetricsCollector::SendAndResetCrashFrequencySample( void MetricsCollector::SendAndResetCrashFrequencySample( const scoped_ptr<PersistentInteger>& frequency) { const unique_ptr<PersistentInteger>& frequency) { SendSample(frequency->Name(), SendSample(frequency->Name(), frequency->GetAndClear(), frequency->GetAndClear(), 1, // value of first bucket 1, // value of first bucket Loading
metricsd/metrics_collector.h +29 −29 Original line number Original line Diff line number Diff line Loading @@ -20,11 +20,11 @@ #include <stdint.h> #include <stdint.h> #include <map> #include <map> #include <memory> #include <string> #include <string> #include <vector> #include <vector> #include <base/files/file_path.h> #include <base/files/file_path.h> #include <base/memory/scoped_ptr.h> #include <base/time/time.h> #include <base/time/time.h> #include <brillo/daemons/dbus_daemon.h> #include <brillo/daemons/dbus_daemon.h> #include <libweaved/command.h> #include <libweaved/command.h> Loading @@ -38,6 +38,7 @@ #include "persistent_integer.h" #include "persistent_integer.h" using chromeos_metrics::PersistentInteger; using chromeos_metrics::PersistentInteger; using std::unique_ptr; class MetricsCollector : public brillo::DBusDaemon { class MetricsCollector : public brillo::DBusDaemon { public: public: Loading Loading @@ -151,18 +152,17 @@ class MetricsCollector : public brillo::DBusDaemon { // Sends a sample representing the number of seconds of active use // Sends a sample representing the number of seconds of active use // for a 24-hour period and reset |use|. // for a 24-hour period and reset |use|. void SendAndResetDailyUseSample( void SendAndResetDailyUseSample(const unique_ptr<PersistentInteger>& use); const scoped_ptr<PersistentInteger>& use); // Sends a sample representing a time interval between two crashes of the // Sends a sample representing a time interval between two crashes of the // same type and reset |interval|. // same type and reset |interval|. void SendAndResetCrashIntervalSample( void SendAndResetCrashIntervalSample( const scoped_ptr<PersistentInteger>& interval); const unique_ptr<PersistentInteger>& interval); // Sends a sample representing a frequency of crashes of some type and reset // Sends a sample representing a frequency of crashes of some type and reset // |frequency|. // |frequency|. void SendAndResetCrashFrequencySample( void SendAndResetCrashFrequencySample( const scoped_ptr<PersistentInteger>& frequency); const unique_ptr<PersistentInteger>& frequency); // Initializes vm and disk stats reporting. // Initializes vm and disk stats reporting. void StatsReporterInit(); void StatsReporterInit(); Loading Loading @@ -241,36 +241,36 @@ class MetricsCollector : public brillo::DBusDaemon { base::TimeDelta latest_cpu_use_microseconds_; base::TimeDelta latest_cpu_use_microseconds_; // Persistent values and accumulators for crash statistics. // Persistent values and accumulators for crash statistics. scoped_ptr<PersistentInteger> daily_cycle_; unique_ptr<PersistentInteger> daily_cycle_; scoped_ptr<PersistentInteger> weekly_cycle_; unique_ptr<PersistentInteger> weekly_cycle_; scoped_ptr<PersistentInteger> version_cycle_; unique_ptr<PersistentInteger> version_cycle_; // Active use accumulated in a day. // Active use accumulated in a day. scoped_ptr<PersistentInteger> daily_active_use_; unique_ptr<PersistentInteger> daily_active_use_; // Active use accumulated since the latest version update. // Active use accumulated since the latest version update. scoped_ptr<PersistentInteger> version_cumulative_active_use_; unique_ptr<PersistentInteger> version_cumulative_active_use_; // The CPU time accumulator. This contains the CPU time, in milliseconds, // The CPU time accumulator. This contains the CPU time, in milliseconds, // used by the system since the most recent OS version update. // used by the system since the most recent OS version update. scoped_ptr<PersistentInteger> version_cumulative_cpu_use_; unique_ptr<PersistentInteger> version_cumulative_cpu_use_; scoped_ptr<PersistentInteger> user_crash_interval_; unique_ptr<PersistentInteger> user_crash_interval_; scoped_ptr<PersistentInteger> kernel_crash_interval_; unique_ptr<PersistentInteger> kernel_crash_interval_; scoped_ptr<PersistentInteger> unclean_shutdown_interval_; unique_ptr<PersistentInteger> unclean_shutdown_interval_; scoped_ptr<PersistentInteger> any_crashes_daily_count_; unique_ptr<PersistentInteger> any_crashes_daily_count_; scoped_ptr<PersistentInteger> any_crashes_weekly_count_; unique_ptr<PersistentInteger> any_crashes_weekly_count_; scoped_ptr<PersistentInteger> user_crashes_daily_count_; unique_ptr<PersistentInteger> user_crashes_daily_count_; scoped_ptr<PersistentInteger> user_crashes_weekly_count_; unique_ptr<PersistentInteger> user_crashes_weekly_count_; scoped_ptr<PersistentInteger> kernel_crashes_daily_count_; unique_ptr<PersistentInteger> kernel_crashes_daily_count_; scoped_ptr<PersistentInteger> kernel_crashes_weekly_count_; unique_ptr<PersistentInteger> kernel_crashes_weekly_count_; scoped_ptr<PersistentInteger> kernel_crashes_version_count_; unique_ptr<PersistentInteger> kernel_crashes_version_count_; scoped_ptr<PersistentInteger> unclean_shutdowns_daily_count_; unique_ptr<PersistentInteger> unclean_shutdowns_daily_count_; scoped_ptr<PersistentInteger> unclean_shutdowns_weekly_count_; unique_ptr<PersistentInteger> unclean_shutdowns_weekly_count_; scoped_ptr<CpuUsageCollector> cpu_usage_collector_; unique_ptr<CpuUsageCollector> cpu_usage_collector_; scoped_ptr<DiskUsageCollector> disk_usage_collector_; unique_ptr<DiskUsageCollector> disk_usage_collector_; scoped_ptr<AveragedStatisticsCollector> averaged_stats_collector_; unique_ptr<AveragedStatisticsCollector> averaged_stats_collector_; std::unique_ptr<weaved::Device> device_; std::unique_ptr<weaved::Device> device_; }; }; Loading
metricsd/persistent_integer_test.cc +3 −2 Original line number Original line Diff line number Diff line Loading @@ -14,12 +14,13 @@ * limitations under the License. * limitations under the License. */ */ #include <gtest/gtest.h> #include <memory> #include <base/compiler_specific.h> #include <base/compiler_specific.h> #include <base/files/file_enumerator.h> #include <base/files/file_enumerator.h> #include <base/files/file_util.h> #include <base/files/file_util.h> #include <base/files/scoped_temp_dir.h> #include <base/files/scoped_temp_dir.h> #include <gtest/gtest.h> #include "persistent_integer.h" #include "persistent_integer.h" Loading @@ -38,7 +39,7 @@ class PersistentIntegerTest : public testing::Test { }; }; TEST_F(PersistentIntegerTest, BasicChecks) { TEST_F(PersistentIntegerTest, BasicChecks) { scoped_ptr<PersistentInteger> pi( std::unique_ptr<PersistentInteger> pi( new PersistentInteger(kBackingFileName, temp_dir_.path())); new PersistentInteger(kBackingFileName, temp_dir_.path())); // Test initialization. // Test initialization. Loading