OLD | NEW |
1 // Copyright (c) 2011 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 "content/browser/in_process_webkit/dom_storage_area.h" | 5 #include "webkit/dom_storage/dom_storage_area.h" |
6 | 6 |
7 #include "base/logging.h" | 7 namespace dom_storage { |
8 #include "content/browser/in_process_webkit/dom_storage_context.h" | |
9 #include "content/browser/in_process_webkit/dom_storage_namespace.h" | |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageArea.h" | |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | |
14 #include "webkit/glue/webkit_glue.h" | |
15 | |
16 using WebKit::WebSecurityOrigin; | |
17 using WebKit::WebStorageArea; | |
18 using WebKit::WebString; | |
19 using WebKit::WebURL; | |
20 | 8 |
21 DOMStorageArea::DOMStorageArea( | 9 DOMStorageArea::DOMStorageArea( |
22 const string16& origin, | 10 const GURL& origin, const FilePath& backing_file) { |
23 int64 id, | |
24 DOMStorageNamespace* owner) | |
25 : origin_(origin), | |
26 origin_url_(origin), | |
27 id_(id), | |
28 owner_(owner) { | |
29 DCHECK(owner_); | |
30 } | 11 } |
31 | 12 |
32 DOMStorageArea::~DOMStorageArea() { | 13 DOMStorageArea::~DOMStorageArea() { |
33 } | 14 } |
34 | 15 |
35 unsigned DOMStorageArea::Length() { | 16 int DOMStorageArea::Length() { |
36 CreateWebStorageAreaIfNecessary(); | 17 return 0; |
37 return storage_area_->length(); | |
38 } | 18 } |
39 | 19 |
40 NullableString16 DOMStorageArea::Key(unsigned index) { | 20 NullableString16 DOMStorageArea::Key(int index) { |
41 CreateWebStorageAreaIfNecessary(); | 21 return NullableString16(true); |
42 return storage_area_->key(index); | |
43 } | 22 } |
44 | 23 |
45 NullableString16 DOMStorageArea::GetItem(const string16& key) { | 24 NullableString16 DOMStorageArea::GetItem(const string16& key) { |
46 CreateWebStorageAreaIfNecessary(); | 25 return NullableString16(true); |
47 return storage_area_->getItem(key); | |
48 } | 26 } |
49 | 27 |
50 NullableString16 DOMStorageArea::SetItem( | 28 bool DOMStorageArea::SetItem( |
51 const string16& key, const string16& value, | 29 const string16& key, const string16& value, |
52 WebStorageArea::Result* result) { | 30 NullableString16* old_value) { |
53 CreateWebStorageAreaIfNecessary(); | 31 return false; |
54 WebString old_value; | |
55 storage_area_->setItem(key, value, WebURL(), *result, old_value); | |
56 return old_value; | |
57 } | 32 } |
58 | 33 |
59 NullableString16 DOMStorageArea::RemoveItem(const string16& key) { | 34 bool DOMStorageArea::RemoveItem( |
60 CreateWebStorageAreaIfNecessary(); | 35 const string16& key, |
61 WebString old_value; | 36 NullableString16* old_value) { |
62 storage_area_->removeItem(key, WebURL(), old_value); | 37 return false; |
63 return old_value; | |
64 } | 38 } |
65 | 39 |
66 bool DOMStorageArea::Clear() { | 40 bool DOMStorageArea::Clear() { |
67 CreateWebStorageAreaIfNecessary(); | 41 return false; |
68 bool somethingCleared; | |
69 storage_area_->clear(WebURL(), somethingCleared); | |
70 return somethingCleared; | |
71 } | 42 } |
72 | 43 |
73 void DOMStorageArea::PurgeMemory() { | 44 void DOMStorageArea::PurgeMemory() { |
74 storage_area_.reset(); | |
75 } | 45 } |
76 | 46 |
77 void DOMStorageArea::CreateWebStorageAreaIfNecessary() { | 47 } // namespace dom_storage |
78 if (!storage_area_.get()) | |
79 storage_area_.reset(owner_->CreateWebStorageArea(origin_)); | |
80 } | |
OLD | NEW |