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

Side by Side Diff: chrome/browser/chromeos/settings/cros_settings.h

Issue 23514056: Function-type templated CallbackRegistry (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pure merge 2 Created 7 years, 2 months 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 | Annotate | Revision Log
« no previous file with comments | « base/callback_registry_unittest.nc ('k') | chrome/browser/chromeos/settings/cros_settings.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 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_CROS_SETTINGS_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_CROS_SETTINGS_H_
6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_CROS_SETTINGS_H_ 6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_CROS_SETTINGS_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // Helper function for the whitelist op. Implemented here because we will need 87 // Helper function for the whitelist op. Implemented here because we will need
88 // this in a few places. The functions searches for |email| in the pref |path| 88 // this in a few places. The functions searches for |email| in the pref |path|
89 // It respects whitelists so foo@bar.baz will match *@bar.baz too. 89 // It respects whitelists so foo@bar.baz will match *@bar.baz too.
90 bool FindEmailInList(const std::string& path, const std::string& email) const; 90 bool FindEmailInList(const std::string& path, const std::string& email) const;
91 91
92 // Adding/removing of providers. 92 // Adding/removing of providers.
93 bool AddSettingsProvider(CrosSettingsProvider* provider); 93 bool AddSettingsProvider(CrosSettingsProvider* provider);
94 bool RemoveSettingsProvider(CrosSettingsProvider* provider); 94 bool RemoveSettingsProvider(CrosSettingsProvider* provider);
95 95
96 // Add an observer Callback for changes for the given |path|. 96 // Add an observer Callback for changes for the given |path|.
97 typedef base::CallbackRegistry<void>::Subscription ObserverSubscription; 97 typedef base::CallbackRegistry<void(void)>::Subscription ObserverSubscription;
98 scoped_ptr<ObserverSubscription> AddSettingsObserver( 98 scoped_ptr<ObserverSubscription> AddSettingsObserver(
99 const std::string& path, 99 const std::string& path,
100 const base::Closure& callback); 100 const base::Closure& callback);
101 101
102 // Returns the provider that handles settings with the |path| or prefix. 102 // Returns the provider that handles settings with the |path| or prefix.
103 CrosSettingsProvider* GetProvider(const std::string& path) const; 103 CrosSettingsProvider* GetProvider(const std::string& path) const;
104 104
105 private: 105 private:
106 friend class CrosSettingsTest; 106 friend class CrosSettingsTest;
107 107
108 // Fires system setting change callback. 108 // Fires system setting change callback.
109 void FireObservers(const std::string& path); 109 void FireObservers(const std::string& path);
110 110
111 // List of ChromeOS system settings providers. 111 // List of ChromeOS system settings providers.
112 std::vector<CrosSettingsProvider*> providers_; 112 std::vector<CrosSettingsProvider*> providers_;
113 113
114 // A map from settings names to a list of observers. Observers get fired in 114 // A map from settings names to a list of observers. Observers get fired in
115 // the order they are added. 115 // the order they are added.
116 typedef base::hash_map<std::string, base::CallbackRegistry<void>*> 116 typedef base::hash_map<std::string, base::CallbackRegistry<void(void)>*>
117 SettingsObserverMap; 117 SettingsObserverMap;
118 SettingsObserverMap settings_observers_; 118 SettingsObserverMap settings_observers_;
119 119
120 DISALLOW_COPY_AND_ASSIGN(CrosSettings); 120 DISALLOW_COPY_AND_ASSIGN(CrosSettings);
121 }; 121 };
122 122
123 // Helper class for tests. Initializes the CrosSettings singleton on 123 // Helper class for tests. Initializes the CrosSettings singleton on
124 // construction and tears it down again on destruction. 124 // construction and tears it down again on destruction.
125 class ScopedTestCrosSettings { 125 class ScopedTestCrosSettings {
126 public: 126 public:
127 ScopedTestCrosSettings(); 127 ScopedTestCrosSettings();
128 ~ScopedTestCrosSettings(); 128 ~ScopedTestCrosSettings();
129 129
130 private: 130 private:
131 DISALLOW_COPY_AND_ASSIGN(ScopedTestCrosSettings); 131 DISALLOW_COPY_AND_ASSIGN(ScopedTestCrosSettings);
132 }; 132 };
133 133
134 } // namespace chromeos 134 } // namespace chromeos
135 135
136 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_CROS_SETTINGS_H_ 136 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_CROS_SETTINGS_H_
OLDNEW
« no previous file with comments | « base/callback_registry_unittest.nc ('k') | chrome/browser/chromeos/settings/cros_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698