| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_value_map.h" | 5 #include "base/prefs/pref_value_map.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 12 #include "base/values.h" | 13 #include "base/values.h" |
| 13 | 14 |
| 14 PrefValueMap::PrefValueMap() {} | 15 PrefValueMap::PrefValueMap() {} |
| 15 | 16 |
| 16 PrefValueMap::~PrefValueMap() {} | 17 PrefValueMap::~PrefValueMap() {} |
| 17 | 18 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 33 } | 34 } |
| 34 | 35 |
| 35 bool PrefValueMap::SetValue(const std::string& key, | 36 bool PrefValueMap::SetValue(const std::string& key, |
| 36 scoped_ptr<base::Value> value) { | 37 scoped_ptr<base::Value> value) { |
| 37 DCHECK(value); | 38 DCHECK(value); |
| 38 | 39 |
| 39 base::Value* old_value = prefs_.get(key); | 40 base::Value* old_value = prefs_.get(key); |
| 40 if (old_value && value->Equals(old_value)) | 41 if (old_value && value->Equals(old_value)) |
| 41 return false; | 42 return false; |
| 42 | 43 |
| 43 prefs_.set(key, value.Pass()); | 44 prefs_.set(key, std::move(value)); |
| 44 return true; | 45 return true; |
| 45 } | 46 } |
| 46 | 47 |
| 47 bool PrefValueMap::RemoveValue(const std::string& key) { | 48 bool PrefValueMap::RemoveValue(const std::string& key) { |
| 48 return prefs_.erase(key) != 0; | 49 return prefs_.erase(key) != 0; |
| 49 } | 50 } |
| 50 | 51 |
| 51 void PrefValueMap::Clear() { | 52 void PrefValueMap::Clear() { |
| 52 prefs_.clear(); | 53 prefs_.clear(); |
| 53 } | 54 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 ++other_pref; | 135 ++other_pref; |
| 135 } | 136 } |
| 136 } | 137 } |
| 137 | 138 |
| 138 // Add the remaining entries. | 139 // Add the remaining entries. |
| 139 for ( ; this_pref != this_prefs.end(); ++this_pref) | 140 for ( ; this_pref != this_prefs.end(); ++this_pref) |
| 140 differing_keys->push_back(this_pref->first); | 141 differing_keys->push_back(this_pref->first); |
| 141 for ( ; other_pref != other_prefs.end(); ++other_pref) | 142 for ( ; other_pref != other_prefs.end(); ++other_pref) |
| 142 differing_keys->push_back(other_pref->first); | 143 differing_keys->push_back(other_pref->first); |
| 143 } | 144 } |
| OLD | NEW |