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

Side by Side Diff: blimp/engine/common/blimp_pref_store.h

Issue 1881253003: Create a PrefStore in support of Blimp metrics collection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding components/prefs to common engine build dependencies. Created 4 years, 8 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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 ANDROID_WEBVIEW_BROWSER_AW_PREF_STORE_H_ 5 #ifndef BLIMP_ENGINE_COMMON_BLIMP_PREF_STORE_H_
6 #define ANDROID_WEBVIEW_BROWSER_AW_PREF_STORE_H_ 6 #define BLIMP_ENGINE_COMMON_BLIMP_PREF_STORE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/observer_list.h" 14 #include "base/observer_list.h"
15 #include "components/prefs/persistent_pref_store.h" 15 #include "components/prefs/persistent_pref_store.h"
16 #include "components/prefs/pref_value_map.h" 16 #include "components/prefs/pref_value_map.h"
17 17
18 namespace blimp {
19 namespace engine {
18 // A light-weight prefstore implementation that keeps preferences 20 // A light-weight prefstore implementation that keeps preferences
Kevin M 2016/04/14 21:49:50 Add newline above
Jess 2016/04/14 22:59:49 Done.
19 // in a memory backed store. This is not a persistent prefstore -- we 21 // in a memory backed store. This is not a persistent prefstore -- we
20 // subclass the PersistentPrefStore here since it is needed by the 22 // subclass the PersistentPrefStore here since it is needed by the
21 // PrefService, which in turn is needed by the Autofill component. 23 // PrefService, which in turn is needed by the metrics component.
Kevin M 2016/04/14 21:49:50 Could you reference AwPrefStore as the basis for t
Jess 2016/04/14 22:59:49 Yes. I'd been assuming the engine need something
22 class AwPrefStore : public PersistentPrefStore { 24 class BlimpPrefStore : public PersistentPrefStore {
Kevin M 2016/04/14 21:49:50 Unit tests?
Jess 2016/04/14 22:59:49 Do you have a specific function or set of function
Kevin M 2016/04/15 17:45:38 Can you inject a test-owned prefs_ and verify that
23 public: 25 public:
24 AwPrefStore(); 26 BlimpPrefStore();
25 27
26 // Overriden from PrefStore. 28 // Overriden from PrefStore.
Kevin M 2016/04/14 21:49:50 PrefStore implementation.
Jess 2016/04/14 22:59:49 Done.
27 bool GetValue(const std::string& key, 29 bool GetValue(const std::string& key,
28 const base::Value** result) const override; 30 const base::Value** result) const override;
29 void AddObserver(PrefStore::Observer* observer) override; 31 void AddObserver(PrefStore::Observer* observer) override;
30 void RemoveObserver(PrefStore::Observer* observer) override; 32 void RemoveObserver(PrefStore::Observer* observer) override;
31 bool HasObservers() const override; 33 bool HasObservers() const override;
32 bool IsInitializationComplete() const override; 34 bool IsInitializationComplete() const override;
33 35
34 // PersistentPrefStore overrides: 36 // PersistentPrefStore overrides:
Kevin M 2016/04/14 21:49:50 "PersistentPrefStore implementation."
Jess 2016/04/14 22:59:49 Done.
35 bool GetMutableValue(const std::string& key, base::Value** result) override; 37 bool GetMutableValue(const std::string& key, base::Value** result) override;
36 void ReportValueChanged(const std::string& key, uint32_t flags) override; 38 void ReportValueChanged(const std::string& key, uint32_t flags) override;
37 void SetValue(const std::string& key, 39 void SetValue(const std::string& key,
38 std::unique_ptr<base::Value> value, 40 std::unique_ptr<base::Value> value,
39 uint32_t flags) override; 41 uint32_t flags) override;
40 void SetValueSilently(const std::string& key, 42 void SetValueSilently(const std::string& key,
41 std::unique_ptr<base::Value> value, 43 std::unique_ptr<base::Value> value,
42 uint32_t flags) override; 44 uint32_t flags) override;
43 void RemoveValue(const std::string& key, uint32_t flags) override; 45 void RemoveValue(const std::string& key, uint32_t flags) override;
44 bool ReadOnly() const override; 46 bool ReadOnly() const override;
45 PrefReadError GetReadError() const override; 47 PrefReadError GetReadError() const override;
46 PersistentPrefStore::PrefReadError ReadPrefs() override; 48 PersistentPrefStore::PrefReadError ReadPrefs() override;
47 void ReadPrefsAsync(ReadErrorDelegate* error_delegate) override; 49 void ReadPrefsAsync(ReadErrorDelegate* error_delegate) override;
48 void CommitPendingWrite() override {} 50 void CommitPendingWrite() override {}
49 void SchedulePendingLossyWrites() override {} 51 void SchedulePendingLossyWrites() override {}
50 void ClearMutableValues() override {} 52 void ClearMutableValues() override {}
51 53
52 protected: 54 protected:
53 ~AwPrefStore() override; 55 ~BlimpPrefStore() override;
54 56
55 private: 57 private:
56 // Stores the preference values. 58 // Stores the preference values.
57 PrefValueMap prefs_; 59 PrefValueMap prefs_;
58 60
59 base::ObserverList<PrefStore::Observer, true> observers_; 61 base::ObserverList<PrefStore::Observer, true> observers_;
60 62
61 DISALLOW_COPY_AND_ASSIGN(AwPrefStore); 63 DISALLOW_COPY_AND_ASSIGN(BlimpPrefStore);
62 }; 64 };
63 65
64 #endif // ANDROID_WEBVIEW_BROWSER_AW_PREF_STORE_H_ 66 } // namespace engine
67 } // namespace blimp
68
69 #endif // BLIMP_ENGINE_COMMON_BLIMP_PREF_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698