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

Side by Side Diff: base/prefs/pref_service.cc

Issue 1479473002: base: Use std::move() instead of Pass() for real movable types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: basepass: missing-include Created 5 years 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
« no previous file with comments | « base/prefs/pref_member.cc ('k') | base/prefs/pref_service_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/prefs/pref_service.h" 5 #include "base/prefs/pref_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
11 #include "base/location.h" 12 #include "base/location.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
14 #include "base/prefs/default_pref_store.h" 15 #include "base/prefs/default_pref_store.h"
15 #include "base/prefs/pref_notifier_impl.h" 16 #include "base/prefs/pref_notifier_impl.h"
16 #include "base/prefs/pref_registry.h" 17 #include "base/prefs/pref_registry.h"
17 #include "base/prefs/pref_value_store.h" 18 #include "base/prefs/pref_value_store.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 const Preference* pref = FindPreference(path); 191 const Preference* pref = FindPreference(path);
191 return pref && !pref->IsDefaultValue(); 192 return pref && !pref->IsDefaultValue();
192 } 193 }
193 194
194 scoped_ptr<base::DictionaryValue> PrefService::GetPreferenceValues() const { 195 scoped_ptr<base::DictionaryValue> PrefService::GetPreferenceValues() const {
195 DCHECK(CalledOnValidThread()); 196 DCHECK(CalledOnValidThread());
196 scoped_ptr<base::DictionaryValue> out(new base::DictionaryValue); 197 scoped_ptr<base::DictionaryValue> out(new base::DictionaryValue);
197 for (const auto& it : *pref_registry_) { 198 for (const auto& it : *pref_registry_) {
198 out->Set(it.first, GetPreferenceValue(it.first)->CreateDeepCopy()); 199 out->Set(it.first, GetPreferenceValue(it.first)->CreateDeepCopy());
199 } 200 }
200 return out.Pass(); 201 return out;
201 } 202 }
202 203
203 scoped_ptr<base::DictionaryValue> PrefService::GetPreferenceValuesOmitDefaults() 204 scoped_ptr<base::DictionaryValue> PrefService::GetPreferenceValuesOmitDefaults()
204 const { 205 const {
205 DCHECK(CalledOnValidThread()); 206 DCHECK(CalledOnValidThread());
206 scoped_ptr<base::DictionaryValue> out(new base::DictionaryValue); 207 scoped_ptr<base::DictionaryValue> out(new base::DictionaryValue);
207 for (const auto& it : *pref_registry_) { 208 for (const auto& it : *pref_registry_) {
208 const Preference* pref = FindPreference(it.first); 209 const Preference* pref = FindPreference(it.first);
209 if (pref->IsDefaultValue()) 210 if (pref->IsDefaultValue())
210 continue; 211 continue;
211 out->Set(it.first, pref->GetValue()->CreateDeepCopy()); 212 out->Set(it.first, pref->GetValue()->CreateDeepCopy());
212 } 213 }
213 return out.Pass(); 214 return out;
214 } 215 }
215 216
216 scoped_ptr<base::DictionaryValue> 217 scoped_ptr<base::DictionaryValue>
217 PrefService::GetPreferenceValuesWithoutPathExpansion() const { 218 PrefService::GetPreferenceValuesWithoutPathExpansion() const {
218 DCHECK(CalledOnValidThread()); 219 DCHECK(CalledOnValidThread());
219 scoped_ptr<base::DictionaryValue> out(new base::DictionaryValue); 220 scoped_ptr<base::DictionaryValue> out(new base::DictionaryValue);
220 for (const auto& it : *pref_registry_) { 221 for (const auto& it : *pref_registry_) {
221 const base::Value* value = GetPreferenceValue(it.first); 222 const base::Value* value = GetPreferenceValue(it.first);
222 DCHECK(value); 223 DCHECK(value);
223 out->SetWithoutPathExpansion(it.first, value->CreateDeepCopy()); 224 out->SetWithoutPathExpansion(it.first, value->CreateDeepCopy());
224 } 225 }
225 return out.Pass(); 226 return out;
226 } 227 }
227 228
228 const PrefService::Preference* PrefService::FindPreference( 229 const PrefService::Preference* PrefService::FindPreference(
229 const std::string& pref_name) const { 230 const std::string& pref_name) const {
230 DCHECK(CalledOnValidThread()); 231 DCHECK(CalledOnValidThread());
231 PreferenceMap::iterator it = prefs_map_.find(pref_name); 232 PreferenceMap::iterator it = prefs_map_.find(pref_name);
232 if (it != prefs_map_.end()) 233 if (it != prefs_map_.end())
233 return &(it->second); 234 return &(it->second);
234 const base::Value* default_value = NULL; 235 const base::Value* default_value = NULL;
235 if (!pref_registry_->defaults()->GetValue(pref_name, &default_value)) 236 if (!pref_registry_->defaults()->GetValue(pref_name, &default_value))
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 NOTREACHED() << "Trying to write an unregistered pref: " << path; 493 NOTREACHED() << "Trying to write an unregistered pref: " << path;
493 return; 494 return;
494 } 495 }
495 if (pref->GetType() != new_value->GetType()) { 496 if (pref->GetType() != new_value->GetType()) {
496 NOTREACHED() << "Trying to set pref " << path 497 NOTREACHED() << "Trying to set pref " << path
497 << " of type " << pref->GetType() 498 << " of type " << pref->GetType()
498 << " to value of type " << new_value->GetType(); 499 << " to value of type " << new_value->GetType();
499 return; 500 return;
500 } 501 }
501 502
502 user_pref_store_->SetValue(path, owned_value.Pass(), GetWriteFlags(pref)); 503 user_pref_store_->SetValue(path, std::move(owned_value), GetWriteFlags(pref));
503 } 504 }
504 505
505 void PrefService::UpdateCommandLinePrefStore(PrefStore* command_line_store) { 506 void PrefService::UpdateCommandLinePrefStore(PrefStore* command_line_store) {
506 pref_value_store_->UpdateCommandLinePrefStore(command_line_store); 507 pref_value_store_->UpdateCommandLinePrefStore(command_line_store);
507 } 508 }
508 509
509 /////////////////////////////////////////////////////////////////////////////// 510 ///////////////////////////////////////////////////////////////////////////////
510 // PrefService::Preference 511 // PrefService::Preference
511 512
512 PrefService::Preference::Preference(const PrefService* service, 513 PrefService::Preference::Preference(const PrefService* service,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 DCHECK(found_value->IsType(default_type)); 607 DCHECK(found_value->IsType(default_type));
607 return found_value; 608 return found_value;
608 } else { 609 } else {
609 // Every registered preference has at least a default value. 610 // Every registered preference has at least a default value.
610 NOTREACHED() << "no valid value found for registered pref " << path; 611 NOTREACHED() << "no valid value found for registered pref " << path;
611 } 612 }
612 } 613 }
613 614
614 return NULL; 615 return NULL;
615 } 616 }
OLDNEW
« no previous file with comments | « base/prefs/pref_member.cc ('k') | base/prefs/pref_service_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698