| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 // A helper class that assists preferences in firing notifications when lists | 5 // A helper class that assists preferences in firing notifications when lists |
| 6 // or dictionaries are changed. | 6 // or dictionaries are changed. |
| 7 | 7 |
| 8 #ifndef BASE_PREFS_SCOPED_USER_PREF_UPDATE_H_ | 8 #ifndef COMPONENTS_PREFS_SCOPED_USER_PREF_UPDATE_H_ |
| 9 #define BASE_PREFS_SCOPED_USER_PREF_UPDATE_H_ | 9 #define COMPONENTS_PREFS_SCOPED_USER_PREF_UPDATE_H_ |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "components/prefs/base_prefs_export.h" | 16 #include "components/prefs/base_prefs_export.h" |
| 17 #include "components/prefs/pref_service.h" | 17 #include "components/prefs/pref_service.h" |
| 18 | 18 |
| 19 class PrefService; | 19 class PrefService; |
| 20 | 20 |
| 21 namespace base { | 21 namespace base { |
| 22 class DictionaryValue; | 22 class DictionaryValue; |
| 23 class ListValue; | 23 class ListValue; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace subtle { | 26 namespace subtle { |
| 27 | 27 |
| 28 // Base class for ScopedUserPrefUpdateTemplate that contains the parts | 28 // Base class for ScopedUserPrefUpdateTemplate that contains the parts |
| 29 // that do not depend on ScopedUserPrefUpdateTemplate's template parameter. | 29 // that do not depend on ScopedUserPrefUpdateTemplate's template parameter. |
| 30 // | 30 // |
| 31 // We need this base class mostly for making it a friend of PrefService | 31 // We need this base class mostly for making it a friend of PrefService |
| 32 // and getting access to PrefService::GetMutableUserPref and | 32 // and getting access to PrefService::GetMutableUserPref and |
| 33 // PrefService::ReportUserPrefChanged. | 33 // PrefService::ReportUserPrefChanged. |
| 34 class BASE_PREFS_EXPORT ScopedUserPrefUpdateBase : public base::NonThreadSafe { | 34 class COMPONENTS_PREFS_EXPORT ScopedUserPrefUpdateBase |
| 35 : public base::NonThreadSafe { |
| 35 protected: | 36 protected: |
| 36 ScopedUserPrefUpdateBase(PrefService* service, const std::string& path); | 37 ScopedUserPrefUpdateBase(PrefService* service, const std::string& path); |
| 37 | 38 |
| 38 // Calls Notify(). | 39 // Calls Notify(). |
| 39 ~ScopedUserPrefUpdateBase(); | 40 ~ScopedUserPrefUpdateBase(); |
| 40 | 41 |
| 41 // Sets |value_| to |service_|->GetMutableUserPref and returns it. | 42 // Sets |value_| to |service_|->GetMutableUserPref and returns it. |
| 42 base::Value* GetValueOfType(base::Value::Type type); | 43 base::Value* GetValueOfType(base::Value::Type type); |
| 43 | 44 |
| 44 private: | 45 private: |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 private: | 99 private: |
| 99 DISALLOW_COPY_AND_ASSIGN(ScopedUserPrefUpdate); | 100 DISALLOW_COPY_AND_ASSIGN(ScopedUserPrefUpdate); |
| 100 }; | 101 }; |
| 101 | 102 |
| 102 typedef ScopedUserPrefUpdate<base::DictionaryValue, | 103 typedef ScopedUserPrefUpdate<base::DictionaryValue, |
| 103 base::Value::TYPE_DICTIONARY> | 104 base::Value::TYPE_DICTIONARY> |
| 104 DictionaryPrefUpdate; | 105 DictionaryPrefUpdate; |
| 105 typedef ScopedUserPrefUpdate<base::ListValue, base::Value::TYPE_LIST> | 106 typedef ScopedUserPrefUpdate<base::ListValue, base::Value::TYPE_LIST> |
| 106 ListPrefUpdate; | 107 ListPrefUpdate; |
| 107 | 108 |
| 108 #endif // BASE_PREFS_SCOPED_USER_PREF_UPDATE_H_ | 109 #endif // COMPONENTS_PREFS_SCOPED_USER_PREF_UPDATE_H_ |
| OLD | NEW |