Remove "virtual" from all lines that have both "virtual" and "override".
[WebKit-https.git] / Source / WebKit2 / NetworkProcess / NetworkLoad.h
1 /*
2  * Copyright (C) 2015 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 NetworkLoad_h
27 #define NetworkLoad_h
28
29 #include "NetworkLoadClient.h"
30 #include "NetworkLoadParameters.h"
31 #include "RemoteNetworkingContext.h"
32 #include <WebCore/ResourceHandleClient.h>
33
34 #if USE(NETWORK_SESSION)
35 #include "DownloadID.h"
36 #include "NetworkSession.h"
37 #include <WebCore/AuthenticationChallenge.h>
38 #endif
39
40 namespace WebKit {
41
42 class NetworkLoad : public WebCore::ResourceHandleClient
43 #if USE(NETWORK_SESSION)
44     , public NetworkDataTaskClient
45 #endif
46 {
47 public:
48     NetworkLoad(NetworkLoadClient&, const NetworkLoadParameters&);
49     ~NetworkLoad();
50
51     void setDefersLoading(bool);
52     void cancel();
53
54     const WebCore::ResourceRequest& currentRequest() const { return m_currentRequest; }
55     void clearCurrentRequest() { m_currentRequest = WebCore::ResourceRequest(); }
56
57     void continueWillSendRequest(const WebCore::ResourceRequest&);
58     void continueDidReceiveResponse();
59
60 #if USE(NETWORK_SESSION)
61     void convertTaskToDownload(DownloadID);
62     void setPendingDownloadID(DownloadID);
63     void setPendingDownload(PendingDownload&);
64     DownloadID pendingDownloadID() { return m_task->pendingDownloadID(); }
65     
66     // NetworkDataTaskClient
67     void willPerformHTTPRedirection(const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, RedirectCompletionHandler) final override;
68     void didReceiveChallenge(const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler) final override;
69     void didReceiveResponseNetworkSession(const WebCore::ResourceResponse&, ResponseCompletionHandler) final override;
70     void didReceiveData(RefPtr<WebCore::SharedBuffer>&&) final override;
71     void didCompleteWithError(const WebCore::ResourceError&) final override;
72     void didBecomeDownload() final override;
73     void didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend) override;
74     void wasBlocked() override;
75     void cannotShowURL() override;
76 #endif
77     // ResourceHandleClient
78     void willSendRequestAsync(WebCore::ResourceHandle*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse) override;
79     void didSendData(WebCore::ResourceHandle*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) override;
80     void didReceiveResponseAsync(WebCore::ResourceHandle*, const WebCore::ResourceResponse&) override;
81     void didReceiveData(WebCore::ResourceHandle*, const char*, unsigned, int encodedDataLength) override;
82     void didReceiveBuffer(WebCore::ResourceHandle*, PassRefPtr<WebCore::SharedBuffer>, int encodedDataLength) override;
83     void didFinishLoading(WebCore::ResourceHandle*, double finishTime) override;
84     void didFail(WebCore::ResourceHandle*, const WebCore::ResourceError&) override;
85     void wasBlocked(WebCore::ResourceHandle*) override;
86     void cannotShowURL(WebCore::ResourceHandle*) override;
87     bool shouldUseCredentialStorage(WebCore::ResourceHandle*) override;
88     void didReceiveAuthenticationChallenge(WebCore::ResourceHandle*, const WebCore::AuthenticationChallenge&) override;
89     void didCancelAuthenticationChallenge(WebCore::ResourceHandle*, const WebCore::AuthenticationChallenge&) override;
90     void receivedCancellation(WebCore::ResourceHandle*, const WebCore::AuthenticationChallenge&) override;
91     bool usesAsyncCallbacks() override { return true; }
92     bool loadingSynchronousXHR() override { return m_client.isSynchronous(); }
93
94 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
95     void canAuthenticateAgainstProtectionSpaceAsync(WebCore::ResourceHandle*, const WebCore::ProtectionSpace&) override;
96 #endif
97 #if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
98     bool supportsDataArray() override;
99     void didReceiveDataArray(WebCore::ResourceHandle*, CFArrayRef) override;
100 #endif
101 #if PLATFORM(COCOA)
102 #if USE(CFNETWORK)
103     void willCacheResponseAsync(WebCore::ResourceHandle*, CFCachedURLResponseRef) override;
104 #else
105     void willCacheResponseAsync(WebCore::ResourceHandle*, NSCachedURLResponse *) override;
106 #endif
107 #endif
108
109 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
110     void continueCanAuthenticateAgainstProtectionSpace(bool);
111 #endif
112
113 #if !USE(NETWORK_SESSION)
114     WebCore::ResourceHandle* handle() const { return m_handle.get(); }
115 #endif
116
117 private:
118     NetworkLoadClient::ShouldContinueDidReceiveResponse sharedDidReceiveResponse(const WebCore::ResourceResponse&);
119     void sharedWillSendRedirectedRequest(const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
120
121     NetworkLoadClient& m_client;
122     const NetworkLoadParameters m_parameters;
123 #if USE(NETWORK_SESSION)
124     RefPtr<NetworkDataTask> m_task;
125     WebCore::AuthenticationChallenge m_challenge;
126     ChallengeCompletionHandler m_challengeCompletionHandler;
127     ResponseCompletionHandler m_responseCompletionHandler;
128     RedirectCompletionHandler m_redirectCompletionHandler;
129 #else
130     RefPtr<RemoteNetworkingContext> m_networkingContext;
131 #endif
132     RefPtr<WebCore::ResourceHandle> m_handle;
133
134     WebCore::ResourceRequest m_currentRequest; // Updated on redirects.
135 };
136
137 } // namespace WebKit
138
139 #endif // NetworkLoad_h