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

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

Issue 2474653003: PreferencesManager (Closed)
Patch Set: Update mojom to support separate subscriptions Created 4 years 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
OLDNEW
(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 {
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 {
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698