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

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

Issue 2474653003: PreferencesManager (Closed)
Patch Set: Updates 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 // Handles all incoming prefs::mojom::PreferenceManagerRequest, providing a
16 // separate PreferencesManager per connection request.
17 //
18 // Additionally monitors system shutdown to clean up connections to PrefService.
19 //
20 // TODO(jonross): Observe profile switching and update PreferenceManager
21 // connections.
22 class PreferencesConnectionManager {
23 public:
24 PreferencesConnectionManager();
25 ~PreferencesConnectionManager();
26
27 // Creates a new PreferencesManager and binds it to |request|.
28 void ProcessRequest(prefs::mojom::PreferencesManagerRequest request);
29
30 private:
31 // mojo::StrongBinding callback:
32 void OnConnectionError(
33 mojo::StrongBindingPtr<prefs::mojom::PreferencesManager> binding);
34
35 // KeyedServiceShutdownNotifier::Subscription callback. Used to cleanup when
36 // the active PrefService is being destroyed.
37 void OnProfileDestroyed();
38
39 // Bindings that automatically cleanup during connection errors.
40 std::vector<mojo::StrongBindingPtr<prefs::mojom::PreferencesManager>>
41 bindings_;
42
43 // Observes shutdown, when PrefService is being destroyed.
44 std::unique_ptr<KeyedServiceShutdownNotifier::Subscription>
45 profile_shutdown_notification_;
46
47 DISALLOW_COPY_AND_ASSIGN(PreferencesConnectionManager);
48 };
49
50 #endif // CHROME_BROWSER_PREFS_PREFERENCES_CONNECTION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698