| 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 #include "components/cronet/android/cronet_in_memory_pref_store.h" | 5 #include "components/cronet/android/cronet_in_memory_pref_store.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 | 9 |
| 10 CronetInMemoryPrefStore::CronetInMemoryPrefStore() {} | 10 CronetInMemoryPrefStore::CronetInMemoryPrefStore() {} |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 } | 30 } |
| 31 | 31 |
| 32 bool CronetInMemoryPrefStore::HasObservers() const { | 32 bool CronetInMemoryPrefStore::HasObservers() const { |
| 33 return observers_.might_have_observers(); | 33 return observers_.might_have_observers(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 bool CronetInMemoryPrefStore::IsInitializationComplete() const { | 36 bool CronetInMemoryPrefStore::IsInitializationComplete() const { |
| 37 return true; | 37 return true; |
| 38 } | 38 } |
| 39 | 39 |
| 40 void CronetInMemoryPrefStore::SetValue( | 40 void CronetInMemoryPrefStore::SetValue(const std::string& key, |
| 41 const std::string& key, scoped_ptr<base::Value> value, uint32 flags) { | 41 scoped_ptr<base::Value> value, |
| 42 uint32_t flags) { |
| 42 DCHECK(value); | 43 DCHECK(value); |
| 43 if (prefs_.SetValue(key, value.Pass())) | 44 if (prefs_.SetValue(key, value.Pass())) |
| 44 ReportValueChanged(key, flags); | 45 ReportValueChanged(key, flags); |
| 45 } | 46 } |
| 46 | 47 |
| 47 void CronetInMemoryPrefStore::SetValueSilently(const std::string& key, | 48 void CronetInMemoryPrefStore::SetValueSilently(const std::string& key, |
| 48 scoped_ptr<base::Value> value, | 49 scoped_ptr<base::Value> value, |
| 49 uint32 flags) { | 50 uint32_t flags) { |
| 50 prefs_.SetValue(key, value.Pass()); | 51 prefs_.SetValue(key, value.Pass()); |
| 51 } | 52 } |
| 52 | 53 |
| 53 void CronetInMemoryPrefStore::RemoveValue(const std::string& key, | 54 void CronetInMemoryPrefStore::RemoveValue(const std::string& key, |
| 54 uint32 flags) { | 55 uint32_t flags) { |
| 55 if (prefs_.RemoveValue(key)) | 56 if (prefs_.RemoveValue(key)) |
| 56 ReportValueChanged(key, flags); | 57 ReportValueChanged(key, flags); |
| 57 } | 58 } |
| 58 | 59 |
| 59 bool CronetInMemoryPrefStore::ReadOnly() const { | 60 bool CronetInMemoryPrefStore::ReadOnly() const { |
| 60 return false; | 61 return false; |
| 61 } | 62 } |
| 62 | 63 |
| 63 PersistentPrefStore::PrefReadError | 64 PersistentPrefStore::PrefReadError |
| 64 CronetInMemoryPrefStore::GetReadError() const { | 65 CronetInMemoryPrefStore::GetReadError() const { |
| 65 return PersistentPrefStore::PREF_READ_ERROR_NONE; | 66 return PersistentPrefStore::PREF_READ_ERROR_NONE; |
| 66 } | 67 } |
| 67 | 68 |
| 68 PersistentPrefStore::PrefReadError CronetInMemoryPrefStore::ReadPrefs() { | 69 PersistentPrefStore::PrefReadError CronetInMemoryPrefStore::ReadPrefs() { |
| 69 return PersistentPrefStore::PREF_READ_ERROR_NONE; | 70 return PersistentPrefStore::PREF_READ_ERROR_NONE; |
| 70 } | 71 } |
| 71 | 72 |
| 72 void CronetInMemoryPrefStore::ReadPrefsAsync( | 73 void CronetInMemoryPrefStore::ReadPrefsAsync( |
| 73 ReadErrorDelegate* error_delegate_raw) { | 74 ReadErrorDelegate* error_delegate_raw) { |
| 74 } | 75 } |
| 75 | 76 |
| 76 void CronetInMemoryPrefStore::ReportValueChanged(const std::string& key, | 77 void CronetInMemoryPrefStore::ReportValueChanged(const std::string& key, |
| 77 uint32 flags) { | 78 uint32_t flags) { |
| 78 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); | 79 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); |
| 79 } | 80 } |
| 80 | 81 |
| OLD | NEW |