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

Side by Side 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, 10 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 unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "webkit/dom_storage/dom_storage_map.h"
6
7 namespace dom_storage {
8
9 unsigned DomStorageMap::Length() {
10 return values_.size();
11 }
12
13 NullableString16 DomStorageMap::Key(unsigned index) {
14 if (index > values_.size())
15 return NullableString16(true);
16 ValuesMap::const_iterator it = values_.begin();
17 for (unsigned i = 0; i < index; ++i, ++it) {
18 // TODO(michaeln): Fix this so we don't have to walk
19 // up to the key from the beginning on each call.
20 }
21 return NullableString16(it->first, false);
22 }
23
24 NullableString16 DomStorageMap::GetItem(const string16& key) {
25 ValuesMap::const_iterator found = values_.find(key);
26 if (found == values_.end())
27 return NullableString16(true);
28 return found->second;
29 }
30
31 bool DomStorageMap::SetItem(
32 const string16& key, const string16& value,
33 NullableString16* old_value) {
34 // 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
35 ValuesMap::const_iterator found = values_.find(key);
36 if (found == values_.end()) {
37 *old_value = NullableString16(true);
38 return true;
39 }
40 values_[key] = NullableString16(value, false);
41 return true;
42 }
43
44 bool DomStorageMap::RemoveItem(
45 const string16& key,
46 string16* old_value) {
47 ValuesMap::const_iterator found = values_.find(key);
48 if (found == values_.end())
49 return false;
50 *old_value = found->second.string();
51 values_.erase(found);
52 return true;
53 }
54
55 DomStorageMap* DomStorageMap::DeepCopy() {
56 DomStorageMap* copy = new DomStorageMap;
57 copy->values_ = values_;
58 return copy;
59 }
60
61 } // namespace dom_storage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698