update_engine: Replace scoped_refptr with shared_ptr in update_manager
It seems like scoped_refptr was a substitute for shared_ptr before
chromium was on C++11:
https://www.chromium.org/developers/smart-pointer-guidelines
But that is not the case anymore as we are already on C++14. So just
replace it in update_manager with shared_ptr.
There is still another use case of it for keeping dbus connections but
that can't easily be changed because brillo::DBusConnection is still
using scoped_refptr.
BUG=chromium:994048
TEST=FEATURES=test emerge update_engine
Change-Id: I1fab0408399d678d2851731aea40fc02be459295
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/1755262
Reviewed-by: Jae Hoon Kim <kimjae@chromium.org>
Reviewed-by: Sen Jiang <senj@chromium.org>
Tested-by: Amin Hassani <ahassani@chromium.org>
Commit-Queue: Amin Hassani <ahassani@chromium.org>
diff --git a/update_manager/evaluation_context_unittest.cc b/update_manager/evaluation_context_unittest.cc
index 151b0b5..a50defd 100644
--- a/update_manager/evaluation_context_unittest.cc
+++ b/update_manager/evaluation_context_unittest.cc
@@ -39,6 +39,7 @@
using brillo::MessageLoopRunMaxIterations;
using brillo::MessageLoopRunUntil;
using chromeos_update_engine::FakeClock;
+using std::shared_ptr;
using std::string;
using std::unique_ptr;
using testing::_;
@@ -59,14 +60,14 @@
}
template <typename T>
-void ReadVar(scoped_refptr<EvaluationContext> ec, Variable<T>* var) {
+void ReadVar(shared_ptr<EvaluationContext> ec, Variable<T>* var) {
ec->GetValue(var);
}
// Runs |evaluation|; if the value pointed by |count_p| is greater than zero,
// decrement it and schedule a reevaluation; otherwise, writes true to |done_p|.
void EvaluateRepeatedly(Closure evaluation,
- scoped_refptr<EvaluationContext> ec,
+ shared_ptr<EvaluationContext> ec,
int* count_p,
bool* done_p) {
evaluation.Run();
@@ -92,11 +93,11 @@
fake_clock_.SetMonotonicTime(Time::FromTimeT(1240428300));
// Mar 2, 2006 1:23:45 UTC.
fake_clock_.SetWallclockTime(Time::FromTimeT(1141262625));
- eval_ctx_ = new EvaluationContext(
+ eval_ctx_.reset(new EvaluationContext(
&fake_clock_,
default_timeout_,
default_timeout_,
- unique_ptr<base::Callback<void(EvaluationContext*)>>(nullptr));
+ unique_ptr<base::Callback<void(EvaluationContext*)>>(nullptr)));
}
void TearDown() override {
@@ -126,7 +127,7 @@
brillo::FakeMessageLoop loop_{nullptr};
FakeClock fake_clock_;
- scoped_refptr<EvaluationContext> eval_ctx_;
+ shared_ptr<EvaluationContext> eval_ctx_;
// FakeVariables used for testing the EvaluationContext. These are required
// here to prevent them from going away *before* the EvaluationContext under