Reland "Non-SFI mode: Switch to newlib. (patchset #4 id:60001 of https://codereview...
[chromium-blink-merge.git] / components / cronet / android / cronet_in_memory_pref_store.h
blobdaebace37b8520f257bd4976e75284323881908a
1 // Copyright 2015 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.
5 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_IN_MEMORY_PREF_STORE_H_
6 #define COMPONENTS_CRONET_ANDROID_CRONET_IN_MEMORY_PREF_STORE_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/observer_list.h"
13 #include "base/prefs/persistent_pref_store.h"
14 #include "base/prefs/pref_value_map.h"
16 namespace base {
17 class Value;
20 // A light-weight prefstore implementation that keeps preferences
21 // in a memory backed store. This is not a persistent prefstore.
22 // TODO(bengr): Move to base/prefs or some other shared location.
23 class CronetInMemoryPrefStore : public PersistentPrefStore {
24 public:
25 CronetInMemoryPrefStore();
27 // PrefStore overrides:
28 bool GetValue(const std::string& key,
29 const base::Value** result) const override;
30 void AddObserver(PrefStore::Observer* observer) override;
31 void RemoveObserver(PrefStore::Observer* observer) override;
32 bool HasObservers() const override;
33 bool IsInitializationComplete() const override;
35 // PersistentPrefStore overrides:
36 bool GetMutableValue(const std::string& key, base::Value** result) override;
37 void ReportValueChanged(const std::string& key, uint32 flags) override;
38 void SetValue(const std::string& key,
39 base::Value* value,
40 uint32 flags) override;
41 void SetValueSilently(const std::string& key,
42 base::Value* value,
43 uint32 flags) override;
44 void RemoveValue(const std::string& key, uint32 flags) override;
45 bool ReadOnly() const override;
46 PrefReadError GetReadError() const override;
47 PersistentPrefStore::PrefReadError ReadPrefs() override;
48 void ReadPrefsAsync(ReadErrorDelegate* error_delegate) override;
49 void CommitPendingWrite() override {}
51 private:
52 ~CronetInMemoryPrefStore() override;
54 // Stores the preference values.
55 PrefValueMap prefs_;
57 base::ObserverList<PrefStore::Observer, true> observers_;
59 DISALLOW_COPY_AND_ASSIGN(CronetInMemoryPrefStore);
62 #endif // COMPONENTS_CRONET_ANDROID_CRONET_IN_MEMORY_PREF_STORE_H_