OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_PREFS_PREFERENCES_CONNECTION_MANAGER_H_ | |
6 #define CHROME_BROWSER_PREFS_PREFERENCES_CONNECTION_MANAGER_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/macros.h" | |
11 #include "components/keyed_service/core/keyed_service_shutdown_notifier.h" | |
12 #include "mojo/public/cpp/bindings/strong_binding.h" | |
13 #include "services/preferences/public/interfaces/preferences.mojom.h" | |
14 | |
15 namespace chrome { | |
sky
2016/12/06 23:37:37
I wouldn't put this in any namespace (see threads
jonross
2016/12/07 15:46:39
I had missed those threads. Removed the namespace.
| |
16 | |
17 // Handles all incoming prefs::mojom::PreferenceManagerRequest, providing a | |
18 // separate PreferencesManager per connection request. | |
19 // | |
20 // Additionally monitors system shutdown to clean up connections to PrefService. | |
21 // | |
22 // TODO(jonross): Observe profile switching and update PreferenceManager | |
23 // connections. | |
24 class PreferencesConnectionManager { | |
sky
2016/12/06 23:37:37
Is the plan that this class is used from places ot
jonross
2016/12/07 00:31:28
This would come down to the timing of a few things
sky
2016/12/07 18:05:16
If long term we're going to go with this, then lea
| |
25 public: | |
26 PreferencesConnectionManager(); | |
27 ~PreferencesConnectionManager(); | |
28 | |
29 // Creates a new PreferencesManager and binds it to |request|. | |
30 void ProcessRequest(prefs::mojom::PreferencesManagerRequest request); | |
31 | |
32 private: | |
33 // KeyedServiceShutdownNotifier::Subscription callback. Used to cleanup when | |
34 // the active PrefService is being destroyed. | |
35 void OnProfileDestroyed(); | |
36 | |
37 // Bindings that automatically cleanup during connection errors. | |
38 std::vector<mojo::StrongBindingPtr<prefs::mojom::PreferencesManager>> | |
39 bindings_; | |
40 | |
41 // Observes shutdown, when PrefService is being destroyed. | |
42 std::unique_ptr<KeyedServiceShutdownNotifier::Subscription> | |
43 profile_shutdown_notification_; | |
44 | |
45 DISALLOW_COPY_AND_ASSIGN(PreferencesConnectionManager); | |
46 }; | |
47 | |
48 } // namespace chrome | |
49 | |
50 #endif // CHROME_BROWSER_PREFS_PREFERENCES_CONNECTION_MANAGER_H_ | |
OLD | NEW |