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

Side by Side Diff: chrome/browser/prefs/pref_notifier_impl.h

Issue 6894020: Adds async interface method to PersistentPrefStore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 2010->2011 Created 9 years, 7 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 | « chrome/browser/prefs/pref_notifier.h ('k') | chrome/browser/prefs/pref_notifier_impl.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) 2010 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 #ifndef CHROME_BROWSER_PREFS_PREF_NOTIFIER_IMPL_H_ 5 #ifndef CHROME_BROWSER_PREFS_PREF_NOTIFIER_IMPL_H_
6 #define CHROME_BROWSER_PREFS_PREF_NOTIFIER_IMPL_H_ 6 #define CHROME_BROWSER_PREFS_PREF_NOTIFIER_IMPL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/hash_tables.h" 11 #include "base/hash_tables.h"
(...skipping 11 matching lines...) Expand all
23 explicit PrefNotifierImpl(PrefService* pref_service); 23 explicit PrefNotifierImpl(PrefService* pref_service);
24 virtual ~PrefNotifierImpl(); 24 virtual ~PrefNotifierImpl();
25 25
26 // If the pref at the given path changes, we call the observer's Observe 26 // If the pref at the given path changes, we call the observer's Observe
27 // method with PREF_CHANGED. 27 // method with PREF_CHANGED.
28 void AddPrefObserver(const char* path, NotificationObserver* obs); 28 void AddPrefObserver(const char* path, NotificationObserver* obs);
29 void RemovePrefObserver(const char* path, NotificationObserver* obs); 29 void RemovePrefObserver(const char* path, NotificationObserver* obs);
30 30
31 // PrefNotifier overrides. 31 // PrefNotifier overrides.
32 virtual void OnPreferenceChanged(const std::string& pref_name); 32 virtual void OnPreferenceChanged(const std::string& pref_name);
33 virtual void OnInitializationCompleted(); 33 virtual void OnInitializationCompleted(bool succeeded);
34 34
35 protected: 35 protected:
36 // A map from pref names to a list of observers. Observers get fired in the 36 // A map from pref names to a list of observers. Observers get fired in the
37 // order they are added. These should only be accessed externally for unit 37 // order they are added. These should only be accessed externally for unit
38 // testing. 38 // testing.
39 typedef ObserverList<NotificationObserver> NotificationObserverList; 39 typedef ObserverList<NotificationObserver> NotificationObserverList;
40 typedef base::hash_map<std::string, NotificationObserverList*> 40 typedef base::hash_map<std::string, NotificationObserverList*>
41 PrefObserverMap; 41 PrefObserverMap;
42 42
43 const PrefObserverMap* pref_observers() const { return &pref_observers_; } 43 const PrefObserverMap* pref_observers() const { return &pref_observers_; }
44 44
45 private: 45 private:
46 // For the given pref_name, fire any observer of the pref. Virtual so it can 46 // For the given pref_name, fire any observer of the pref. Virtual so it can
47 // be mocked for unit testing. 47 // be mocked for unit testing.
48 virtual void FireObservers(const std::string& path); 48 virtual void FireObservers(const std::string& path);
49 49
50 // Weak reference; the notifier is owned by the PrefService. 50 // Weak reference; the notifier is owned by the PrefService.
51 PrefService* pref_service_; 51 PrefService* pref_service_;
52 52
53 PrefObserverMap pref_observers_; 53 PrefObserverMap pref_observers_;
54 54
55 DISALLOW_COPY_AND_ASSIGN(PrefNotifierImpl); 55 DISALLOW_COPY_AND_ASSIGN(PrefNotifierImpl);
56 }; 56 };
57 57
58 #endif // CHROME_BROWSER_PREFS_PREF_NOTIFIER_IMPL_H_ 58 #endif // CHROME_BROWSER_PREFS_PREF_NOTIFIER_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_notifier.h ('k') | chrome/browser/prefs/pref_notifier_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698