OLD | NEW |
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_SPEECH_CHROME_SPEECH_RECOGNITION_PREFERENCES_H_ | 5 #ifndef CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_PREFERENCES_H_ |
6 #define CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_PREFERENCES_H_ | 6 #define CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_PREFERENCES_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
13 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
14 #include "chrome/browser/api/prefs/pref_change_registrar.h" | 14 #include "chrome/browser/api/prefs/pref_change_registrar.h" |
15 #include "chrome/browser/profiles/profile_keyed_service.h" | 15 #include "chrome/browser/profiles/profile_keyed_service.h" |
16 #include "chrome/browser/profiles/profile_keyed_service_factory.h" | 16 #include "chrome/browser/profiles/profile_keyed_service_factory.h" |
17 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
18 #include "content/public/browser/speech_recognition_preferences.h" | 18 #include "content/public/browser/speech_recognition_preferences.h" |
19 | 19 |
20 class PrefService; | 20 class PrefService; |
21 | 21 |
22 namespace base{ | 22 namespace base { |
23 class ListValue; | 23 class ListValue; |
24 } | 24 } |
25 | 25 |
26 // Utility class that handles persistent storage of speech recognition | 26 // Utility class that handles persistent storage of speech recognition |
27 // preferences. Instances of this class must be obtained exclusively through the | 27 // preferences. Instances of this class must be obtained exclusively through the |
28 // method ChromeSpeechRecognitionPreferences::GetForProfile(...), so that | 28 // method ChromeSpeechRecognitionPreferences::GetForProfile(...), so that |
29 // preferences are handled within the Profile (if not NULL). The internal | 29 // preferences are handled within the Profile (if not NULL). The internal |
30 // factory class also handles ownership and lifetime of the | 30 // factory class also handles ownership and lifetime of the |
31 // ChromeSpeechRecognitionPreferences instances (through the inner Service | 31 // ChromeSpeechRecognitionPreferences instances (through the inner Service |
32 // class), allowing them to be used in a detached mode (no persistent storage) | 32 // class), allowing them to be used in a detached mode (no persistent storage) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 private: | 72 private: |
73 friend struct DefaultSingletonTraits<Factory>; | 73 friend struct DefaultSingletonTraits<Factory>; |
74 | 74 |
75 Factory(); | 75 Factory(); |
76 virtual ~Factory(); | 76 virtual ~Factory(); |
77 | 77 |
78 // ProfileKeyedServiceFactory methods: | 78 // ProfileKeyedServiceFactory methods: |
79 virtual ProfileKeyedService* BuildServiceInstanceFor(Profile* profile) | 79 virtual ProfileKeyedService* BuildServiceInstanceFor(Profile* profile) |
80 const OVERRIDE; | 80 const OVERRIDE; |
81 virtual void RegisterUserPrefs(PrefService* prefs) OVERRIDE; | 81 virtual void RegisterUserPrefs(PrefService* prefs) OVERRIDE; |
82 virtual bool ServiceRedirectedInIncognito() OVERRIDE; | 82 virtual bool ServiceRedirectedInIncognito() const OVERRIDE; |
83 virtual bool ServiceIsNULLWhileTesting() OVERRIDE; | 83 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE; |
84 virtual bool ServiceIsCreatedWithProfile() OVERRIDE; | 84 virtual bool ServiceIsCreatedWithProfile() const OVERRIDE; |
85 | 85 |
86 DISALLOW_COPY_AND_ASSIGN(Factory); | 86 DISALLOW_COPY_AND_ASSIGN(Factory); |
87 }; | 87 }; |
88 | 88 |
89 // This wrapper handles the binding between ChromeSpeechRecognitionPreferences | 89 // This wrapper handles the binding between ChromeSpeechRecognitionPreferences |
90 // instances (which can have a longer lifetime, since they are refcounted) and | 90 // instances (which can have a longer lifetime, since they are refcounted) and |
91 // ProfileKeyedService (which lifetime depends on the Profile service). Upon | 91 // ProfileKeyedService (which lifetime depends on the Profile service). Upon |
92 // profile shutdown, the ChromeSpeechRecognitionPreferences instance is | 92 // profile shutdown, the ChromeSpeechRecognitionPreferences instance is |
93 // detached from profile, meaning that after that point its clients can still | 93 // detached from profile, meaning that after that point its clients can still |
94 // use it, but preferences will no longer be kept in sync with the profile. | 94 // use it, but preferences will no longer be kept in sync with the profile. |
(...skipping 25 matching lines...) Expand all Loading... |
120 scoped_ptr<base::ListValue> notifications_shown_; | 120 scoped_ptr<base::ListValue> notifications_shown_; |
121 | 121 |
122 // Lock used to ensure exclusive access to preference variables that are | 122 // Lock used to ensure exclusive access to preference variables that are |
123 // accessed by both threads (note: mutable is required to keep getters const). | 123 // accessed by both threads (note: mutable is required to keep getters const). |
124 mutable base::Lock preferences_lock_; | 124 mutable base::Lock preferences_lock_; |
125 | 125 |
126 DISALLOW_COPY_AND_ASSIGN(ChromeSpeechRecognitionPreferences); | 126 DISALLOW_COPY_AND_ASSIGN(ChromeSpeechRecognitionPreferences); |
127 }; | 127 }; |
128 | 128 |
129 #endif // CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_PREFERENCES_H_ | 129 #endif // CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_PREFERENCES_H_ |
OLD | NEW |