Fix emulator build error
[platform/framework/web/chromium-efl.git] / components / prefs / in_memory_pref_store.h
1 // Copyright 2016 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_PREFS_IN_MEMORY_PREF_STORE_H_
6 #define COMPONENTS_PREFS_IN_MEMORY_PREF_STORE_H_
7
8 #include <stdint.h>
9 #include <string>
10
11 #include "base/compiler_specific.h"
12 #include "base/observer_list.h"
13 #include "base/strings/string_piece.h"
14 #include "base/values.h"
15 #include "components/prefs/persistent_pref_store.h"
16 #include "components/prefs/pref_value_map.h"
17
18 // A light-weight prefstore implementation that keeps preferences
19 // in a memory backed store. This is not a persistent prefstore -- we
20 // subclass the PersistentPrefStore here since it is needed by the
21 // PrefService, which in turn is needed by various components.
22 class COMPONENTS_PREFS_EXPORT InMemoryPrefStore : public PersistentPrefStore {
23  public:
24   InMemoryPrefStore();
25
26   InMemoryPrefStore(const InMemoryPrefStore&) = delete;
27   InMemoryPrefStore& operator=(const InMemoryPrefStore&) = delete;
28
29   // PrefStore implementation.
30   bool GetValue(base::StringPiece key,
31                 const base::Value** result) const override;
32   base::Value::Dict GetValues() const override;
33   void AddObserver(PrefStore::Observer* observer) override;
34   void RemoveObserver(PrefStore::Observer* observer) override;
35   bool HasObservers() const override;
36   bool IsInitializationComplete() const override;
37
38   // PersistentPrefStore implementation.
39   bool GetMutableValue(const std::string& key, base::Value** result) override;
40   void ReportValueChanged(const std::string& key, uint32_t flags) override;
41   void SetValue(const std::string& key,
42                 base::Value value,
43                 uint32_t flags) override;
44   void SetValueSilently(const std::string& key,
45                         base::Value value,
46                         uint32_t flags) override;
47   void RemoveValue(const std::string& key, uint32_t flags) override;
48   bool ReadOnly() const override;
49   PrefReadError GetReadError() const override;
50   PersistentPrefStore::PrefReadError ReadPrefs() override;
51   void ReadPrefsAsync(ReadErrorDelegate* error_delegate) override {}
52   void SchedulePendingLossyWrites() override {}
53   void OnStoreDeletionFromDisk() override {}
54   bool IsInMemoryPrefStore() const override;
55   void RemoveValuesByPrefixSilently(const std::string& prefix) override;
56
57  protected:
58   ~InMemoryPrefStore() override;
59
60  private:
61   // Stores the preference values.
62   PrefValueMap prefs_;
63
64   base::ObserverList<PrefStore::Observer, true>::Unchecked observers_;
65 };
66
67 #endif  // COMPONENTS_PREFS_IN_MEMORY_PREF_STORE_H_