Remove obsolete entries from .gitignore.
[chromium-blink-merge.git] / components / cronet / android / cronet_in_memory_pref_store.h
blob0887208f012c04ef30240888f97c7ccbb9c91750
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/memory/scoped_ptr.h"
13 #include "base/observer_list.h"
14 #include "base/prefs/persistent_pref_store.h"
15 #include "base/prefs/pref_value_map.h"
17 namespace base {
18 class Value;
21 // A light-weight prefstore implementation that keeps preferences
22 // in a memory backed store. This is not a persistent prefstore.
23 // TODO(bengr): Move to base/prefs or some other shared location.
24 class CronetInMemoryPrefStore : public PersistentPrefStore {
25 public:
26 CronetInMemoryPrefStore();
28 // PrefStore overrides:
29 bool GetValue(const std::string& key,
30 const base::Value** result) const override;
31 void AddObserver(PrefStore::Observer* observer) override;
32 void RemoveObserver(PrefStore::Observer* observer) override;
33 bool HasObservers() const override;
34 bool IsInitializationComplete() const override;
36 // PersistentPrefStore overrides:
37 bool GetMutableValue(const std::string& key, base::Value** result) override;
38 void ReportValueChanged(const std::string& key, uint32 flags) override;
39 void SetValue(const std::string& key,
40 scoped_ptr<base::Value> value,
41 uint32 flags) override;
42 void SetValueSilently(const std::string& key,
43 scoped_ptr<base::Value> value,
44 uint32 flags) override;
45 void RemoveValue(const std::string& key, uint32 flags) override;
46 bool ReadOnly() const override;
47 PrefReadError GetReadError() const override;
48 PersistentPrefStore::PrefReadError ReadPrefs() override;
49 void ReadPrefsAsync(ReadErrorDelegate* error_delegate) override;
50 void CommitPendingWrite() override {}
51 void SchedulePendingLossyWrites() override {}
53 private:
54 ~CronetInMemoryPrefStore() override;
56 // Stores the preference values.
57 PrefValueMap prefs_;
59 base::ObserverList<PrefStore::Observer, true> observers_;
61 DISALLOW_COPY_AND_ASSIGN(CronetInMemoryPrefStore);
64 #endif // COMPONENTS_CRONET_ANDROID_CRONET_IN_MEMORY_PREF_STORE_H_