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 "webkit/dom_storage/dom_storage_map.h" | 5 #include "webkit/dom_storage/dom_storage_map.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace { | 9 namespace { |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 return NullableString16(key_iterator_->first, false); | 54 return NullableString16(key_iterator_->first, false); |
55 } | 55 } |
56 | 56 |
57 NullableString16 DomStorageMap::GetItem(const string16& key) const { | 57 NullableString16 DomStorageMap::GetItem(const string16& key) const { |
58 ValuesMap::const_iterator found = values_.find(key); | 58 ValuesMap::const_iterator found = values_.find(key); |
59 if (found == values_.end()) | 59 if (found == values_.end()) |
60 return NullableString16(true); | 60 return NullableString16(true); |
61 return found->second; | 61 return found->second; |
62 } | 62 } |
63 | 63 |
| 64 bool DomStorageMap::ContainsItem(const string16& key) const { |
| 65 return values_.find(key) != values_.end(); |
| 66 } |
| 67 |
64 bool DomStorageMap::SetItem( | 68 bool DomStorageMap::SetItem( |
65 const string16& key, const string16& value, | 69 const string16& key, const string16& value, |
66 NullableString16* old_value) { | 70 NullableString16* old_value) { |
67 ValuesMap::const_iterator found = values_.find(key); | 71 ValuesMap::const_iterator found = values_.find(key); |
68 if (found == values_.end()) | 72 if (found == values_.end()) |
69 *old_value = NullableString16(true); | 73 *old_value = NullableString16(true); |
70 else | 74 else |
71 *old_value = found->second; | 75 *old_value = found->second; |
72 | 76 |
73 size_t old_item_size = old_value->is_null() ? | 77 size_t old_item_size = old_value->is_null() ? |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 copy->ResetKeyIterator(); | 117 copy->ResetKeyIterator(); |
114 return copy; | 118 return copy; |
115 } | 119 } |
116 | 120 |
117 void DomStorageMap::ResetKeyIterator() { | 121 void DomStorageMap::ResetKeyIterator() { |
118 key_iterator_ = values_.begin(); | 122 key_iterator_ = values_.begin(); |
119 last_key_index_ = 0; | 123 last_key_index_ = 0; |
120 } | 124 } |
121 | 125 |
122 } // namespace dom_storage | 126 } // namespace dom_storage |
OLD | NEW |