| 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 | #if ENABLE(SERVICE_WORKER) |
| 28 | |
| 29 | #include "ArgumentCoders.h" |
| 30 | #include "Connection.h" |
| 31 | #include <WebCore/FetchIdentifier.h> |
| 32 | #include <WebCore/ServiceWorkerClientData.h> |
| 33 | #include <WebCore/ServiceWorkerData.h> |
| 34 | #include <WebCore/ServiceWorkerIdentifier.h> |
| 35 | #include <WebCore/ServiceWorkerTypes.h> |
| 36 | #include <wtf/Forward.h> |
| 37 | #include <wtf/Optional.h> |
| 38 | #include <wtf/ThreadSafeRefCounted.h> |
| 39 | #include <wtf/Vector.h> |
| 40 | #include <wtf/text/WTFString.h> |
| 41 | |
| 42 | namespace IPC { |
| 43 | class FormDataReference; |
| 44 | } |
| 45 | |
| 46 | namespace PAL { |
| 47 | class SessionID; |
| 48 | } |
| 49 | |
| 50 | namespace WebCore { |
| 51 | struct FetchOptions; |
| 52 | class ResourceRequest; |
| 53 | struct ServiceWorkerContextData; |
| 54 | struct MessageWithMessagePorts; |
| 55 | } |
| 56 | |
| 57 | namespace WebKit { |
| 58 | struct WebPreferencesStore; |
| 59 | } |
| 60 | |
| 61 | namespace Messages { |
| 62 | namespace WebSWContextManagerConnection { |
| 63 | |
| 64 | static inline IPC::StringReference messageReceiverName() |
| 65 | { |
| 66 | return IPC::StringReference("WebSWContextManagerConnection" ); |
| 67 | } |
| 68 | |
| 69 | class InstallServiceWorker { |
| 70 | public: |
| 71 | typedef std::tuple<const WebCore::ServiceWorkerContextData&, const PAL::SessionID&, const String&> Arguments; |
| 72 | |
| 73 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
| 74 | static IPC::StringReference name() { return IPC::StringReference("InstallServiceWorker" ); } |
| 75 | static const bool isSync = false; |
| 76 | |
| 77 | InstallServiceWorker(const WebCore::ServiceWorkerContextData& contextData, const PAL::SessionID& sessionID, const String& userAgent) |
| 78 | : m_arguments(contextData, sessionID, userAgent) |
| 79 | { |
| 80 | } |
| 81 | |
| 82 | const Arguments& arguments() const |
| 83 | { |
| 84 | return m_arguments; |
| 85 | } |
| 86 | |
| 87 | private: |
| 88 | Arguments m_arguments; |
| 89 | }; |
| 90 | |
| 91 | class StartFetch { |
| 92 | public: |
| 93 | typedef std::tuple<const WebCore::SWServerConnectionIdentifier&, const WebCore::ServiceWorkerIdentifier&, const WebCore::FetchIdentifier&, const WebCore::ResourceRequest&, const WebCore::FetchOptions&, const IPC::FormDataReference&, const String&> Arguments; |
| 94 | |
| 95 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
| 96 | static IPC::StringReference name() { return IPC::StringReference("StartFetch" ); } |
| 97 | static const bool isSync = false; |
| 98 | |
| 99 | StartFetch(const WebCore::SWServerConnectionIdentifier& serverConnectionIdentifier, const WebCore::ServiceWorkerIdentifier& serviceWorkerIdentifier, const WebCore::FetchIdentifier& fetchIdentifier, const WebCore::ResourceRequest& request, const WebCore::FetchOptions& options, const IPC::FormDataReference& requestBody, const String& referrer) |
| 100 | : m_arguments(serverConnectionIdentifier, serviceWorkerIdentifier, fetchIdentifier, request, options, requestBody, referrer) |
| 101 | { |
| 102 | } |
| 103 | |
| 104 | const Arguments& arguments() const |
| 105 | { |
| 106 | return m_arguments; |
| 107 | } |
| 108 | |
| 109 | private: |
| 110 | Arguments m_arguments; |
| 111 | }; |
| 112 | |
| 113 | class CancelFetch { |
| 114 | public: |
| 115 | typedef std::tuple<const WebCore::SWServerConnectionIdentifier&, const WebCore::ServiceWorkerIdentifier&, const WebCore::FetchIdentifier&> Arguments; |
| 116 | |
| 117 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
| 118 | static IPC::StringReference name() { return IPC::StringReference("CancelFetch" ); } |
| 119 | static const bool isSync = false; |
| 120 | |
| 121 | CancelFetch(const WebCore::SWServerConnectionIdentifier& serverConnectionIdentifier, const WebCore::ServiceWorkerIdentifier& serviceWorkerIdentifier, const WebCore::FetchIdentifier& fetchIdentifier) |
| 122 | : m_arguments(serverConnectionIdentifier, serviceWorkerIdentifier, fetchIdentifier) |
| 123 | { |
| 124 | } |
| 125 | |
| 126 | const Arguments& arguments() const |
| 127 | { |
| 128 | return m_arguments; |
| 129 | } |
| 130 | |
| 131 | private: |
| 132 | Arguments m_arguments; |
| 133 | }; |
| 134 | |
| 135 | class ContinueDidReceiveFetchResponse { |
| 136 | public: |
| 137 | typedef std::tuple<const WebCore::SWServerConnectionIdentifier&, const WebCore::ServiceWorkerIdentifier&, const WebCore::FetchIdentifier&> Arguments; |
| 138 | |
| 139 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
| 140 | static IPC::StringReference name() { return IPC::StringReference("ContinueDidReceiveFetchResponse" ); } |
| 141 | static const bool isSync = false; |
| 142 | |
| 143 | ContinueDidReceiveFetchResponse(const WebCore::SWServerConnectionIdentifier& serverConnectionIdentifier, const WebCore::ServiceWorkerIdentifier& serviceWorkerIdentifier, const WebCore::FetchIdentifier& fetchIdentifier) |
| 144 | : m_arguments(serverConnectionIdentifier, serviceWorkerIdentifier, fetchIdentifier) |
| 145 | { |
| 146 | } |
| 147 | |
| 148 | const Arguments& arguments() const |
| 149 | { |
| 150 | return m_arguments; |
| 151 | } |
| 152 | |
| 153 | private: |
| 154 | Arguments m_arguments; |
| 155 | }; |
| 156 | |
| 157 | class PostMessageToServiceWorker { |
| 158 | public: |
| 159 | typedef std::tuple<const WebCore::ServiceWorkerIdentifier&, const WebCore::MessageWithMessagePorts&, const WebCore::ServiceWorkerOrClientData&> Arguments; |
| 160 | |
| 161 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
| 162 | static IPC::StringReference name() { return IPC::StringReference("PostMessageToServiceWorker" ); } |
| 163 | static const bool isSync = false; |
| 164 | |
| 165 | PostMessageToServiceWorker(const WebCore::ServiceWorkerIdentifier& destinationIdentifier, const WebCore::MessageWithMessagePorts& message, const WebCore::ServiceWorkerOrClientData& sourceData) |
| 166 | : m_arguments(destinationIdentifier, message, sourceData) |
| 167 | { |
| 168 | } |
| 169 | |
| 170 | const Arguments& arguments() const |
| 171 | { |
| 172 | return m_arguments; |
| 173 | } |
| 174 | |
| 175 | private: |
| 176 | Arguments m_arguments; |
| 177 | }; |
| 178 | |
| 179 | class FireInstallEvent { |
| 180 | public: |
| 181 | typedef std::tuple<const WebCore::ServiceWorkerIdentifier&> Arguments; |
| 182 | |
| 183 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
| 184 | static IPC::StringReference name() { return IPC::StringReference("FireInstallEvent" ); } |
| 185 | static const bool isSync = false; |
| 186 | |
| 187 | explicit FireInstallEvent(const WebCore::ServiceWorkerIdentifier& identifier) |
| 188 | : m_arguments(identifier) |
| 189 | { |
| 190 | } |
| 191 | |
| 192 | const Arguments& arguments() const |
| 193 | { |
| 194 | return m_arguments; |
| 195 | } |
| 196 | |
| 197 | private: |
| 198 | Arguments m_arguments; |
| 199 | }; |
| 200 | |
| 201 | class FireActivateEvent { |
| 202 | public: |
| 203 | typedef std::tuple<const WebCore::ServiceWorkerIdentifier&> Arguments; |
| 204 | |
| 205 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
| 206 | static IPC::StringReference name() { return IPC::StringReference("FireActivateEvent" ); } |
| 207 | static const bool isSync = false; |
| 208 | |
| 209 | explicit FireActivateEvent(const WebCore::ServiceWorkerIdentifier& identifier) |
| 210 | : m_arguments(identifier) |
| 211 | { |
| 212 | } |
| 213 | |
| 214 | const Arguments& arguments() const |
| 215 | { |
| 216 | return m_arguments; |
| 217 | } |
| 218 | |
| 219 | private: |
| 220 | Arguments m_arguments; |
| 221 | }; |
| 222 | |
| 223 | class TerminateWorker { |
| 224 | public: |
| 225 | typedef std::tuple<const WebCore::ServiceWorkerIdentifier&> Arguments; |
| 226 | |
| 227 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
| 228 | static IPC::StringReference name() { return IPC::StringReference("TerminateWorker" ); } |
| 229 | static const bool isSync = false; |
| 230 | |
| 231 | explicit TerminateWorker(const WebCore::ServiceWorkerIdentifier& identifier) |
| 232 | : m_arguments(identifier) |
| 233 | { |
| 234 | } |
| 235 | |
| 236 | const Arguments& arguments() const |
| 237 | { |
| 238 | return m_arguments; |
| 239 | } |
| 240 | |
| 241 | private: |
| 242 | Arguments m_arguments; |
| 243 | }; |
| 244 | |
| 245 | class SyncTerminateWorker { |
| 246 | public: |
| 247 | typedef std::tuple<const WebCore::ServiceWorkerIdentifier&> Arguments; |
| 248 | |
| 249 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
| 250 | static IPC::StringReference name() { return IPC::StringReference("SyncTerminateWorker" ); } |
| 251 | static const bool isSync = true; |
| 252 | |
| 253 | using DelayedReply = CompletionHandler<void()>; |
| 254 | static void send(std::unique_ptr<IPC::Encoder>&&, IPC::Connection&); |
| 255 | using Reply = std::tuple<>; |
| 256 | using ReplyArguments = std::tuple<>; |
| 257 | explicit SyncTerminateWorker(const WebCore::ServiceWorkerIdentifier& identifier) |
| 258 | : m_arguments(identifier) |
| 259 | { |
| 260 | } |
| 261 | |
| 262 | const Arguments& arguments() const |
| 263 | { |
| 264 | return m_arguments; |
| 265 | } |
| 266 | |
| 267 | private: |
| 268 | Arguments m_arguments; |
| 269 | }; |
| 270 | |
| 271 | class FindClientByIdentifierCompleted { |
| 272 | public: |
| 273 | typedef std::tuple<uint64_t, const Optional<WebCore::ServiceWorkerClientData>&, bool> Arguments; |
| 274 | |
| 275 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
| 276 | static IPC::StringReference name() { return IPC::StringReference("FindClientByIdentifierCompleted" ); } |
| 277 | static const bool isSync = false; |
| 278 | |
| 279 | FindClientByIdentifierCompleted(uint64_t clientIdRequestIdentifier, const Optional<WebCore::ServiceWorkerClientData>& data, bool hasSecurityError) |
| 280 | : m_arguments(clientIdRequestIdentifier, data, hasSecurityError) |
| 281 | { |
| 282 | } |
| 283 | |
| 284 | const Arguments& arguments() const |
| 285 | { |
| 286 | return m_arguments; |
| 287 | } |
| 288 | |
| 289 | private: |
| 290 | Arguments m_arguments; |
| 291 | }; |
| 292 | |
| 293 | class MatchAllCompleted { |
| 294 | public: |
| 295 | typedef std::tuple<uint64_t, const Vector<WebCore::ServiceWorkerClientData>&> Arguments; |
| 296 | |
| 297 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
| 298 | static IPC::StringReference name() { return IPC::StringReference("MatchAllCompleted" ); } |
| 299 | static const bool isSync = false; |
| 300 | |
| 301 | MatchAllCompleted(uint64_t matchAllRequestIdentifier, const Vector<WebCore::ServiceWorkerClientData>& clientsData) |
| 302 | : m_arguments(matchAllRequestIdentifier, clientsData) |
| 303 | { |
| 304 | } |
| 305 | |
| 306 | const Arguments& arguments() const |
| 307 | { |
| 308 | return m_arguments; |
| 309 | } |
| 310 | |
| 311 | private: |
| 312 | Arguments m_arguments; |
| 313 | }; |
| 314 | |
| 315 | class ClaimCompleted { |
| 316 | public: |
| 317 | typedef std::tuple<uint64_t> Arguments; |
| 318 | |
| 319 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
| 320 | static IPC::StringReference name() { return IPC::StringReference("ClaimCompleted" ); } |
| 321 | static const bool isSync = false; |
| 322 | |
| 323 | explicit ClaimCompleted(uint64_t claimRequestIdentifier) |
| 324 | : m_arguments(claimRequestIdentifier) |
| 325 | { |
| 326 | } |
| 327 | |
| 328 | const Arguments& arguments() const |
| 329 | { |
| 330 | return m_arguments; |
| 331 | } |
| 332 | |
| 333 | private: |
| 334 | Arguments m_arguments; |
| 335 | }; |
| 336 | |
| 337 | class DidFinishSkipWaiting { |
| 338 | public: |
| 339 | typedef std::tuple<uint64_t> Arguments; |
| 340 | |
| 341 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
| 342 | static IPC::StringReference name() { return IPC::StringReference("DidFinishSkipWaiting" ); } |
| 343 | static const bool isSync = false; |
| 344 | |
| 345 | explicit DidFinishSkipWaiting(uint64_t callbackID) |
| 346 | : m_arguments(callbackID) |
| 347 | { |
| 348 | } |
| 349 | |
| 350 | const Arguments& arguments() const |
| 351 | { |
| 352 | return m_arguments; |
| 353 | } |
| 354 | |
| 355 | private: |
| 356 | Arguments m_arguments; |
| 357 | }; |
| 358 | |
| 359 | class SetUserAgent { |
| 360 | public: |
| 361 | typedef std::tuple<const String&> Arguments; |
| 362 | |
| 363 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
| 364 | static IPC::StringReference name() { return IPC::StringReference("SetUserAgent" ); } |
| 365 | static const bool isSync = false; |
| 366 | |
| 367 | explicit SetUserAgent(const String& userAgent) |
| 368 | : m_arguments(userAgent) |
| 369 | { |
| 370 | } |
| 371 | |
| 372 | const Arguments& arguments() const |
| 373 | { |
| 374 | return m_arguments; |
| 375 | } |
| 376 | |
| 377 | private: |
| 378 | Arguments m_arguments; |
| 379 | }; |
| 380 | |
| 381 | class UpdatePreferencesStore { |
| 382 | public: |
| 383 | typedef std::tuple<const WebKit::WebPreferencesStore&> Arguments; |
| 384 | |
| 385 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
| 386 | static IPC::StringReference name() { return IPC::StringReference("UpdatePreferencesStore" ); } |
| 387 | static const bool isSync = false; |
| 388 | |
| 389 | explicit UpdatePreferencesStore(const WebKit::WebPreferencesStore& store) |
| 390 | : m_arguments(store) |
| 391 | { |
| 392 | } |
| 393 | |
| 394 | const Arguments& arguments() const |
| 395 | { |
| 396 | return m_arguments; |
| 397 | } |
| 398 | |
| 399 | private: |
| 400 | Arguments m_arguments; |
| 401 | }; |
| 402 | |
| 403 | class TerminateProcess { |
| 404 | public: |
| 405 | typedef std::tuple<> Arguments; |
| 406 | |
| 407 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
| 408 | static IPC::StringReference name() { return IPC::StringReference("TerminateProcess" ); } |
| 409 | static const bool isSync = false; |
| 410 | |
| 411 | const Arguments& arguments() const |
| 412 | { |
| 413 | return m_arguments; |
| 414 | } |
| 415 | |
| 416 | private: |
| 417 | Arguments m_arguments; |
| 418 | }; |
| 419 | |
| 420 | class SetThrottleState { |
| 421 | public: |
| 422 | typedef std::tuple<bool> Arguments; |
| 423 | |
| 424 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
| 425 | static IPC::StringReference name() { return IPC::StringReference("SetThrottleState" ); } |
| 426 | static const bool isSync = false; |
| 427 | |
| 428 | explicit SetThrottleState(bool isThrottleable) |
| 429 | : m_arguments(isThrottleable) |
| 430 | { |
| 431 | } |
| 432 | |
| 433 | const Arguments& arguments() const |
| 434 | { |
| 435 | return m_arguments; |
| 436 | } |
| 437 | |
| 438 | private: |
| 439 | Arguments m_arguments; |
| 440 | }; |
| 441 | |
| 442 | } // namespace WebSWContextManagerConnection |
| 443 | } // namespace Messages |
| 444 | |
| 445 | #endif // ENABLE(SERVICE_WORKER) |
| 446 | |