update_engine: migrate usage of deprecated base::Value methods
Methods provided by base::Value that consume or produce unmanaged raw
pointers have been deprecated and will be eventually removed from
libchrome. This CL migrates the usage of these deprecated methods in the
update-engine code to the equivalent methods that use std::unique_ptr.
BUG=chromium:689697
TEST=Run unit tests.
Reviewed-on: https://chromium-review.googlesource.com/438840
Commit-Ready: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Dan Erat <derat@chromium.org>
(cherry picked from commit 42458e2b6df997d0fcb5ccefb0cd3d40220143eb)
Change-Id: Ic4c3b0691db08cd5ca7b1cedfe6510b4081c3cda
diff --git a/update_manager/evaluation_context.cc b/update_manager/evaluation_context.cc
index 63f7d9b..98238f2 100644
--- a/update_manager/evaluation_context.cc
+++ b/update_manager/evaluation_context.cc
@@ -19,10 +19,12 @@
#include <algorithm>
#include <memory>
#include <string>
+#include <utility>
#include <base/bind.h>
#include <base/json/json_writer.h>
#include <base/location.h>
+#include <base/memory/ptr_util.h>
#include <base/strings/string_util.h>
#include <base/values.h>
@@ -227,13 +229,13 @@
}
string EvaluationContext::DumpContext() const {
- base::DictionaryValue* variables = new base::DictionaryValue();
+ auto variables = base::MakeUnique<base::DictionaryValue>();
for (auto& it : value_cache_) {
variables->SetString(it.first->GetName(), it.second.ToString());
}
base::DictionaryValue value;
- value.Set("variables", variables); // Adopts |variables|.
+ value.Set("variables", std::move(variables));
value.SetString(
"evaluation_start_wallclock",
chromeos_update_engine::utils::ToString(evaluation_start_wallclock_));