1 | /* |
2 | * Copyright (C) 2010-2018 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'' AND |
14 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
16 | * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR |
17 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
20 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
21 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
22 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 | */ |
24 | |
25 | #pragma once |
26 | |
27 | #include "ArgumentCoders.h" |
28 | #include "Connection.h" |
29 | #include <wtf/Forward.h> |
30 | #include <wtf/HashMap.h> |
31 | #include <wtf/ThreadSafeRefCounted.h> |
32 | #include <wtf/text/WTFString.h> |
33 | |
34 | namespace WebCore { |
35 | struct SecurityOriginData; |
36 | } |
37 | |
38 | namespace Messages { |
39 | namespace StorageManager { |
40 | |
41 | static inline IPC::StringReference messageReceiverName() |
42 | { |
43 | return IPC::StringReference("StorageManager" ); |
44 | } |
45 | |
46 | class CreateLocalStorageMap { |
47 | public: |
48 | typedef std::tuple<uint64_t, uint64_t, const WebCore::SecurityOriginData&> Arguments; |
49 | |
50 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
51 | static IPC::StringReference name() { return IPC::StringReference("CreateLocalStorageMap" ); } |
52 | static const bool isSync = false; |
53 | |
54 | CreateLocalStorageMap(uint64_t storageMapID, uint64_t storageNamespaceID, const WebCore::SecurityOriginData& securityOriginData) |
55 | : m_arguments(storageMapID, storageNamespaceID, securityOriginData) |
56 | { |
57 | } |
58 | |
59 | const Arguments& arguments() const |
60 | { |
61 | return m_arguments; |
62 | } |
63 | |
64 | private: |
65 | Arguments m_arguments; |
66 | }; |
67 | |
68 | class CreateTransientLocalStorageMap { |
69 | public: |
70 | typedef std::tuple<uint64_t, uint64_t, const WebCore::SecurityOriginData&, const WebCore::SecurityOriginData&> Arguments; |
71 | |
72 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
73 | static IPC::StringReference name() { return IPC::StringReference("CreateTransientLocalStorageMap" ); } |
74 | static const bool isSync = false; |
75 | |
76 | CreateTransientLocalStorageMap(uint64_t storageMapID, uint64_t storageNamespaceID, const WebCore::SecurityOriginData& topLevelSecurityOriginData, const WebCore::SecurityOriginData& securityOriginData) |
77 | : m_arguments(storageMapID, storageNamespaceID, topLevelSecurityOriginData, securityOriginData) |
78 | { |
79 | } |
80 | |
81 | const Arguments& arguments() const |
82 | { |
83 | return m_arguments; |
84 | } |
85 | |
86 | private: |
87 | Arguments m_arguments; |
88 | }; |
89 | |
90 | class CreateSessionStorageMap { |
91 | public: |
92 | typedef std::tuple<uint64_t, uint64_t, const WebCore::SecurityOriginData&> Arguments; |
93 | |
94 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
95 | static IPC::StringReference name() { return IPC::StringReference("CreateSessionStorageMap" ); } |
96 | static const bool isSync = false; |
97 | |
98 | CreateSessionStorageMap(uint64_t storageMapID, uint64_t storageNamespaceID, const WebCore::SecurityOriginData& securityOriginData) |
99 | : m_arguments(storageMapID, storageNamespaceID, securityOriginData) |
100 | { |
101 | } |
102 | |
103 | const Arguments& arguments() const |
104 | { |
105 | return m_arguments; |
106 | } |
107 | |
108 | private: |
109 | Arguments m_arguments; |
110 | }; |
111 | |
112 | class DestroyStorageMap { |
113 | public: |
114 | typedef std::tuple<uint64_t> Arguments; |
115 | |
116 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
117 | static IPC::StringReference name() { return IPC::StringReference("DestroyStorageMap" ); } |
118 | static const bool isSync = false; |
119 | |
120 | explicit DestroyStorageMap(uint64_t storageMapID) |
121 | : m_arguments(storageMapID) |
122 | { |
123 | } |
124 | |
125 | const Arguments& arguments() const |
126 | { |
127 | return m_arguments; |
128 | } |
129 | |
130 | private: |
131 | Arguments m_arguments; |
132 | }; |
133 | |
134 | class GetValues { |
135 | public: |
136 | typedef std::tuple<const WebCore::SecurityOriginData&, uint64_t, uint64_t> Arguments; |
137 | |
138 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
139 | static IPC::StringReference name() { return IPC::StringReference("GetValues" ); } |
140 | static const bool isSync = true; |
141 | |
142 | using DelayedReply = CompletionHandler<void(const HashMap<String, String>& values)>; |
143 | static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&, const HashMap<String, String>& values); |
144 | using Reply = std::tuple<HashMap<String, String>&>; |
145 | using ReplyArguments = std::tuple<HashMap<String, String>>; |
146 | GetValues(const WebCore::SecurityOriginData& securityOriginData, uint64_t storageMapID, uint64_t storageMapSeed) |
147 | : m_arguments(securityOriginData, storageMapID, storageMapSeed) |
148 | { |
149 | } |
150 | |
151 | const Arguments& arguments() const |
152 | { |
153 | return m_arguments; |
154 | } |
155 | |
156 | private: |
157 | Arguments m_arguments; |
158 | }; |
159 | |
160 | class SetItem { |
161 | public: |
162 | typedef std::tuple<const WebCore::SecurityOriginData&, uint64_t, uint64_t, uint64_t, const String&, const String&, const String&> Arguments; |
163 | |
164 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
165 | static IPC::StringReference name() { return IPC::StringReference("SetItem" ); } |
166 | static const bool isSync = false; |
167 | |
168 | SetItem(const WebCore::SecurityOriginData& securityOriginData, uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, const String& key, const String& value, const String& urlString) |
169 | : m_arguments(securityOriginData, storageMapID, sourceStorageAreaID, storageMapSeed, key, value, urlString) |
170 | { |
171 | } |
172 | |
173 | const Arguments& arguments() const |
174 | { |
175 | return m_arguments; |
176 | } |
177 | |
178 | private: |
179 | Arguments m_arguments; |
180 | }; |
181 | |
182 | class SetItems { |
183 | public: |
184 | typedef std::tuple<uint64_t, const HashMap<String, String>&> Arguments; |
185 | |
186 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
187 | static IPC::StringReference name() { return IPC::StringReference("SetItems" ); } |
188 | static const bool isSync = false; |
189 | |
190 | SetItems(uint64_t storageMapID, const HashMap<String, String>& items) |
191 | : m_arguments(storageMapID, items) |
192 | { |
193 | } |
194 | |
195 | const Arguments& arguments() const |
196 | { |
197 | return m_arguments; |
198 | } |
199 | |
200 | private: |
201 | Arguments m_arguments; |
202 | }; |
203 | |
204 | class RemoveItem { |
205 | public: |
206 | typedef std::tuple<const WebCore::SecurityOriginData&, uint64_t, uint64_t, uint64_t, const String&, const String&> Arguments; |
207 | |
208 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
209 | static IPC::StringReference name() { return IPC::StringReference("RemoveItem" ); } |
210 | static const bool isSync = false; |
211 | |
212 | RemoveItem(const WebCore::SecurityOriginData& securityOriginData, uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, const String& key, const String& urlString) |
213 | : m_arguments(securityOriginData, storageMapID, sourceStorageAreaID, storageMapSeed, key, urlString) |
214 | { |
215 | } |
216 | |
217 | const Arguments& arguments() const |
218 | { |
219 | return m_arguments; |
220 | } |
221 | |
222 | private: |
223 | Arguments m_arguments; |
224 | }; |
225 | |
226 | class Clear { |
227 | public: |
228 | typedef std::tuple<const WebCore::SecurityOriginData&, uint64_t, uint64_t, uint64_t, const String&> Arguments; |
229 | |
230 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
231 | static IPC::StringReference name() { return IPC::StringReference("Clear" ); } |
232 | static const bool isSync = false; |
233 | |
234 | Clear(const WebCore::SecurityOriginData& securityOriginData, uint64_t storageMapID, uint64_t sourceStorageAreaID, uint64_t storageMapSeed, const String& urlString) |
235 | : m_arguments(securityOriginData, storageMapID, sourceStorageAreaID, storageMapSeed, urlString) |
236 | { |
237 | } |
238 | |
239 | const Arguments& arguments() const |
240 | { |
241 | return m_arguments; |
242 | } |
243 | |
244 | private: |
245 | Arguments m_arguments; |
246 | }; |
247 | |
248 | } // namespace StorageManager |
249 | } // namespace Messages |
250 | |