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

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

Issue 2759413002: Move PrefStoreManagerImpl into //services/preferences. (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_PUBLIC_CPP_PREF_STORE_MANAGER_IMPL_H_ 5 #ifndef SERVICES_PREFERENCES_PREF_STORE_MANAGER_IMPL_H_
6 #define SERVICES_PREFERENCES_PUBLIC_CPP_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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "components/prefs/pref_value_store.h" 16 #include "components/prefs/pref_value_store.h"
(...skipping 17 matching lines...) Expand all
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< 38 public service_manager::InterfaceFactory<
39 mojom::PersistentPrefStoreConnector>, 39 mojom::PersistentPrefStoreConnector>,
40 public mojom::PrefServiceControl, 40 public mojom::PrefServiceControl,
41 public service_manager::InterfaceFactory<mojom::PrefServiceControl>, 41 public service_manager::InterfaceFactory<mojom::PrefServiceControl>,
42 public service_manager::Service { 42 public service_manager::Service {
43 public: 43 public:
44 using PrefStoreTypes = std::set<PrefValueStore::PrefStoreType>; 44 using PrefStoreTypes = std::set<PrefValueStore::PrefStoreType>;
tibell 2017/03/21 22:06:33 Delete this as well?
Sam McNally 2017/03/21 23:10:51 Done.
45 45
46 // Only replies to Connect calls when all |expected_pref_stores| have 46 // Only replies to Connect calls when all |expected_pref_stores| have
47 // registered. 47 // registered.
48 PrefStoreManagerImpl(PrefStoreTypes expected_pref_stores, 48 PrefStoreManagerImpl(
49 scoped_refptr<base::SequencedWorkerPool> worker_pool); 49 std::set<PrefValueStore::PrefStoreType> expected_pref_stores,
50 scoped_refptr<base::SequencedWorkerPool> worker_pool);
50 ~PrefStoreManagerImpl() override; 51 ~PrefStoreManagerImpl() override;
51 52
52 private: 53 private:
53 using PrefStorePtrs = 54 using PrefStorePtrs =
54 std::unordered_map<PrefValueStore::PrefStoreType, mojom::PrefStorePtr>; 55 std::unordered_map<PrefValueStore::PrefStoreType, mojom::PrefStorePtr>;
55 56
56 // mojom::PrefStoreRegistry: 57 // mojom::PrefStoreRegistry:
57 void Register(PrefValueStore::PrefStoreType type, 58 void Register(PrefValueStore::PrefStoreType type,
58 mojom::PrefStorePtr pref_store_ptr) override; 59 mojom::PrefStorePtr pref_store_ptr) override;
59 60
(...skipping 25 matching lines...) Expand all
85 bool OnConnect(const service_manager::ServiceInfo& remote_info, 86 bool OnConnect(const service_manager::ServiceInfo& remote_info,
86 service_manager::InterfaceRegistry* registry) override; 87 service_manager::InterfaceRegistry* registry) override;
87 88
88 // Called when a PrefStore previously registered using |Register| disconnects. 89 // Called when a PrefStore previously registered using |Register| disconnects.
89 void OnPrefStoreDisconnect(PrefValueStore::PrefStoreType type); 90 void OnPrefStoreDisconnect(PrefValueStore::PrefStoreType type);
90 91
91 // Have all the expected PrefStores connected? 92 // Have all the expected PrefStores connected?
92 bool AllConnected() const; 93 bool AllConnected() const;
93 94
94 // PrefStores that need to register before replying to any Connect calls. 95 // PrefStores that need to register before replying to any Connect calls.
95 PrefStoreTypes expected_pref_stores_; 96 std::set<PrefValueStore::PrefStoreType> expected_pref_stores_;
96 97
97 // Registered pref stores. 98 // Registered pref stores.
98 PrefStorePtrs pref_store_ptrs_; 99 PrefStorePtrs pref_store_ptrs_;
99 100
100 mojo::BindingSet<mojom::PrefStoreConnector> connector_bindings_; 101 mojo::BindingSet<mojom::PrefStoreConnector> connector_bindings_;
101 mojo::BindingSet<mojom::PrefStoreRegistry> registry_bindings_; 102 mojo::BindingSet<mojom::PrefStoreRegistry> registry_bindings_;
102 std::unique_ptr<PersistentPrefStoreImpl> persistent_pref_store_; 103 std::unique_ptr<PersistentPrefStoreImpl> persistent_pref_store_;
103 mojo::BindingSet<mojom::PersistentPrefStoreConnector> 104 mojo::BindingSet<mojom::PersistentPrefStoreConnector>
104 persistent_pref_store_bindings_; 105 persistent_pref_store_bindings_;
105 mojo::Binding<mojom::PrefServiceControl> init_binding_; 106 mojo::Binding<mojom::PrefServiceControl> init_binding_;
106 107
107 // Requests made to connect to the service before it has been initialized. 108 // Requests made to connect to the service before it has been initialized.
108 // These will be handled when initialization completes. 109 // These will be handled when initialization completes.
109 std::vector<mojom::PersistentPrefStoreConnectorRequest> 110 std::vector<mojom::PersistentPrefStoreConnectorRequest>
110 pending_persistent_pref_store_requests_; 111 pending_persistent_pref_store_requests_;
111 112
112 scoped_refptr<base::SequencedWorkerPool> worker_pool_; 113 scoped_refptr<base::SequencedWorkerPool> worker_pool_;
113 114
114 // We hold on to the connection request callbacks until all expected 115 // We hold on to the connection request callbacks until all expected
115 // PrefStores have registered. 116 // PrefStores have registered.
116 std::vector<ConnectCallback> pending_callbacks_; 117 std::vector<ConnectCallback> pending_callbacks_;
117 118
118 DISALLOW_COPY_AND_ASSIGN(PrefStoreManagerImpl); 119 DISALLOW_COPY_AND_ASSIGN(PrefStoreManagerImpl);
119 }; 120 };
120 121
121 } // namespace prefs 122 } // namespace prefs
122 123
123 #endif // SERVICES_PREFERENCES_PUBLIC_CPP_PREF_STORE_MANAGER_IMPL_H_ 124 #endif // SERVICES_PREFERENCES_PREF_STORE_MANAGER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698