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

Side by Side Diff: components/login/screens/screen_context.cc

Issue 2889163002: Remove raw DictionaryValue::Set in //components (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/login/screens/screen_context.h" 5 #include "components/login/screens/screen_context.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility>
8 9
9 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ptr_util.h"
10 12
11 namespace login { 13 namespace login {
12 14
13 namespace { 15 namespace {
14 16
15 template <typename StringListType> 17 template <typename StringListType>
16 base::ListValue* StringListToListValue(const StringListType& list) { 18 base::ListValue* StringListToListValue(const StringListType& list) {
17 base::ListValue* result = new base::ListValue(); 19 base::ListValue* result = new base::ListValue();
18 for (typename StringListType::const_iterator it = list.begin(); 20 for (typename StringListType::const_iterator it = list.begin();
19 it != list.end(); 21 it != list.end();
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 DCHECK(value); 171 DCHECK(value);
170 std::unique_ptr<base::Value> new_value(value); 172 std::unique_ptr<base::Value> new_value(value);
171 173
172 base::Value* current_value; 174 base::Value* current_value;
173 bool in_storage = storage_.Get(key, &current_value); 175 bool in_storage = storage_.Get(key, &current_value);
174 176
175 // Don't do anything if |storage_| already contains <|key|, |new_value|> pair. 177 // Don't do anything if |storage_| already contains <|key|, |new_value|> pair.
176 if (in_storage && new_value->Equals(current_value)) 178 if (in_storage && new_value->Equals(current_value))
177 return false; 179 return false;
178 180
179 changes_.Set(key, new_value->DeepCopy()); 181 changes_.Set(key, base::MakeUnique<base::Value>(*new_value));
180 storage_.Set(key, new_value.release()); 182 storage_.Set(key, std::move(new_value));
181 return true; 183 return true;
182 } 184 }
183 185
184 } // namespace login 186 } // namespace login
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698