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/update_manager.h b/update_manager/update_manager.h
index 732175f..8ab61d0 100644
--- a/update_manager/update_manager.h
+++ b/update_manager/update_manager.h
@@ -22,7 +22,6 @@
#include <string>
#include <base/callback.h>
-#include <base/memory/ref_counted.h>
#include <base/time/time.h>
#include "update_engine/common/clock_interface.h"
@@ -33,15 +32,6 @@
namespace chromeos_update_manager {
-// Comparator for scoped_refptr objects.
-template <typename T>
-struct ScopedRefPtrLess {
- bool operator()(const scoped_refptr<T>& first,
- const scoped_refptr<T>& second) const {
- return first.get() < second.get();
- }
-};
-
// Please do not move this class into a new file for simplicity.
// This pure virtual class is purely created for purpose of testing. The reason
// was that |UpdateManager|'s member functions are templatized, which does not
@@ -152,7 +142,7 @@
// the evaluation will be re-scheduled to be called later.
template <typename R, typename... Args>
void OnPolicyReadyToEvaluate(
- scoped_refptr<EvaluationContext> ec,
+ std::shared_ptr<EvaluationContext> ec,
base::Callback<void(EvalStatus status, const R& result)> callback,
EvalStatus (Policy::*policy_method)(
EvaluationContext*, State*, std::string*, R*, Args...) const,
@@ -186,9 +176,7 @@
// destructed; alternatively, when the UpdateManager instance is destroyed, it
// will remove all pending events associated with all outstanding contexts
// (which should, in turn, trigger their destruction).
- std::set<scoped_refptr<EvaluationContext>,
- ScopedRefPtrLess<EvaluationContext>>
- ec_repo_;
+ std::set<std::shared_ptr<EvaluationContext>> ec_repo_;
base::WeakPtrFactory<UpdateManager> weak_ptr_factory_;