Merge "metricsd: Replace scoped_ptr with unique_ptr." am: c947a13772
am: b9e0742ef5
* commit 'b9e0742ef569369936cd42e99468b28843c1c30c':
metricsd: Replace scoped_ptr with unique_ptr.
diff --git a/metricsd/collectors/averaged_statistics_collector_test.cc b/metricsd/collectors/averaged_statistics_collector_test.cc
index 9c97f00..68f9f2f 100644
--- a/metricsd/collectors/averaged_statistics_collector_test.cc
+++ b/metricsd/collectors/averaged_statistics_collector_test.cc
@@ -16,11 +16,12 @@
#include "averaged_statistics_collector.h"
+#include <memory>
+
#include <inttypes.h>
#include <base/files/file_util.h>
#include <base/files/scoped_temp_dir.h>
-#include <base/memory/scoped_ptr.h>
#include <base/strings/stringprintf.h>
#include <gtest/gtest.h>
@@ -62,7 +63,7 @@
}
// Collector used for tests.
- scoped_ptr<AveragedStatisticsCollector> collector_;
+ std::unique_ptr<AveragedStatisticsCollector> collector_;
// Temporary directory used for tests.
base::ScopedTempDir temp_dir_;
diff --git a/metricsd/include/metrics/timer.h b/metricsd/include/metrics/timer.h
index b36ffff..c1b8ede 100644
--- a/metricsd/include/metrics/timer.h
+++ b/metricsd/include/metrics/timer.h
@@ -19,10 +19,10 @@
#ifndef METRICS_TIMER_H_
#define METRICS_TIMER_H_
+#include <memory>
#include <string>
#include <base/macros.h>
-#include <base/memory/scoped_ptr.h>
#include <base/time/time.h>
#include <gtest/gtest_prod.h> // for FRIEND_TEST
@@ -121,7 +121,7 @@
TimerState timer_state_;
// Wrapper for the calls to the system clock.
- scoped_ptr<ClockWrapper> clock_wrapper_;
+ std::unique_ptr<ClockWrapper> clock_wrapper_;
DISALLOW_COPY_AND_ASSIGN(Timer);
};
diff --git a/metricsd/metrics_collector.cc b/metricsd/metrics_collector.cc
index e9edf2e..a5daab5 100644
--- a/metricsd/metrics_collector.cc
+++ b/metricsd/metrics_collector.cc
@@ -19,6 +19,8 @@
#include <sysexits.h>
#include <time.h>
+#include <memory>
+
#include <base/bind.h>
#include <base/files/file_path.h>
#include <base/files/file_util.h>
@@ -665,7 +667,7 @@
}
void MetricsCollector::SendAndResetDailyUseSample(
- const scoped_ptr<PersistentInteger>& use) {
+ const unique_ptr<PersistentInteger>& use) {
SendSample(use->Name(),
use->GetAndClear(),
1, // value of first bucket
@@ -674,7 +676,7 @@
}
void MetricsCollector::SendAndResetCrashIntervalSample(
- const scoped_ptr<PersistentInteger>& interval) {
+ const unique_ptr<PersistentInteger>& interval) {
SendSample(interval->Name(),
interval->GetAndClear(),
1, // value of first bucket
@@ -683,7 +685,7 @@
}
void MetricsCollector::SendAndResetCrashFrequencySample(
- const scoped_ptr<PersistentInteger>& frequency) {
+ const unique_ptr<PersistentInteger>& frequency) {
SendSample(frequency->Name(),
frequency->GetAndClear(),
1, // value of first bucket
diff --git a/metricsd/metrics_collector.h b/metricsd/metrics_collector.h
index 422ed7c..45ef63d 100644
--- a/metricsd/metrics_collector.h
+++ b/metricsd/metrics_collector.h
@@ -20,11 +20,11 @@
#include <stdint.h>
#include <map>
+#include <memory>
#include <string>
#include <vector>
#include <base/files/file_path.h>
-#include <base/memory/scoped_ptr.h>
#include <base/time/time.h>
#include <brillo/daemons/dbus_daemon.h>
#include <libweaved/command.h>
@@ -38,6 +38,7 @@
#include "persistent_integer.h"
using chromeos_metrics::PersistentInteger;
+using std::unique_ptr;
class MetricsCollector : public brillo::DBusDaemon {
public:
@@ -151,18 +152,17 @@
// Sends a sample representing the number of seconds of active use
// for a 24-hour period and reset |use|.
- void SendAndResetDailyUseSample(
- const scoped_ptr<PersistentInteger>& use);
+ void SendAndResetDailyUseSample(const unique_ptr<PersistentInteger>& use);
// Sends a sample representing a time interval between two crashes of the
// same type and reset |interval|.
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
// |frequency|.
void SendAndResetCrashFrequencySample(
- const scoped_ptr<PersistentInteger>& frequency);
+ const unique_ptr<PersistentInteger>& frequency);
// Initializes vm and disk stats reporting.
void StatsReporterInit();
@@ -241,36 +241,36 @@
base::TimeDelta latest_cpu_use_microseconds_;
// Persistent values and accumulators for crash statistics.
- scoped_ptr<PersistentInteger> daily_cycle_;
- scoped_ptr<PersistentInteger> weekly_cycle_;
- scoped_ptr<PersistentInteger> version_cycle_;
+ unique_ptr<PersistentInteger> daily_cycle_;
+ unique_ptr<PersistentInteger> weekly_cycle_;
+ unique_ptr<PersistentInteger> version_cycle_;
// 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.
- 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,
// 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_;
- scoped_ptr<PersistentInteger> kernel_crash_interval_;
- scoped_ptr<PersistentInteger> unclean_shutdown_interval_;
+ unique_ptr<PersistentInteger> user_crash_interval_;
+ unique_ptr<PersistentInteger> kernel_crash_interval_;
+ unique_ptr<PersistentInteger> unclean_shutdown_interval_;
- scoped_ptr<PersistentInteger> any_crashes_daily_count_;
- scoped_ptr<PersistentInteger> any_crashes_weekly_count_;
- scoped_ptr<PersistentInteger> user_crashes_daily_count_;
- scoped_ptr<PersistentInteger> user_crashes_weekly_count_;
- scoped_ptr<PersistentInteger> kernel_crashes_daily_count_;
- scoped_ptr<PersistentInteger> kernel_crashes_weekly_count_;
- scoped_ptr<PersistentInteger> kernel_crashes_version_count_;
- scoped_ptr<PersistentInteger> unclean_shutdowns_daily_count_;
- scoped_ptr<PersistentInteger> unclean_shutdowns_weekly_count_;
+ unique_ptr<PersistentInteger> any_crashes_daily_count_;
+ unique_ptr<PersistentInteger> any_crashes_weekly_count_;
+ unique_ptr<PersistentInteger> user_crashes_daily_count_;
+ unique_ptr<PersistentInteger> user_crashes_weekly_count_;
+ unique_ptr<PersistentInteger> kernel_crashes_daily_count_;
+ unique_ptr<PersistentInteger> kernel_crashes_weekly_count_;
+ unique_ptr<PersistentInteger> kernel_crashes_version_count_;
+ unique_ptr<PersistentInteger> unclean_shutdowns_daily_count_;
+ unique_ptr<PersistentInteger> unclean_shutdowns_weekly_count_;
- scoped_ptr<CpuUsageCollector> cpu_usage_collector_;
- scoped_ptr<DiskUsageCollector> disk_usage_collector_;
- scoped_ptr<AveragedStatisticsCollector> averaged_stats_collector_;
+ unique_ptr<CpuUsageCollector> cpu_usage_collector_;
+ unique_ptr<DiskUsageCollector> disk_usage_collector_;
+ unique_ptr<AveragedStatisticsCollector> averaged_stats_collector_;
std::unique_ptr<weaved::Device> device_;
};
diff --git a/metricsd/persistent_integer_test.cc b/metricsd/persistent_integer_test.cc
index 55d6cbc..bf76261 100644
--- a/metricsd/persistent_integer_test.cc
+++ b/metricsd/persistent_integer_test.cc
@@ -14,12 +14,13 @@
* limitations under the License.
*/
-#include <gtest/gtest.h>
+#include <memory>
#include <base/compiler_specific.h>
#include <base/files/file_enumerator.h>
#include <base/files/file_util.h>
#include <base/files/scoped_temp_dir.h>
+#include <gtest/gtest.h>
#include "persistent_integer.h"
@@ -38,7 +39,7 @@
};
TEST_F(PersistentIntegerTest, BasicChecks) {
- scoped_ptr<PersistentInteger> pi(
+ std::unique_ptr<PersistentInteger> pi(
new PersistentInteger(kBackingFileName, temp_dir_.path()));
// Test initialization.
diff --git a/metricsd/timer.cc b/metricsd/timer.cc
index 0c2c119..06fc336 100644
--- a/metricsd/timer.cc
+++ b/metricsd/timer.cc
@@ -18,8 +18,6 @@
#include <string>
-#include <base/memory/scoped_ptr.h>
-
#include "metrics/metrics_library.h"
namespace chromeos_metrics {
diff --git a/metricsd/timer_test.cc b/metricsd/timer_test.cc
index bc7a2a1..7a67e11 100644
--- a/metricsd/timer_test.cc
+++ b/metricsd/timer_test.cc
@@ -16,9 +16,9 @@
#include <stdint.h>
-#include <base/memory/scoped_ptr.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
+#include <memory>
#include "metrics/metrics_library_mock.h"
#include "metrics/timer.h"
@@ -61,7 +61,7 @@
virtual void TearDown() {}
Timer timer_;
- scoped_ptr<ClockWrapperMock> clock_wrapper_mock_;
+ std::unique_ptr<ClockWrapperMock> clock_wrapper_mock_;
base::TimeTicks stime, etime, stime2, etime2, stime3, etime3;
};
@@ -436,7 +436,7 @@
TimerReporter timer_reporter_;
MetricsLibraryMock lib_;
- scoped_ptr<ClockWrapperMock> clock_wrapper_mock_;
+ std::unique_ptr<ClockWrapperMock> clock_wrapper_mock_;
base::TimeTicks stime, etime;
};
diff --git a/metricsd/uploader/system_profile_cache.h b/metricsd/uploader/system_profile_cache.h
index 0a21ad4..f9c484c 100644
--- a/metricsd/uploader/system_profile_cache.h
+++ b/metricsd/uploader/system_profile_cache.h
@@ -19,12 +19,12 @@
#include <stdint.h>
+#include <memory>
#include <string>
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
#include "base/gtest_prod_util.h"
-#include "base/memory/scoped_ptr.h"
#include "persistent_integer.h"
#include "uploader/proto/system_profile.pb.h"
#include "uploader/system_profile_setter.h"
@@ -80,7 +80,7 @@
bool initialized_;
bool testing_;
base::FilePath metrics_directory_;
- scoped_ptr<chromeos_metrics::PersistentInteger> session_id_;
+ std::unique_ptr<chromeos_metrics::PersistentInteger> session_id_;
SystemProfile profile_;
};
diff --git a/metricsd/uploader/upload_service.cc b/metricsd/uploader/upload_service.cc
index ea8427a..2fb30c3 100644
--- a/metricsd/uploader/upload_service.cc
+++ b/metricsd/uploader/upload_service.cc
@@ -18,6 +18,7 @@
#include <sysexits.h>
+#include <memory>
#include <string>
#include <base/bind.h>
@@ -169,7 +170,7 @@
if (!current_log_)
return;
- scoped_ptr<MetricsLog> staged_log;
+ std::unique_ptr<MetricsLog> staged_log;
staged_log.swap(current_log_);
staged_log->CloseLog();
if (!staged_log->PopulateSystemProfile(system_profile_setter_.get())) {
diff --git a/metricsd/uploader/upload_service.h b/metricsd/uploader/upload_service.h
index fe064b8..1d36121 100644
--- a/metricsd/uploader/upload_service.h
+++ b/metricsd/uploader/upload_service.h
@@ -17,6 +17,7 @@
#ifndef METRICS_UPLOADER_UPLOAD_SERVICE_H_
#define METRICS_UPLOADER_UPLOAD_SERVICE_H_
+#include <memory>
#include <string>
#include <base/metrics/histogram_base.h>
@@ -141,11 +142,11 @@
// Returns the current log. If there is no current log, creates it first.
MetricsLog* GetOrCreateCurrentLog();
- scoped_ptr<SystemProfileSetter> system_profile_setter_;
+ std::unique_ptr<SystemProfileSetter> system_profile_setter_;
base::HistogramSnapshotManager histogram_snapshot_manager_;
- scoped_ptr<Sender> sender_;
+ std::unique_ptr<Sender> sender_;
chromeos_metrics::PersistentInteger failed_upload_count_;
- scoped_ptr<MetricsLog> current_log_;
+ std::unique_ptr<MetricsLog> current_log_;
std::shared_ptr<CrashCounters> counters_;
base::TimeDelta upload_interval_;
diff --git a/metricsd/uploader/upload_service_test.cc b/metricsd/uploader/upload_service_test.cc
index 0e2ba8f..ec507e8 100644
--- a/metricsd/uploader/upload_service_test.cc
+++ b/metricsd/uploader/upload_service_test.cc
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <gtest/gtest.h>
+#include <memory>
#include <base/at_exit.h>
#include <base/files/file_util.h>
@@ -23,6 +23,7 @@
#include <base/metrics/sparse_histogram.h>
#include <base/metrics/statistics_recorder.h>
#include <base/sys_info.h>
+#include <gtest/gtest.h>
#include "constants.h"
#include "persistent_integer.h"
@@ -86,15 +87,15 @@
}
const metrics::SystemProfileProto_Stability GetCurrentStability() {
- EXPECT_TRUE(upload_service_->current_log_);
+ EXPECT_TRUE(upload_service_->current_log_.get());
return upload_service_->current_log_->uma_proto()->system_profile().stability();
}
base::ScopedTempDir dir_;
- scoped_ptr<UploadService> upload_service_;
+ std::unique_ptr<UploadService> upload_service_;
- scoped_ptr<base::AtExitManager> exit_manager_;
+ std::unique_ptr<base::AtExitManager> exit_manager_;
std::shared_ptr<CrashCounters> counters_;
};