Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Unified Diff: webkit/dom_storage/dom_storage_map.cc

Issue 9146025: Framing for a DOMStorage backend that does not depend on in-process-webkit. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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,68 @@
+// 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 {
+
+DomStorageMap::DomStorageMap() {}
+DomStorageMap::~DomStorageMap() {}
+
+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(benm): Alter 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(benm): check quota and return false if exceeded
+ ValuesMap::const_iterator found = values_.find(key);
+ if (found == values_.end())
+ *old_value = NullableString16(true);
+ else
+ *old_value = found->second;
+ values_[key] = NullableString16(value, false);
+ return true;
+}
+
+bool DomStorageMap::RemoveItem(
+ const string16& key,
+ string16* old_value) {
+ ValuesMap::iterator found = values_.find(key);
+ if (found == values_.end())
+ return false;
+ *old_value = found->second.string();
+ values_.erase(found);
+ return true;
+}
+
+void DomStorageMap::SwapValues(ValuesMap* values) {
+ values_.swap(*values);
+}
+
+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

Powered by Google App Engine
This is Rietveld 408576698