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

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

Issue 2856083002: Pref service: support for incognito prefs (Closed)
Patch Set: Rebase Created 3 years, 7 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_PERSISTENT_PREF_STORE_IMPL_H_ 5 #ifndef SERVICES_PREFERENCES_PERSISTENT_PREF_STORE_IMPL_H_
6 #define SERVICES_PREFERENCES_PERSISTENT_PREF_STORE_IMPL_H_ 6 #define SERVICES_PREFERENCES_PERSISTENT_PREF_STORE_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <unordered_map> 10 #include <unordered_map>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "services/preferences/public/interfaces/preferences.mojom.h" 14 #include "services/preferences/public/interfaces/preferences.mojom.h"
15 #include "services/preferences/public/interfaces/tracked_preference_validation_d elegate.mojom.h" 15 #include "services/preferences/public/interfaces/tracked_preference_validation_d elegate.mojom.h"
16 16
17 namespace prefs { 17 namespace prefs {
18 18
19 class PersistentPrefStoreImpl : public PrefStore::Observer { 19 class PersistentPrefStoreImpl : public PrefStore::Observer,
20 public mojom::PrefStore {
20 public: 21 public:
21 using ObservedPrefs = std::set<std::string>; 22 using ObservedPrefs = std::set<std::string>;
22 23
23 // If |initialized()| is false after construction, |on_initialized| will be 24 // If |initialized()| is false after construction, |on_initialized| will be
24 // called when it becomes true. 25 // called when it becomes true.
25 PersistentPrefStoreImpl( 26 PersistentPrefStoreImpl(
26 scoped_refptr<PersistentPrefStore> backing_pref_store, 27 scoped_refptr<PersistentPrefStore> backing_pref_store,
27 base::OnceClosure on_initialized); 28 base::OnceClosure on_initialized);
28 29
29 ~PersistentPrefStoreImpl() override; 30 ~PersistentPrefStoreImpl() override;
30 31
31 mojom::PersistentPrefStoreConnectionPtr CreateConnection( 32 mojom::PersistentPrefStoreConnectionPtr CreateConnection(
32 ObservedPrefs observed_prefs); 33 ObservedPrefs observed_prefs);
33 34
34 bool initialized() { return !initializing_; } 35 bool initialized() { return !initializing_; }
35 36
36 private: 37 private:
37 class Connection; 38 class Connection;
39 class WritableConnection;
38 40
39 void SetValues(std::vector<mojom::PrefUpdatePtr> updates); 41 void SetValues(std::vector<mojom::PrefUpdatePtr> updates);
40 42
41 void CommitPendingWrite(); 43 void CommitPendingWrite();
42 void SchedulePendingLossyWrites(); 44 void SchedulePendingLossyWrites();
43 void ClearMutableValues(); 45 void ClearMutableValues();
44 46
45 // PrefStore::Observer: 47 // PrefStore::Observer:
46 void OnPrefValueChanged(const std::string& key) override; 48 void OnPrefValueChanged(const std::string& key) override;
47 void OnInitializationCompleted(bool succeeded) override; 49 void OnInitializationCompleted(bool succeeded) override;
48 50
51 // prefs::mojom::PrefStore:
52 void AddObserver(const std::vector<std::string>& prefs_to_observe,
53 const AddObserverCallback& callback) override;
54
49 void OnConnectionError(Connection* connection); 55 void OnConnectionError(Connection* connection);
50 56
51 scoped_refptr<PersistentPrefStore> backing_pref_store_; 57 scoped_refptr<PersistentPrefStore> backing_pref_store_;
52 58
53 bool initializing_ = false; 59 bool initializing_ = false;
54 60
55 std::unordered_map<Connection*, std::unique_ptr<Connection>> connections_; 61 std::unordered_map<Connection*, std::unique_ptr<Connection>> connections_;
56 62
57 base::OnceClosure on_initialized_; 63 base::OnceClosure on_initialized_;
58 64
59 DISALLOW_COPY_AND_ASSIGN(PersistentPrefStoreImpl); 65 DISALLOW_COPY_AND_ASSIGN(PersistentPrefStoreImpl);
60 }; 66 };
61 67
62 } // namespace prefs 68 } // namespace prefs
63 69
64 #endif // SERVICES_PREFERENCES_PERSISTENT_PREF_STORE_IMPL_H_ 70 #endif // SERVICES_PREFERENCES_PERSISTENT_PREF_STORE_IMPL_H_
OLDNEW
« no previous file with comments | « services/preferences/persistent_pref_store_factory.cc ('k') | services/preferences/persistent_pref_store_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698