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

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

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
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 "chrome/browser/chromeos/settings/cros_settings.h" 5 #include "chrome/browser/chromeos/settings/cros_settings.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 DCHECK(!callback.is_null()); 265 DCHECK(!callback.is_null());
266 DCHECK(CalledOnValidThread()); 266 DCHECK(CalledOnValidThread());
267 267
268 if (!GetProvider(path)) { 268 if (!GetProvider(path)) {
269 NOTREACHED() << "Trying to add an observer for an unregistered setting: " 269 NOTREACHED() << "Trying to add an observer for an unregistered setting: "
270 << path; 270 << path;
271 return scoped_ptr<CrosSettings::ObserverSubscription>(); 271 return scoped_ptr<CrosSettings::ObserverSubscription>();
272 } 272 }
273 273
274 // Get the callback registry associated with the path. 274 // Get the callback registry associated with the path.
275 base::CallbackRegistry<void>* registry = NULL; 275 base::CallbackRegistry<void(void)>* registry = NULL;
276 SettingsObserverMap::iterator observer_iterator = 276 SettingsObserverMap::iterator observer_iterator =
277 settings_observers_.find(path); 277 settings_observers_.find(path);
278 if (observer_iterator == settings_observers_.end()) { 278 if (observer_iterator == settings_observers_.end()) {
279 registry = new base::CallbackRegistry<void>; 279 registry = new base::CallbackRegistry<void(void)>;
280 settings_observers_[path] = registry; 280 settings_observers_[path] = registry;
281 } else { 281 } else {
282 registry = observer_iterator->second; 282 registry = observer_iterator->second;
283 } 283 }
284 284
285 return registry->Add(callback); 285 return registry->Add(callback);
286 } 286 }
287 287
288 CrosSettingsProvider* CrosSettings::GetProvider( 288 CrosSettingsProvider* CrosSettings::GetProvider(
289 const std::string& path) const { 289 const std::string& path) const {
(...skipping 16 matching lines...) Expand all
306 306
307 ScopedTestCrosSettings::ScopedTestCrosSettings() { 307 ScopedTestCrosSettings::ScopedTestCrosSettings() {
308 CrosSettings::Initialize(); 308 CrosSettings::Initialize();
309 } 309 }
310 310
311 ScopedTestCrosSettings::~ScopedTestCrosSettings() { 311 ScopedTestCrosSettings::~ScopedTestCrosSettings() {
312 CrosSettings::Shutdown(); 312 CrosSettings::Shutdown();
313 } 313 }
314 314
315 } // namespace chromeos 315 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/settings/cros_settings.h ('k') | chrome/browser/ui/prefs/prefs_tab_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698