2 * Copyright (C) 2017 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
28 #if ENABLE(SERVICE_WORKER)
30 #include "Connection.h"
31 #include "MessageReceiver.h"
32 #include <WebCore/ServiceWorkerThreadProxy.h>
33 #include <wtf/HashMap.h>
37 class ResourceRequest;
38 struct ServiceWorkerContextData;
42 struct WebPreferencesStore;
44 class ServiceWorkerContextManager : public IPC::MessageReceiver {
46 ServiceWorkerContextManager(Ref<IPC::Connection>&&, uint64_t pageID, const WebPreferencesStore&);
48 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
51 void updatePreferences(const WebPreferencesStore&);
53 void startServiceWorker(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData&);
54 void startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, WebCore::ResourceRequest&&, WebCore::FetchOptions&&);
55 void postMessageToServiceWorkerGlobalScope(uint64_t serverConnectionIdentifier, uint64_t serviceWorkerIdentifier, const IPC::DataReference& message, const String& sourceOrigin);
57 Ref<IPC::Connection> m_connectionToStorageProcess;
58 HashMap<uint64_t, RefPtr<WebCore::ServiceWorkerThreadProxy>> m_workerMap;
59 uint64_t m_pageID { 0 };
60 uint64_t m_previousServiceWorkerID { 0 };
65 #endif // ENABLE(SERVICE_WORKER)