OLD | NEW |
1 /* | 1 // DELETE ME |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions are | |
6 * met: | |
7 * | |
8 * * Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * * Redistributions in binary form must reproduce the above | |
11 * copyright notice, this list of conditions and the following disclaimer | |
12 * in the documentation and/or other materials provided with the | |
13 * distribution. | |
14 * * Neither the name of Google Inc. nor the names of its | |
15 * contributors may be used to endorse or promote products derived from | |
16 * this software without specific prior written permission. | |
17 * | |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 */ | |
30 | |
31 #include "config.h" | |
32 #include "WebStorageAreaImpl.h" | |
33 | |
34 #include "ExceptionCode.h" | |
35 | |
36 #include "platform/WebString.h" | |
37 #include "platform/WebURL.h" | |
38 | |
39 namespace WebKit { | |
40 | |
41 const WebURL* WebStorageAreaImpl::storageEventURL = 0; | |
42 | |
43 WebStorageAreaImpl::WebStorageAreaImpl(PassRefPtr<WebCore::StorageArea> storageA
rea) | |
44 : m_storageArea(storageArea) | |
45 { | |
46 } | |
47 | |
48 WebStorageAreaImpl::~WebStorageAreaImpl() | |
49 { | |
50 } | |
51 | |
52 unsigned WebStorageAreaImpl::length() | |
53 { | |
54 return m_storageArea->length(0); | |
55 } | |
56 | |
57 WebString WebStorageAreaImpl::key(unsigned index) | |
58 { | |
59 return m_storageArea->key(index, 0); | |
60 } | |
61 | |
62 WebString WebStorageAreaImpl::getItem(const WebString& key) | |
63 { | |
64 return m_storageArea->getItem(key, 0); | |
65 } | |
66 | |
67 void WebStorageAreaImpl::setItem(const WebString& key, const WebString& value, c
onst WebURL& url, Result& result, WebString& oldValue) | |
68 { | |
69 int exceptionCode = 0; | |
70 | |
71 ScopedStorageEventURL scope(url); | |
72 oldValue = m_storageArea->setItem(key, value, exceptionCode, 0); | |
73 | |
74 if (exceptionCode) { | |
75 ASSERT(exceptionCode == WebCore::QUOTA_EXCEEDED_ERR); | |
76 result = ResultBlockedByQuota; | |
77 } else | |
78 result = ResultOK; | |
79 } | |
80 | |
81 void WebStorageAreaImpl::removeItem(const WebString& key, const WebURL& url, Web
String& oldValue) | |
82 { | |
83 ScopedStorageEventURL scope(url); | |
84 oldValue = m_storageArea->removeItem(key, 0); | |
85 } | |
86 | |
87 void WebStorageAreaImpl::clear(const WebURL& url, bool& somethingCleared) | |
88 { | |
89 ScopedStorageEventURL scope(url); | |
90 somethingCleared = m_storageArea->clear(0); | |
91 } | |
92 | |
93 } // namespace WebKit | |
OLD | NEW |