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

Side by Side Diff: base/prefs/overlay_user_pref_store.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/json_pref_store_unittest.cc ('k') | base/prefs/pref_member.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/overlay_user_pref_store.h" 5 #include "base/prefs/overlay_user_pref_store.h"
6 6
7 #include <utility>
8
7 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
8 #include "base/values.h" 10 #include "base/values.h"
9 11
10 OverlayUserPrefStore::OverlayUserPrefStore( 12 OverlayUserPrefStore::OverlayUserPrefStore(
11 PersistentPrefStore* underlay) 13 PersistentPrefStore* underlay)
12 : underlay_(underlay) { 14 : underlay_(underlay) {
13 underlay_->AddObserver(this); 15 underlay_->AddObserver(this);
14 } 16 }
15 17
16 bool OverlayUserPrefStore::IsSetInOverlay(const std::string& key) const { 18 bool OverlayUserPrefStore::IsSetInOverlay(const std::string& key) const {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 61
60 *result = underlay_value->DeepCopy(); 62 *result = underlay_value->DeepCopy();
61 overlay_.SetValue(key, make_scoped_ptr(*result)); 63 overlay_.SetValue(key, make_scoped_ptr(*result));
62 return true; 64 return true;
63 } 65 }
64 66
65 void OverlayUserPrefStore::SetValue(const std::string& key, 67 void OverlayUserPrefStore::SetValue(const std::string& key,
66 scoped_ptr<base::Value> value, 68 scoped_ptr<base::Value> value,
67 uint32 flags) { 69 uint32 flags) {
68 if (!ShallBeStoredInOverlay(key)) { 70 if (!ShallBeStoredInOverlay(key)) {
69 underlay_->SetValue(GetUnderlayKey(key), value.Pass(), flags); 71 underlay_->SetValue(GetUnderlayKey(key), std::move(value), flags);
70 return; 72 return;
71 } 73 }
72 74
73 if (overlay_.SetValue(key, value.Pass())) 75 if (overlay_.SetValue(key, std::move(value)))
74 ReportValueChanged(key, flags); 76 ReportValueChanged(key, flags);
75 } 77 }
76 78
77 void OverlayUserPrefStore::SetValueSilently(const std::string& key, 79 void OverlayUserPrefStore::SetValueSilently(const std::string& key,
78 scoped_ptr<base::Value> value, 80 scoped_ptr<base::Value> value,
79 uint32 flags) { 81 uint32 flags) {
80 if (!ShallBeStoredInOverlay(key)) { 82 if (!ShallBeStoredInOverlay(key)) {
81 underlay_->SetValueSilently(GetUnderlayKey(key), value.Pass(), flags); 83 underlay_->SetValueSilently(GetUnderlayKey(key), std::move(value), flags);
82 return; 84 return;
83 } 85 }
84 86
85 overlay_.SetValue(key, value.Pass()); 87 overlay_.SetValue(key, std::move(value));
86 } 88 }
87 89
88 void OverlayUserPrefStore::RemoveValue(const std::string& key, uint32 flags) { 90 void OverlayUserPrefStore::RemoveValue(const std::string& key, uint32 flags) {
89 if (!ShallBeStoredInOverlay(key)) { 91 if (!ShallBeStoredInOverlay(key)) {
90 underlay_->RemoveValue(GetUnderlayKey(key), flags); 92 underlay_->RemoveValue(GetUnderlayKey(key), flags);
91 return; 93 return;
92 } 94 }
93 95
94 if (overlay_.RemoveValue(key)) 96 if (overlay_.RemoveValue(key))
95 ReportValueChanged(key, flags); 97 ReportValueChanged(key, flags);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 NamesMap::const_iterator i = 177 NamesMap::const_iterator i =
176 overlay_to_underlay_names_map_.find(overlay_key); 178 overlay_to_underlay_names_map_.find(overlay_key);
177 return i != overlay_to_underlay_names_map_.end() ? i->second : overlay_key; 179 return i != overlay_to_underlay_names_map_.end() ? i->second : overlay_key;
178 } 180 }
179 181
180 bool OverlayUserPrefStore::ShallBeStoredInOverlay( 182 bool OverlayUserPrefStore::ShallBeStoredInOverlay(
181 const std::string& key) const { 183 const std::string& key) const {
182 return overlay_to_underlay_names_map_.find(key) != 184 return overlay_to_underlay_names_map_.find(key) !=
183 overlay_to_underlay_names_map_.end(); 185 overlay_to_underlay_names_map_.end();
184 } 186 }
OLDNEW
« no previous file with comments | « base/prefs/json_pref_store_unittest.cc ('k') | base/prefs/pref_member.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698