| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/prefs/tracked/pref_service_hash_store_contents.h" | 5 #include "chrome/browser/prefs/tracked/pref_service_hash_store_contents.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_registry_simple.h" | 7 #include "base/prefs/pref_registry_simple.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 // Implements get-or-create of a dictionary value and holds a | 14 // Implements get-or-create of a dictionary value and holds a |
| 15 // DictionaryPrefUpdate. | 15 // DictionaryPrefUpdate. |
| 16 class PrefServiceMutableDictionary | 16 class PrefServiceMutableDictionary |
| 17 : public HashStoreContents::MutableDictionary { | 17 : public HashStoreContents::MutableDictionary { |
| 18 public: | 18 public: |
| 19 // Creates an instance that provides mutable access to a dictionary value | 19 // Creates an instance that provides mutable access to a dictionary value |
| 20 // named |key| that is a child of |kProfilePreferenceHashes| in | 20 // named |key| that is a child of |kProfilePreferenceHashes| in |
| 21 // |prefs|. | 21 // |prefs|. |
| 22 PrefServiceMutableDictionary(const std::string& key, | 22 PrefServiceMutableDictionary(const std::string& key, |
| 23 PrefService* pref_service); | 23 PrefService* pref_service); |
| 24 | 24 |
| 25 // HashStoreContents::MutableDictionary implementation | 25 // HashStoreContents::MutableDictionary implementation |
| 26 virtual base::DictionaryValue* operator->() OVERRIDE; | 26 virtual base::DictionaryValue* operator->() override; |
| 27 | 27 |
| 28 private: | 28 private: |
| 29 const std::string key_; | 29 const std::string key_; |
| 30 DictionaryPrefUpdate update_; | 30 DictionaryPrefUpdate update_; |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 PrefServiceMutableDictionary::PrefServiceMutableDictionary( | 33 PrefServiceMutableDictionary::PrefServiceMutableDictionary( |
| 34 const std::string& key, | 34 const std::string& key, |
| 35 PrefService* pref_service) | 35 PrefService* pref_service) |
| 36 : key_(key), | 36 : key_(key), |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 hash_of_hashes_dict->GetStringWithoutPathExpansion(hash_store_id_, | 137 hash_of_hashes_dict->GetStringWithoutPathExpansion(hash_store_id_, |
| 138 &hash_of_hashes); | 138 &hash_of_hashes); |
| 139 } | 139 } |
| 140 return hash_of_hashes; | 140 return hash_of_hashes; |
| 141 } | 141 } |
| 142 | 142 |
| 143 void PrefServiceHashStoreContents::SetSuperMac(const std::string& super_mac) { | 143 void PrefServiceHashStoreContents::SetSuperMac(const std::string& super_mac) { |
| 144 PrefServiceMutableDictionary(kHashOfHashesDict, pref_service_) | 144 PrefServiceMutableDictionary(kHashOfHashesDict, pref_service_) |
| 145 ->SetStringWithoutPathExpansion(hash_store_id_, super_mac); | 145 ->SetStringWithoutPathExpansion(hash_store_id_, super_mac); |
| 146 } | 146 } |
| OLD | NEW |