Remove "virtual" from all lines that have both "virtual" and "override".
[WebKit-https.git] / Source / WebKit2 / UIProcess / Network / NetworkProcessProxy.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 NetworkProcessProxy_h
27 #define NetworkProcessProxy_h
28
29 #include "ChildProcessProxy.h"
30 #include "CustomProtocolManagerProxy.h"
31 #include "ProcessLauncher.h"
32 #include "ProcessThrottler.h"
33 #include "ProcessThrottlerClient.h"
34 #include "WebProcessProxyMessages.h"
35 #include <memory>
36 #include <wtf/Deque.h>
37
38 namespace WebCore {
39 class AuthenticationChallenge;
40 class ResourceRequest;
41 class SecurityOrigin;
42 class SessionID;
43 }
44
45 namespace WebKit {
46
47 class DownloadProxy;
48 class DownloadProxyMap;
49 class WebProcessPool;
50 enum class WebsiteDataFetchOption;
51 enum class WebsiteDataType;
52 struct NetworkProcessCreationParameters;
53
54 class NetworkProcessProxy : public ChildProcessProxy, private ProcessThrottlerClient {
55 public:
56     static Ref<NetworkProcessProxy> create(WebProcessPool&);
57     ~NetworkProcessProxy();
58
59     void getNetworkProcessConnection(PassRefPtr<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply>);
60
61     DownloadProxy* createDownloadProxy(const WebCore::ResourceRequest&);
62
63     void fetchWebsiteData(WebCore::SessionID, OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, std::function<void (WebsiteData)> completionHandler);
64     void deleteWebsiteData(WebCore::SessionID, OptionSet<WebsiteDataType>, std::chrono::system_clock::time_point modifiedSince, std::function<void ()> completionHandler);
65     void deleteWebsiteDataForOrigins(WebCore::SessionID, OptionSet<WebKit::WebsiteDataType>, const Vector<RefPtr<WebCore::SecurityOrigin>>& origins, const Vector<String>& cookieHostNames, std::function<void ()> completionHandler);
66
67 #if PLATFORM(COCOA)
68     void setProcessSuppressionEnabled(bool);
69 #endif
70
71     void processReadyToSuspend();
72
73     void setIsHoldingLockedFiles(bool);
74
75     ProcessThrottler& throttler() { return m_throttler; }
76
77 private:
78     NetworkProcessProxy(WebProcessPool&);
79
80     // ChildProcessProxy
81     void getLaunchOptions(ProcessLauncher::LaunchOptions&) override;
82     void connectionWillOpen(IPC::Connection&) override;
83     void processWillShutDown(IPC::Connection&) override;
84
85     void platformGetLaunchOptions(ProcessLauncher::LaunchOptions&);
86     void networkProcessCrashedOrFailedToLaunch();
87
88     // ProcessThrottlerClient
89     void sendProcessWillSuspendImminently() override;
90     void sendPrepareToSuspend() override;
91     void sendCancelPrepareToSuspend() override;
92     void sendProcessDidResume() override;
93     void didSetAssertionState(AssertionState) override;
94
95     // IPC::Connection::Client
96     void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&) override;
97     void didReceiveSyncMessage(IPC::Connection&, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&) override;
98     void didClose(IPC::Connection&) override;
99     void didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName) override;
100     IPC::ProcessType localProcessType() override { return IPC::ProcessType::UI; }
101     IPC::ProcessType remoteProcessType() override { return IPC::ProcessType::Network; }
102
103     // Message handlers
104     void didReceiveNetworkProcessProxyMessage(IPC::Connection&, IPC::MessageDecoder&);
105     void didCreateNetworkConnectionToWebProcess(const IPC::Attachment&);
106     void didReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, const WebCore::AuthenticationChallenge&, uint64_t challengeID);
107     void didFetchWebsiteData(uint64_t callbackID, const WebsiteData&);
108     void didDeleteWebsiteData(uint64_t callbackID);
109     void didDeleteWebsiteDataForOrigins(uint64_t callbackID);
110     void logSampledDiagnosticMessage(uint64_t pageID, const String& message, const String& description);
111     void logSampledDiagnosticMessageWithResult(uint64_t pageID, const String& message, const String& description, uint32_t result);
112     void logSampledDiagnosticMessageWithValue(uint64_t pageID, const String& message, const String& description, const String& value);
113
114     // ProcessLauncher::Client
115     void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) override;
116
117     WebProcessPool& m_processPool;
118     
119     unsigned m_numPendingConnectionRequests;
120     Deque<RefPtr<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply>> m_pendingConnectionReplies;
121
122     HashMap<uint64_t, std::function<void (WebsiteData)>> m_pendingFetchWebsiteDataCallbacks;
123     HashMap<uint64_t, std::function<void ()>> m_pendingDeleteWebsiteDataCallbacks;
124     HashMap<uint64_t, std::function<void ()>> m_pendingDeleteWebsiteDataForOriginsCallbacks;
125
126     std::unique_ptr<DownloadProxyMap> m_downloadProxyMap;
127     CustomProtocolManagerProxy m_customProtocolManagerProxy;
128     ProcessThrottler m_throttler;
129     ProcessThrottler::BackgroundActivityToken m_tokenForHoldingLockedFiles;
130 };
131
132 } // namespace WebKit
133
134 #endif // NetworkProcessProxy_h