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

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

Issue 1918083002: Convert //components/[f-n]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: … Created 4 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>
8
7 #include "base/logging.h" 9 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
9 10
10 namespace login { 11 namespace login {
11 12
12 namespace { 13 namespace {
13 14
14 template <typename StringListType> 15 template <typename StringListType>
15 base::ListValue* StringListToListValue(const StringListType& list) { 16 base::ListValue* StringListToListValue(const StringListType& list) {
16 base::ListValue* result = new base::ListValue(); 17 base::ListValue* result = new base::ListValue();
17 for (typename StringListType::const_iterator it = list.begin(); 18 for (typename StringListType::const_iterator it = list.begin();
18 it != list.end(); 19 it != list.end();
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 return Get<String16List>(key); 117 return Get<String16List>(key);
117 } 118 }
118 119
119 String16List ScreenContext::GetString16List( 120 String16List ScreenContext::GetString16List(
120 const KeyType& key, 121 const KeyType& key,
121 const String16List& default_value) const { 122 const String16List& default_value) const {
122 return Get(key, default_value); 123 return Get(key, default_value);
123 } 124 }
124 125
125 void ScreenContext::CopyFrom(ScreenContext& context) { 126 void ScreenContext::CopyFrom(ScreenContext& context) {
126 scoped_ptr<base::DictionaryValue> storage(context.storage_.DeepCopy()); 127 std::unique_ptr<base::DictionaryValue> storage(context.storage_.DeepCopy());
127 scoped_ptr<base::DictionaryValue> changes(context.changes_.DeepCopy()); 128 std::unique_ptr<base::DictionaryValue> changes(context.changes_.DeepCopy());
128 storage_.Swap(storage.get()); 129 storage_.Swap(storage.get());
129 changes_.Swap(changes.get()); 130 changes_.Swap(changes.get());
130 } 131 }
131 132
132 bool ScreenContext::HasKey(const KeyType& key) const { 133 bool ScreenContext::HasKey(const KeyType& key) const {
133 DCHECK(CalledOnValidThread()); 134 DCHECK(CalledOnValidThread());
134 return storage_.HasKey(key); 135 return storage_.HasKey(key);
135 } 136 }
136 137
137 bool ScreenContext::HasChanges() const { 138 bool ScreenContext::HasChanges() const {
(...skipping 21 matching lines...) Expand all
159 Set(it.key(), it.value().DeepCopy()); 160 Set(it.key(), it.value().DeepCopy());
160 if (keys) 161 if (keys)
161 keys->push_back(it.key()); 162 keys->push_back(it.key());
162 } 163 }
163 changes_.Clear(); 164 changes_.Clear();
164 } 165 }
165 166
166 bool ScreenContext::Set(const KeyType& key, base::Value* value) { 167 bool ScreenContext::Set(const KeyType& key, base::Value* value) {
167 DCHECK(CalledOnValidThread()); 168 DCHECK(CalledOnValidThread());
168 DCHECK(value); 169 DCHECK(value);
169 scoped_ptr<base::Value> new_value(value); 170 std::unique_ptr<base::Value> new_value(value);
170 171
171 base::Value* current_value; 172 base::Value* current_value;
172 bool in_storage = storage_.Get(key, &current_value); 173 bool in_storage = storage_.Get(key, &current_value);
173 174
174 // Don't do anything if |storage_| already contains <|key|, |new_value|> pair. 175 // Don't do anything if |storage_| already contains <|key|, |new_value|> pair.
175 if (in_storage && new_value->Equals(current_value)) 176 if (in_storage && new_value->Equals(current_value))
176 return false; 177 return false;
177 178
178 changes_.Set(key, new_value->DeepCopy()); 179 changes_.Set(key, new_value->DeepCopy());
179 storage_.Set(key, new_value.release()); 180 storage_.Set(key, new_value.release());
180 return true; 181 return true;
181 } 182 }
182 183
183 } // namespace login 184 } // namespace login
OLDNEW
« no previous file with comments | « components/login/screens/screen_context.h ('k') | components/login/screens/screen_context_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698