Chromium Code Reviews| 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 f36a595ce840505d948a7f1f091193557f499246..3c30310532848ecef08d89412dd57d4f190c2721 100644 |
| --- a/components/cloud_devices/common/description_items_inl.h |
| +++ b/components/cloud_devices/common/description_items_inl.h |
| @@ -7,6 +7,8 @@ |
| #include <stddef.h> |
| +#include <memory> |
| +#include <utility> |
| #include <vector> |
| #include "base/numerics/safe_conversions.h" |
| @@ -65,9 +67,10 @@ void ListCapability<Option, Traits>::SaveTo( |
| base::ListValue* options_list = |
| description->CreateListItem(Traits::GetCapabilityPath()); |
| for (size_t i = 0; i < options_.size(); ++i) { |
| - base::DictionaryValue* option_value = new base::DictionaryValue; |
| - options_list->Append(option_value); |
| - Traits::Save(options_[i], option_value); |
| + std::unique_ptr<base::DictionaryValue> option_value( |
| + new base::DictionaryValue); |
| + Traits::Save(options_[i], option_value.get()); |
| + options_list->Append(std::move(option_value)); |
|
blundell
2016/08/29 07:39:15
similar question for my own understanding: is the
dcheng
2016/08/30 17:41:55
It is: one way to think of it is move constructors
|
| } |
| } |
| @@ -127,11 +130,12 @@ void SelectionCapability<Option, Traits>::SaveTo( |
| description->CreateItem(Traits::GetCapabilityPath()) |
| ->Set(json::kKeyOption, options_list); |
| for (size_t i = 0; i < options_.size(); ++i) { |
| - base::DictionaryValue* option_value = new base::DictionaryValue; |
| - options_list->Append(option_value); |
| + std::unique_ptr<base::DictionaryValue> option_value( |
| + new base::DictionaryValue); |
| if (base::checked_cast<int>(i) == default_idx_) |
| option_value->SetBoolean(json::kKeyIsDefault, true); |
| - Traits::Save(options_[i], option_value); |
| + Traits::Save(options_[i], option_value.get()); |
| + options_list->Append(std::move(option_value)); |
| } |
| } |