Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Unified Diff: components/cloud_devices/common/description_items_inl.h

Issue 2911033002: Remove raw base::DictionaryValue::Set (Closed)
Patch Set: Proper Windows Fix Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/network/onc/onc_validator.cc ('k') | components/policy/core/common/mac_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cloud_devices/common/description_items_inl.h
diff --git a/components/cloud_devices/common/description_items_inl.h b/components/cloud_devices/common/description_items_inl.h
index 3c30310532848ecef08d89412dd57d4f190c2721..02fc0237253df3d06fcf702d4411012d887845e2 100644
--- a/components/cloud_devices/common/description_items_inl.h
+++ b/components/cloud_devices/common/description_items_inl.h
@@ -11,7 +11,9 @@
#include <utility>
#include <vector>
+#include "base/memory/ptr_util.h"
#include "base/numerics/safe_conversions.h"
+#include "base/values.h"
#include "components/cloud_devices/common/description_items.h"
// Implementation of templates defined in header file.
@@ -126,17 +128,16 @@ template <class Option, class Traits>
void SelectionCapability<Option, Traits>::SaveTo(
CloudDeviceDescription* description) const {
DCHECK(IsValid());
- base::ListValue* options_list = new base::ListValue;
- description->CreateItem(Traits::GetCapabilityPath())
- ->Set(json::kKeyOption, options_list);
+ auto options_list = base::MakeUnique<base::ListValue>();
for (size_t i = 0; i < options_.size(); ++i) {
- std::unique_ptr<base::DictionaryValue> option_value(
- new base::DictionaryValue);
+ auto option_value = base::MakeUnique<base::DictionaryValue>();
if (base::checked_cast<int>(i) == default_idx_)
option_value->SetBoolean(json::kKeyIsDefault, true);
Traits::Save(options_[i], option_value.get());
options_list->Append(std::move(option_value));
}
+ description->CreateItem(Traits::GetCapabilityPath())
+ ->Set(json::kKeyOption, std::move(options_list));
}
template <class Traits>
« no previous file with comments | « chromeos/network/onc/onc_validator.cc ('k') | components/policy/core/common/mac_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698