1 | /* |
2 | * Copyright (C) 2013 Apple 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 |
6 | * are met: |
7 | * 1. Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. |
9 | * 2. Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. |
12 | * |
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
23 | * THE POSSIBILITY OF SUCH DAMAGE. |
24 | */ |
25 | |
26 | #include "config.h" |
27 | #include "StorageAreaImpl.h" |
28 | |
29 | #include "StorageAreaMap.h" |
30 | #include <WebCore/Document.h> |
31 | #include <WebCore/Frame.h> |
32 | #include <WebCore/Page.h> |
33 | #include <WebCore/SchemeRegistry.h> |
34 | #include <WebCore/SecurityOriginData.h> |
35 | #include <WebCore/Settings.h> |
36 | |
37 | namespace WebKit { |
38 | using namespace WebCore; |
39 | |
40 | static uint64_t generateStorageAreaID() |
41 | { |
42 | static uint64_t storageAreaID; |
43 | return ++storageAreaID; |
44 | } |
45 | |
46 | Ref<StorageAreaImpl> StorageAreaImpl::create(Ref<StorageAreaMap>&& storageAreaMap) |
47 | { |
48 | return adoptRef(*new StorageAreaImpl(WTFMove(storageAreaMap))); |
49 | } |
50 | |
51 | StorageAreaImpl::StorageAreaImpl(Ref<StorageAreaMap>&& storageAreaMap) |
52 | : m_storageAreaID(generateStorageAreaID()) |
53 | , m_storageAreaMap(WTFMove(storageAreaMap)) |
54 | { |
55 | } |
56 | |
57 | StorageAreaImpl::~StorageAreaImpl() |
58 | { |
59 | } |
60 | |
61 | unsigned StorageAreaImpl::length() |
62 | { |
63 | return m_storageAreaMap->length(); |
64 | } |
65 | |
66 | String StorageAreaImpl::key(unsigned index) |
67 | { |
68 | return m_storageAreaMap->key(index); |
69 | } |
70 | |
71 | String StorageAreaImpl::item(const String& key) |
72 | { |
73 | return m_storageAreaMap->item(key); |
74 | } |
75 | |
76 | void StorageAreaImpl::setItem(Frame* sourceFrame, const String& key, const String& value, bool& quotaException) |
77 | { |
78 | ASSERT(!value.isNull()); |
79 | |
80 | m_storageAreaMap->setItem(sourceFrame, this, key, value, quotaException); |
81 | } |
82 | |
83 | void StorageAreaImpl::removeItem(Frame* sourceFrame, const String& key) |
84 | { |
85 | m_storageAreaMap->removeItem(sourceFrame, this, key); |
86 | } |
87 | |
88 | void StorageAreaImpl::clear(Frame* sourceFrame) |
89 | { |
90 | m_storageAreaMap->clear(sourceFrame, this); |
91 | } |
92 | |
93 | bool StorageAreaImpl::contains(const String& key) |
94 | { |
95 | return m_storageAreaMap->contains(key); |
96 | } |
97 | |
98 | StorageType StorageAreaImpl::storageType() const |
99 | { |
100 | return m_storageAreaMap->storageType(); |
101 | } |
102 | |
103 | size_t StorageAreaImpl::memoryBytesUsedByCache() |
104 | { |
105 | return 0; |
106 | } |
107 | |
108 | void StorageAreaImpl::incrementAccessCount() |
109 | { |
110 | // Storage access is handled in the UI process, so there's nothing to do here. |
111 | } |
112 | |
113 | void StorageAreaImpl::decrementAccessCount() |
114 | { |
115 | // Storage access is handled in the UI process, so there's nothing to do here. |
116 | } |
117 | |
118 | void StorageAreaImpl::closeDatabaseIfIdle() |
119 | { |
120 | // FIXME: Implement this. |
121 | ASSERT_NOT_REACHED(); |
122 | } |
123 | |
124 | const SecurityOriginData& StorageAreaImpl::securityOrigin() const |
125 | { |
126 | return m_storageAreaMap->securityOrigin().data(); |
127 | } |
128 | |
129 | } // namespace WebKit |
130 | |