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_
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"
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
{
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
,
40 uint32 flags
) override
;
41 void SetValueSilently(const std::string
& key
,
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
{}
52 ~CronetInMemoryPrefStore() override
;
54 // Stores the preference values.
57 base::ObserverList
<PrefStore::Observer
, true> observers_
;
59 DISALLOW_COPY_AND_ASSIGN(CronetInMemoryPrefStore
);
62 #endif // COMPONENTS_CRONET_ANDROID_CRONET_IN_MEMORY_PREF_STORE_H_