OLD | NEW |
---|---|
(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 "services/preferences/public/interfaces/preferences.mojom.h" | |
14 #include "services/preferences/public/interfaces/tracked_preference_validation_d elegate.mojom.h" | |
15 | |
16 namespace base { | |
17 class Value; | |
18 } | |
19 | |
20 namespace prefs { | |
21 | |
22 class UserPrefs : public mojom::PersistentPrefStoreConnector, | |
tibell
2017/03/10 02:18:27
Sorry to be a pain, but I think it would be nice t
Sam McNally
2017/03/10 02:43:25
Done.
| |
23 public PrefStore::Observer { | |
24 public: | |
25 UserPrefs(scoped_refptr<PersistentPrefStore> backing_pref_store, | |
26 mojom::TrackedPreferenceValidationDelegatePtr validation_delegate); | |
27 | |
28 ~UserPrefs() override; | |
29 | |
30 // mojom::PersistentPrefStoreConnector override: | |
31 void Connect(const ConnectCallback& callback) override; | |
32 | |
33 private: | |
34 class Connection; | |
35 | |
36 void SetValue(const std::string& key, | |
37 std::unique_ptr<base::Value> value, | |
38 uint32_t flags); | |
39 | |
40 void CommitPendingWrite(); | |
41 void SchedulePendingLossyWrites(); | |
42 void ClearMutableValues(); | |
43 | |
44 // PrefStore::Observer: | |
45 void OnPrefValueChanged(const std::string& key) override; | |
46 void OnInitializationCompleted(bool succeeded) override; | |
47 | |
48 void CallConnectCallback( | |
49 const mojom::PersistentPrefStoreConnector::ConnectCallback& callback); | |
50 void OnConnectionError(Connection* connection); | |
51 | |
52 scoped_refptr<PersistentPrefStore> backing_pref_store_; | |
53 mojom::TrackedPreferenceValidationDelegatePtr validation_delegate_; | |
54 | |
55 bool initializing_ = false; | |
56 std::vector<ConnectCallback> pending_connect_callbacks_; | |
57 | |
58 std::unordered_map<Connection*, std::unique_ptr<Connection>> connections_; | |
tibell
2017/03/10 02:18:27
Could this just be set<std::unique_ptr<Connection>
Sam McNally
2017/03/10 02:43:25
Lookup by unique_ptr is inefficient.
| |
59 | |
60 DISALLOW_COPY_AND_ASSIGN(UserPrefs); | |
61 }; | |
62 | |
63 } // namespace prefs | |
64 | |
65 #endif // SERVICES_PREFERENCES_USER_PREFS_H_ | |
OLD | NEW |