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

Side by Side Diff: content/browser/in_process_webkit/dom_storage_area.cc

Issue 10086018: More DomStorage house cleaning (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 "content/browser/in_process_webkit/dom_storage_area.h"
6
7 #include "base/logging.h"
8 #include "content/browser/in_process_webkit/dom_storage_namespace.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageArea.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
13 #include "webkit/dom_storage/dom_storage_types.h"
14 #include "webkit/glue/webkit_glue.h"
15
16 #ifdef ENABLE_NEW_DOM_STORAGE_BACKEND
17 // This class is no longer applicable.
18 #else
19
20 using WebKit::WebSecurityOrigin;
21 using WebKit::WebStorageArea;
22 using WebKit::WebString;
23 using WebKit::WebURL;
24
25 DOMStorageArea::DOMStorageArea(
26 const string16& origin,
27 int64 id,
28 DOMStorageNamespace* owner)
29 : origin_(origin),
30 origin_url_(origin),
31 id_(id),
32 owner_(owner) {
33 DCHECK(owner_);
34 }
35
36 DOMStorageArea::~DOMStorageArea() {
37 }
38
39 unsigned DOMStorageArea::Length() {
40 CreateWebStorageAreaIfNecessary();
41 return storage_area_->length();
42 }
43
44 NullableString16 DOMStorageArea::Key(unsigned index) {
45 CreateWebStorageAreaIfNecessary();
46 return storage_area_->key(index);
47 }
48
49 NullableString16 DOMStorageArea::GetItem(const string16& key) {
50 CreateWebStorageAreaIfNecessary();
51 return storage_area_->getItem(key);
52 }
53
54 NullableString16 DOMStorageArea::SetItem(
55 const string16& key, const string16& value,
56 WebStorageArea::Result* result) {
57 CreateWebStorageAreaIfNecessary();
58 WebString old_value;
59 storage_area_->setItem(key, value, WebURL(), *result, old_value);
60 return old_value;
61 }
62
63 NullableString16 DOMStorageArea::RemoveItem(const string16& key) {
64 CreateWebStorageAreaIfNecessary();
65 WebString old_value;
66 storage_area_->removeItem(key, WebURL(), old_value);
67 return old_value;
68 }
69
70 bool DOMStorageArea::Clear() {
71 CreateWebStorageAreaIfNecessary();
72 bool somethingCleared;
73 storage_area_->clear(WebURL(), somethingCleared);
74 return somethingCleared;
75 }
76
77 void DOMStorageArea::PurgeMemory() {
78 storage_area_.reset();
79 }
80
81 void DOMStorageArea::CreateWebStorageAreaIfNecessary() {
82 if (!storage_area_.get())
83 storage_area_.reset(owner_->CreateWebStorageArea(origin_));
84 }
85
86 #endif // ENABLE_NEW_DOM_STORAGE_BACKEND
87
OLDNEW
« no previous file with comments | « content/browser/in_process_webkit/dom_storage_area.h ('k') | content/browser/in_process_webkit/dom_storage_context_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698