Index: webkit/dom_storage/dom_storage_map.cc |
=================================================================== |
--- webkit/dom_storage/dom_storage_map.cc (revision 0) |
+++ webkit/dom_storage/dom_storage_map.cc (revision 0) |
@@ -0,0 +1,61 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "webkit/dom_storage/dom_storage_map.h" |
+ |
+namespace dom_storage { |
+ |
+unsigned DomStorageMap::Length() { |
+ return values_.size(); |
+} |
+ |
+NullableString16 DomStorageMap::Key(unsigned index) { |
+ if (index > values_.size()) |
+ return NullableString16(true); |
+ ValuesMap::const_iterator it = values_.begin(); |
+ for (unsigned i = 0; i < index; ++i, ++it) { |
+ // TODO(michaeln): Fix this so we don't have to walk |
+ // up to the key from the beginning on each call. |
+ } |
+ return NullableString16(it->first, false); |
+} |
+ |
+NullableString16 DomStorageMap::GetItem(const string16& key) { |
+ ValuesMap::const_iterator found = values_.find(key); |
+ if (found == values_.end()) |
+ return NullableString16(true); |
+ return found->second; |
+} |
+ |
+bool DomStorageMap::SetItem( |
+ const string16& key, const string16& value, |
+ NullableString16* old_value) { |
+ // TODO(michaeln): check quota and return false if exceeded |
benm (inactive)
2012/02/02 16:23:19
I was thinking that this would be more the respons
michaeln
2012/02/03 00:33:42
Since we need the size of the old values and need
|
+ ValuesMap::const_iterator found = values_.find(key); |
+ if (found == values_.end()) { |
+ *old_value = NullableString16(true); |
+ return true; |
+ } |
+ values_[key] = NullableString16(value, false); |
+ return true; |
+} |
+ |
+bool DomStorageMap::RemoveItem( |
+ const string16& key, |
+ string16* old_value) { |
+ ValuesMap::const_iterator found = values_.find(key); |
+ if (found == values_.end()) |
+ return false; |
+ *old_value = found->second.string(); |
+ values_.erase(found); |
+ return true; |
+} |
+ |
+DomStorageMap* DomStorageMap::DeepCopy() { |
+ DomStorageMap* copy = new DomStorageMap; |
+ copy->values_ = values_; |
+ return copy; |
+} |
+ |
+} // namespace dom_storage |
Property changes on: webkit\dom_storage\dom_storage_map.cc |
___________________________________________________________________ |
Added: svn:eol-style |
+ LF |