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

Side by Side Diff: services/preferences/pref_store_manager_impl.h

Issue 2771723002: Pref service: Merge PrefStoreConnector interfaces. (Closed)
Patch Set: Created 3 years, 9 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 SERVICES_PREFERENCES_PREF_STORE_MANAGER_IMPL_H_ 5 #ifndef SERVICES_PREFERENCES_PREF_STORE_MANAGER_IMPL_H_
6 #define SERVICES_PREFERENCES_PREF_STORE_MANAGER_IMPL_H_ 6 #define SERVICES_PREFERENCES_PREF_STORE_MANAGER_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <unordered_map> 10 #include <unordered_map>
(...skipping 17 matching lines...) Expand all
28 28
29 // This class mediates the connection of clients who wants to read preferences 29 // This class mediates the connection of clients who wants to read preferences
30 // and the pref stores that store those preferences. Pref stores use the 30 // and the pref stores that store those preferences. Pref stores use the
31 // |PrefStoreRegistry| interface to register themselves with the manager and 31 // |PrefStoreRegistry| interface to register themselves with the manager and
32 // clients use the |PrefStoreConnector| interface to connect to these stores. 32 // clients use the |PrefStoreConnector| interface to connect to these stores.
33 class PrefStoreManagerImpl 33 class PrefStoreManagerImpl
34 : public mojom::PrefStoreRegistry, 34 : public mojom::PrefStoreRegistry,
35 public mojom::PrefStoreConnector, 35 public mojom::PrefStoreConnector,
36 public service_manager::InterfaceFactory<mojom::PrefStoreConnector>, 36 public service_manager::InterfaceFactory<mojom::PrefStoreConnector>,
37 public service_manager::InterfaceFactory<mojom::PrefStoreRegistry>, 37 public service_manager::InterfaceFactory<mojom::PrefStoreRegistry>,
38 public service_manager::InterfaceFactory<
39 mojom::PersistentPrefStoreConnector>,
40 public mojom::PrefServiceControl, 38 public mojom::PrefServiceControl,
41 public service_manager::InterfaceFactory<mojom::PrefServiceControl>, 39 public service_manager::InterfaceFactory<mojom::PrefServiceControl>,
42 public service_manager::Service { 40 public service_manager::Service {
43 public: 41 public:
44 // Only replies to Connect calls when all |expected_pref_stores| have 42 // Only replies to Connect calls when all |expected_pref_stores| have
45 // registered. 43 // registered.
46 PrefStoreManagerImpl( 44 PrefStoreManagerImpl(
47 std::set<PrefValueStore::PrefStoreType> expected_pref_stores, 45 std::set<PrefValueStore::PrefStoreType> expected_pref_stores,
48 scoped_refptr<base::SequencedWorkerPool> worker_pool); 46 scoped_refptr<base::SequencedWorkerPool> worker_pool);
49 ~PrefStoreManagerImpl() override; 47 ~PrefStoreManagerImpl() override;
(...skipping 10 matching lines...) Expand all
60 void Connect(const ConnectCallback& callback) override; 58 void Connect(const ConnectCallback& callback) override;
61 59
62 // service_manager::InterfaceFactory<PrefStoreConnector>: 60 // service_manager::InterfaceFactory<PrefStoreConnector>:
63 void Create(const service_manager::Identity& remote_identity, 61 void Create(const service_manager::Identity& remote_identity,
64 prefs::mojom::PrefStoreConnectorRequest request) override; 62 prefs::mojom::PrefStoreConnectorRequest request) override;
65 63
66 // service_manager::InterfaceFactory<PrefStoreRegistry>: 64 // service_manager::InterfaceFactory<PrefStoreRegistry>:
67 void Create(const service_manager::Identity& remote_identity, 65 void Create(const service_manager::Identity& remote_identity,
68 prefs::mojom::PrefStoreRegistryRequest request) override; 66 prefs::mojom::PrefStoreRegistryRequest request) override;
69 67
70 // service_manager::InterfaceFactory<PersistentPrefStoreConnector>:
71 void Create(
72 const service_manager::Identity& remote_identity,
73 prefs::mojom::PersistentPrefStoreConnectorRequest request) override;
74
75 // service_manager::InterfaceFactory<PrefServiceControl>: 68 // service_manager::InterfaceFactory<PrefServiceControl>:
76 void Create(const service_manager::Identity& remote_identity, 69 void Create(const service_manager::Identity& remote_identity,
77 prefs::mojom::PrefServiceControlRequest request) override; 70 prefs::mojom::PrefServiceControlRequest request) override;
78 71
79 // PrefServiceControl: 72 // PrefServiceControl:
80 void Init(mojom::PersistentPrefStoreConfigurationPtr configuration) override; 73 void Init(mojom::PersistentPrefStoreConfigurationPtr configuration) override;
81 74
82 // service_manager::Service: 75 // service_manager::Service:
83 void OnStart() override; 76 void OnStart() override;
84 bool OnConnect(const service_manager::ServiceInfo& remote_info, 77 bool OnConnect(const service_manager::ServiceInfo& remote_info,
85 service_manager::InterfaceRegistry* registry) override; 78 service_manager::InterfaceRegistry* registry) override;
86 79
87 // Called when a PrefStore previously registered using |Register| disconnects. 80 // Called when a PrefStore previously registered using |Register| disconnects.
88 void OnPrefStoreDisconnect(PrefValueStore::PrefStoreType type); 81 void OnPrefStoreDisconnect(PrefValueStore::PrefStoreType type);
89 82
90 // Have all the expected PrefStores connected? 83 // Have all the expected PrefStores connected?
91 bool AllConnected() const; 84 bool AllConnected() const;
92 85
86 void ProcessPendingConnects();
87
88 void ConnectImpl(const ConnectCallback& callback);
89
90 void OnPersistentPrefStoreReady();
91
93 // PrefStores that need to register before replying to any Connect calls. 92 // PrefStores that need to register before replying to any Connect calls.
94 std::set<PrefValueStore::PrefStoreType> expected_pref_stores_; 93 std::set<PrefValueStore::PrefStoreType> expected_pref_stores_;
95 94
96 // Registered pref stores. 95 // Registered pref stores.
97 PrefStorePtrs pref_store_ptrs_; 96 PrefStorePtrs pref_store_ptrs_;
98 97
99 // We hold on to the connection request callbacks until all expected 98 // We hold on to the connection request callbacks until all expected
100 // PrefStores have registered. 99 // PrefStores have registered.
101 std::vector<ConnectCallback> pending_callbacks_; 100 std::vector<ConnectCallback> pending_callbacks_;
102 101
103 mojo::BindingSet<mojom::PrefStoreConnector> connector_bindings_; 102 mojo::BindingSet<mojom::PrefStoreConnector> connector_bindings_;
104 mojo::BindingSet<mojom::PrefStoreRegistry> registry_bindings_; 103 mojo::BindingSet<mojom::PrefStoreRegistry> registry_bindings_;
105 std::unique_ptr<PersistentPrefStoreImpl> persistent_pref_store_; 104 std::unique_ptr<PersistentPrefStoreImpl> persistent_pref_store_;
106 mojo::BindingSet<mojom::PersistentPrefStoreConnector>
107 persistent_pref_store_bindings_;
108 mojo::Binding<mojom::PrefServiceControl> init_binding_; 105 mojo::Binding<mojom::PrefServiceControl> init_binding_;
109 106
110 // Requests made to connect to the service before it has been initialized.
111 // These will be handled when initialization completes.
112 std::vector<mojom::PersistentPrefStoreConnectorRequest>
113 pending_persistent_pref_store_requests_;
114
115 scoped_refptr<base::SequencedWorkerPool> worker_pool_; 107 scoped_refptr<base::SequencedWorkerPool> worker_pool_;
116 108
117 DISALLOW_COPY_AND_ASSIGN(PrefStoreManagerImpl); 109 DISALLOW_COPY_AND_ASSIGN(PrefStoreManagerImpl);
118 }; 110 };
119 111
120 } // namespace prefs 112 } // namespace prefs
121 113
122 #endif // SERVICES_PREFERENCES_PREF_STORE_MANAGER_IMPL_H_ 114 #endif // SERVICES_PREFERENCES_PREF_STORE_MANAGER_IMPL_H_
OLDNEW
« no previous file with comments | « services/preferences/pref_service_factory_unittest.cc ('k') | services/preferences/pref_store_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698