OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 IOS_CRNET_SDCH_OWNER_PREF_STORAGE_H_ | 5 #ifndef IOS_CRNET_SDCH_OWNER_PREF_STORAGE_H_ |
6 #define IOS_CRNET_SDCH_OWNER_PREF_STORAGE_H_ | 6 #define IOS_CRNET_SDCH_OWNER_PREF_STORAGE_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "components/prefs/pref_store.h" | 11 #include "components/prefs/pref_store.h" |
10 #include "net/sdch/sdch_owner.h" | 12 #include "net/sdch/sdch_owner.h" |
11 | 13 |
12 class PersistentPrefStore; | 14 class PersistentPrefStore; |
13 | 15 |
14 // Provides an implementation of SdchOwner::PrefStorage that maps to | 16 // Provides an implementation of SdchOwner::PrefStorage that maps to |
15 // Chrome's preferences system. | 17 // Chrome's preferences system. |
16 class SdchOwnerPrefStorage | 18 class SdchOwnerPrefStorage |
17 : public net::SdchOwner::PrefStorage, | 19 : public net::SdchOwner::PrefStorage, |
18 public PrefStore::Observer { | 20 public PrefStore::Observer { |
19 public: | 21 public: |
20 // The storage must outlive this class. | 22 // The storage must outlive this class. |
21 explicit SdchOwnerPrefStorage(PersistentPrefStore* storage); | 23 explicit SdchOwnerPrefStorage(PersistentPrefStore* storage); |
22 ~SdchOwnerPrefStorage() override; | 24 ~SdchOwnerPrefStorage() override; |
23 | 25 |
24 ReadError GetReadError() const override; | 26 ReadError GetReadError() const override; |
25 bool GetValue(const base::DictionaryValue** result) const override; | 27 bool GetValue(const base::DictionaryValue** result) const override; |
26 bool GetMutableValue(base::DictionaryValue** result) override; | 28 bool GetMutableValue(base::DictionaryValue** result) override; |
27 void SetValue(scoped_ptr<base::DictionaryValue> value) override; | 29 void SetValue(std::unique_ptr<base::DictionaryValue> value) override; |
28 void ReportValueChanged() override; | 30 void ReportValueChanged() override; |
29 bool IsInitializationComplete() override; | 31 bool IsInitializationComplete() override; |
30 void StartObservingInit(net::SdchOwner* observer) override; | 32 void StartObservingInit(net::SdchOwner* observer) override; |
31 void StopObservingInit() override; | 33 void StopObservingInit() override; |
32 | 34 |
33 private: | 35 private: |
34 // PrefStore::Observer implementation. | 36 // PrefStore::Observer implementation. |
35 void OnPrefValueChanged(const std::string& key) override; | 37 void OnPrefValueChanged(const std::string& key) override; |
36 void OnInitializationCompleted(bool succeeded) override; | 38 void OnInitializationCompleted(bool succeeded) override; |
37 | 39 |
38 PersistentPrefStore* storage_; // Non-owning. | 40 PersistentPrefStore* storage_; // Non-owning. |
39 const std::string storage_key_; | 41 const std::string storage_key_; |
40 | 42 |
41 net::SdchOwner* init_observer_; // Non-owning. | 43 net::SdchOwner* init_observer_; // Non-owning. |
42 | 44 |
43 DISALLOW_COPY_AND_ASSIGN(SdchOwnerPrefStorage); | 45 DISALLOW_COPY_AND_ASSIGN(SdchOwnerPrefStorage); |
44 }; | 46 }; |
45 | 47 |
46 #endif // IOS_CRNET_SDCH_OWNER_PREF_STORAGE_H_ | 48 #endif // IOS_CRNET_SDCH_OWNER_PREF_STORAGE_H_ |
OLD | NEW |