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

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

Issue 2743463002: WIP: Pref service user prefs. (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
(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_USER_PREFS_H_
6 #define SERVICES_PREFERENCES_USER_PREFS_H_
7
8 #include <memory>
9 #include <unordered_map>
10 #include <vector>
11
12 #include "base/macros.h"
13 #include "base/values.h"
14 #include "services/preferences/public/interfaces/preferences.mojom.h"
15 #include "services/preferences/public/interfaces/tracked_preference_validation_d elegate.mojom.h"
16
17 namespace prefs {
18
19 class UserPrefs : public mojom::PersistentPrefStoreConnector,
20 public PrefStore::Observer {
21 public:
22 UserPrefs(scoped_refptr<PersistentPrefStore> backing_pref_store,
23 mojom::TrackedPreferenceValidationDelegatePtr validation_delegate);
24
25 ~UserPrefs() override;
26
27 // mojom::PersistentPrefStoreConnector override:
28 void Connect(const ConnectCallback& callback) override;
29
30 private:
31 class Connection;
32
33 void SetValue(const std::string& key,
34 std::unique_ptr<base::Value> value,
35 uint32_t flags);
36
37 void CommitPendingWrite();
38 void SchedulePendingLossyWrites();
39 void ClearMutableValues();
40
41 // PrefStore::Observer:
42 void OnPrefValueChanged(const std::string& key) override;
43 void OnInitializationCompleted(bool succeeded) override;
44
45 void CallConnectCallback(
46 const mojom::PersistentPrefStoreConnector::ConnectCallback& callback);
47 void OnConnectionError(Connection* connection);
48
49 scoped_refptr<PersistentPrefStore> backing_pref_store_;
50 mojom::TrackedPreferenceValidationDelegatePtr validation_delegate_;
51
52 bool loading_ = false;
53 std::vector<ConnectCallback> connect_callbacks_;
54
55 std::unordered_map<Connection*, std::unique_ptr<Connection>> connections_;
56
57 DISALLOW_COPY_AND_ASSIGN(UserPrefs);
58 };
59
60 } // namespace prefs
61
62 #endif // SERVICES_PREFERENCES_USER_PREFS_H_
OLDNEW
« no previous file with comments | « services/preferences/public/interfaces/preferences.mojom ('k') | services/preferences/user_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698