Add types for DownloadID and TaskIdentifier
[WebKit-https.git] / Source / WebKit2 / NetworkProcess / NetworkConnectionToWebProcess.h
1 /*
2  * Copyright (C) 2012 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 #ifndef NetworkConnectionToWebProcess_h
27 #define NetworkConnectionToWebProcess_h
28
29 #include "BlockingResponseMap.h"
30 #include "Connection.h"
31 #include "DownloadID.h"
32 #include "NetworkConnectionToWebProcessMessages.h"
33 #include <WebCore/ResourceLoadPriority.h>
34 #include <wtf/HashSet.h>
35 #include <wtf/RefCounted.h>
36
37 namespace WebCore {
38 class ResourceRequest;
39 }
40
41 namespace WebKit {
42
43 class NetworkConnectionToWebProcess;
44 class NetworkResourceLoader;
45 class SyncNetworkResourceLoader;
46 typedef uint64_t ResourceLoadIdentifier;
47
48 class NetworkConnectionToWebProcess : public RefCounted<NetworkConnectionToWebProcess>, IPC::Connection::Client {
49 public:
50     static Ref<NetworkConnectionToWebProcess> create(IPC::Connection::Identifier);
51     virtual ~NetworkConnectionToWebProcess();
52
53     IPC::Connection* connection() const { return m_connection.get(); }
54
55     void didCleanupResourceLoader(NetworkResourceLoader&);
56
57 private:
58     NetworkConnectionToWebProcess(IPC::Connection::Identifier);
59
60     // IPC::Connection::Client
61     virtual void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&) override;
62     virtual void didReceiveSyncMessage(IPC::Connection&, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&) override;
63     virtual void didClose(IPC::Connection&) override;
64     virtual void didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName) override;
65     virtual IPC::ProcessType localProcessType() override { return IPC::ProcessType::Network; }
66     virtual IPC::ProcessType remoteProcessType() override { return IPC::ProcessType::Web; }
67
68     // Message handlers.
69     void didReceiveNetworkConnectionToWebProcessMessage(IPC::Connection&, IPC::MessageDecoder&);
70     void didReceiveSyncNetworkConnectionToWebProcessMessage(IPC::Connection&, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&);
71     
72     void scheduleResourceLoad(const NetworkResourceLoadParameters&);
73     void performSynchronousLoad(const NetworkResourceLoadParameters&, RefPtr<Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad::DelayedReply>&&);
74     void loadPing(const NetworkResourceLoadParameters&);
75     void prefetchDNS(const String&);
76
77     void removeLoadIdentifier(ResourceLoadIdentifier);
78     void setDefersLoading(ResourceLoadIdentifier, bool);
79     void crossOriginRedirectReceived(ResourceLoadIdentifier, const WebCore::URL& redirectURL);
80     void startDownload(WebCore::SessionID, DownloadID, const WebCore::ResourceRequest&);
81     void convertMainResourceLoadToDownload(WebCore::SessionID, uint64_t mainResourceLoadIdentifier, DownloadID, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
82
83     void cookiesForDOM(WebCore::SessionID, const WebCore::URL& firstParty, const WebCore::URL&, String& result);
84     void setCookiesFromDOM(WebCore::SessionID, const WebCore::URL& firstParty, const WebCore::URL&, const String&);
85     void cookiesEnabled(WebCore::SessionID, const WebCore::URL& firstParty, const WebCore::URL&, bool& result);
86     void cookieRequestHeaderFieldValue(WebCore::SessionID, const WebCore::URL& firstParty, const WebCore::URL&, String& result);
87     void getRawCookies(WebCore::SessionID, const WebCore::URL& firstParty, const WebCore::URL&, Vector<WebCore::Cookie>&);
88     void deleteCookie(WebCore::SessionID, const WebCore::URL&, const String& cookieName);
89
90     void registerFileBlobURL(const WebCore::URL&, const String& path, const SandboxExtension::Handle&, const String& contentType);
91     void registerBlobURL(const WebCore::URL&, Vector<WebCore::BlobPart>, const String& contentType);
92     void registerBlobURLFromURL(const WebCore::URL&, const WebCore::URL& srcURL);
93     void registerBlobURLForSlice(const WebCore::URL&, const WebCore::URL& srcURL, int64_t start, int64_t end);
94     void blobSize(const WebCore::URL&, uint64_t& resultSize);
95     void unregisterBlobURL(const WebCore::URL&);
96
97     RefPtr<IPC::Connection> m_connection;
98
99     HashMap<ResourceLoadIdentifier, RefPtr<NetworkResourceLoader>> m_networkResourceLoaders;
100 };
101
102 } // namespace WebKit
103
104 #endif // NetworkConnectionToWebProcess_h