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

Side by Side Diff: services/preferences/public/cpp/pref_store_impl.h

Issue 2635153002: Pref service: expose all read-only PrefStores through Mojo (Closed)
Patch Set: Address bauerb's review comments 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SERVICES_PREFERENCES_PUBLIC_CPP_PREF_STORE_IMPL_H_
6 #define SERVICES_PREFERENCES_PUBLIC_CPP_PREF_STORE_IMPL_H_
7
8 #include <vector>
9
10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
12 #include "components/prefs/pref_store.h"
13 #include "components/prefs/pref_value_store.h"
14 #include "mojo/public/cpp/bindings/binding.h"
15 #include "services/preferences/public/interfaces/preferences.mojom.h"
16
17 namespace prefs {
18
19 // Wraps an actual PrefStore implementation and exposes it as a
20 // mojom::PrefStore interface.
21 class PrefStoreImpl : public ::PrefStore::Observer, public mojom::PrefStore {
22 public:
23 PrefStoreImpl(scoped_refptr<::PrefStore> pref_store,
24 mojom::PrefStoreRequest request);
25 ~PrefStoreImpl() override;
26
27 // The created instance is registered in and owned by the
28 // |mojom::PrefStoreRegistry|.
29 static std::unique_ptr<PrefStoreImpl> Create(
30 mojom::PrefStoreRegistryPtr registry_ptr,
31 scoped_refptr<::PrefStore> pref_store,
32 PrefValueStore::PrefStoreType type);
33
34 private:
35 // PrefStore::Observer:
36 void OnPrefValueChanged(const std::string& key) override;
37 void OnInitializationCompleted(bool succeeded) override;
38
39 // prefs::mojom::PrefStore:
40 void AddObserver(const AddObserverCallback& callback) override;
41
42 // The backing store we observer for changes.
43 scoped_refptr<::PrefStore> backing_pref_store_;
44
45 // Observers we notify when |backing_pref_store_| changes.
46 std::vector<mojom::PrefStoreObserverPtr> observers_;
47
48 // True when the |backing_pref_store_| is initialized, either because it was
49 // passed already initialized in the constructor or after
50 // OnInitializationCompleted was called.
51 bool backing_pref_store_initialized_;
52
53 mojo::Binding<mojom::PrefStore> binding_;
54
55 DISALLOW_COPY_AND_ASSIGN(PrefStoreImpl);
56 };
57
58 } // namespace prefs
59
60 #endif // SERVICES_PREFERENCES_PUBLIC_CPP_PREF_STORE_IMPL_H_
OLDNEW
« no previous file with comments | « services/preferences/public/cpp/pref_store_client.cc ('k') | services/preferences/public/cpp/pref_store_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698