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