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

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

Issue 2743563003: Pref service: add persistent pref store frontend and backend. (Closed)
Patch Set: rebase 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_PERSISTENT_PREF_STORE_CLIENT_H_
6 #define SERVICES_PREFERENCES_PUBLIC_CPP_PERSISTENT_PREF_STORE_CLIENT_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/macros.h"
12 #include "components/prefs/persistent_pref_store.h"
13 #include "services/preferences/public/cpp/pref_store_client_mixin.h"
14 #include "services/preferences/public/interfaces/preferences.mojom.h"
15
16 namespace base {
17 class Value;
18 class DictionaryValue;
19 }
20
21 namespace prefs {
22
23 // An implementation of PersistentPrefStore backed by a
24 // mojom::PersistentPrefStore and a mojom::PrefStoreObserver.
25 class PersistentPrefStoreClient
26 : public PrefStoreClientMixin<PersistentPrefStore> {
27 public:
28 explicit PersistentPrefStoreClient(
29 mojom::PersistentPrefStoreConnectorPtr connector);
30
31 // WriteablePrefStore:
32 void SetValue(const std::string& key,
33 std::unique_ptr<base::Value> value,
34 uint32_t flags) override;
35 void RemoveValue(const std::string& key, uint32_t flags) override;
36 bool GetMutableValue(const std::string& key, base::Value** result) override;
37 void ReportValueChanged(const std::string& key, uint32_t flags) override;
38 void SetValueSilently(const std::string& key,
39 std::unique_ptr<base::Value> value,
40 uint32_t flags) override;
41
42 // PersistentPrefStore:
43 bool ReadOnly() const override;
44 PrefReadError GetReadError() const override;
45 PrefReadError ReadPrefs() override;
46 void ReadPrefsAsync(ReadErrorDelegate* error_delegate) override;
47 void CommitPendingWrite() override;
48 void SchedulePendingLossyWrites() override;
49 void ClearMutableValues() override;
50
51 protected:
52 // base::RefCounted<PrefStore>:
53 ~PersistentPrefStoreClient() override;
54
55 private:
56 void OnCreateComplete(PrefReadError read_error,
57 bool read_only,
58 std::unique_ptr<base::DictionaryValue> cached_prefs,
59 mojom::PersistentPrefStorePtr pref_store,
60 mojom::PrefStoreObserverRequest observer_request);
61
62 mojom::PersistentPrefStoreConnectorPtr connector_;
63 bool read_only_ = false;
64 PrefReadError read_error_ = PersistentPrefStore::PREF_READ_ERROR_NONE;
65 mojom::PersistentPrefStorePtr pref_store_;
66
67 std::unique_ptr<ReadErrorDelegate> error_delegate_;
68
69 DISALLOW_COPY_AND_ASSIGN(PersistentPrefStoreClient);
70 };
71
72 } // namespace prefs
73
74 #endif // SERVICES_PREFERENCES_PUBLIC_CPP_PERSISTENT_PREF_STORE_CLIENT_H_
OLDNEW
« no previous file with comments | « services/preferences/public/cpp/BUILD.gn ('k') | services/preferences/public/cpp/persistent_pref_store_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698