Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/prefs/default_pref_store.h" | 5 #include "base/prefs/default_pref_store.h" |
| 6 | 6 |
| 7 using base::Value; | 7 using base::Value; |
| 8 | 8 |
| 9 DefaultPrefStore::DefaultPrefStore() {} | 9 DefaultPrefStore::DefaultPrefStore() {} |
| 10 | 10 |
| 11 PrefStore::ReadResult DefaultPrefStore::GetValue( | |
| 12 const std::string& key, | |
| 13 const base::Value** result) const { | |
| 14 const const_iterator entry = prefs_.find(key); | |
|
Bernhard Bauer
2012/11/06 18:25:02
Nit: I think a const const_iterator is overkill ;-
Mattias Nissler (ping if slow)
2012/11/07 08:24:02
It's correct w.r.t. the style guide though.
Anthony Berent
2012/11/07 11:22:54
This code actually goes away as a result of Mattla
| |
| 15 if (entry != prefs_.end()) { | |
| 16 if (result) | |
| 17 *result = entry->second; | |
| 18 return READ_OK; | |
| 19 } | |
| 20 return READ_NO_VALUE; | |
| 21 } | |
| 22 | |
| 11 void DefaultPrefStore::SetDefaultValue(const std::string& key, Value* value) { | 23 void DefaultPrefStore::SetDefaultValue(const std::string& key, Value* value) { |
| 12 CHECK(GetValue(key, NULL) == READ_NO_VALUE); | 24 CHECK(GetValue(key, NULL) == READ_NO_VALUE); |
| 13 SetValue(key, value); | 25 prefs_.insert(std::make_pair(key, value)); |
| 14 } | 26 } |
| 15 | 27 |
| 16 void DefaultPrefStore::RemoveDefaultValue(const std::string& key) { | 28 void DefaultPrefStore::RemoveDefaultValue(const std::string& key) { |
| 17 CHECK(GetValue(key, NULL) == READ_OK); | 29 CHECK(GetValue(key, NULL) == READ_OK); |
| 18 RemoveValue(key); | 30 prefs_.erase(key); |
| 19 } | 31 } |
| 20 | 32 |
| 21 base::Value::Type DefaultPrefStore::GetType(const std::string& key) const { | 33 base::Value::Type DefaultPrefStore::GetType(const std::string& key) const { |
| 22 const Value* value; | 34 const Value* value; |
| 23 return GetValue(key, &value) == READ_OK ? value->GetType() : Value::TYPE_NULL; | 35 return GetValue(key, &value) == READ_OK ? value->GetType() : Value::TYPE_NULL; |
| 24 } | 36 } |
| 25 | 37 |
| 38 DefaultPrefStore::const_iterator DefaultPrefStore::begin() const { | |
| 39 return prefs_.begin(); | |
| 40 } | |
| 41 | |
| 42 DefaultPrefStore::const_iterator DefaultPrefStore::end() const { | |
| 43 return prefs_.end(); | |
| 44 } | |
| 45 | |
| 26 DefaultPrefStore::~DefaultPrefStore() {} | 46 DefaultPrefStore::~DefaultPrefStore() {} |
| OLD | NEW |