1 | /* |
2 | * Copyright (C) 2012-2019 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 | #pragma once |
27 | |
28 | #include "AuxiliaryProcess.h" |
29 | #include "CacheModel.h" |
30 | #include "DownloadManager.h" |
31 | #include "NetworkBlobRegistry.h" |
32 | #include "NetworkContentRuleListManager.h" |
33 | #include "NetworkHTTPSUpgradeChecker.h" |
34 | #include "SandboxExtension.h" |
35 | #include "WebResourceLoadStatisticsStore.h" |
36 | #include "WebsiteData.h" |
37 | #include <WebCore/AdClickAttribution.h> |
38 | #include <WebCore/ClientOrigin.h> |
39 | #include <WebCore/DiagnosticLoggingClient.h> |
40 | #include <WebCore/FetchIdentifier.h> |
41 | #include <WebCore/IDBKeyData.h> |
42 | #include <WebCore/IDBServer.h> |
43 | #include <WebCore/RegistrableDomain.h> |
44 | #include <WebCore/ServiceWorkerIdentifier.h> |
45 | #include <WebCore/ServiceWorkerTypes.h> |
46 | #include <memory> |
47 | #include <wtf/CrossThreadTask.h> |
48 | #include <wtf/Function.h> |
49 | #include <wtf/HashSet.h> |
50 | #include <wtf/MemoryPressureHandler.h> |
51 | #include <wtf/NeverDestroyed.h> |
52 | #include <wtf/RetainPtr.h> |
53 | #include <wtf/WeakPtr.h> |
54 | |
55 | #if PLATFORM(IOS_FAMILY) |
56 | #include "WebSQLiteDatabaseTracker.h" |
57 | #endif |
58 | |
59 | #if PLATFORM(COCOA) |
60 | typedef struct OpaqueCFHTTPCookieStorage* CFHTTPCookieStorageRef; |
61 | #endif |
62 | |
63 | namespace IPC { |
64 | class FormDataReference; |
65 | } |
66 | |
67 | namespace PAL { |
68 | class SessionID; |
69 | } |
70 | |
71 | namespace WebCore { |
72 | class CertificateInfo; |
73 | class CurlProxySettings; |
74 | class DownloadID; |
75 | class ProtectionSpace; |
76 | class StorageQuotaManager; |
77 | class NetworkStorageSession; |
78 | class ResourceError; |
79 | class SWServer; |
80 | enum class IncludeHttpOnlyCookies : bool; |
81 | enum class StoredCredentialsPolicy : uint8_t; |
82 | enum class StorageAccessPromptWasShown : bool; |
83 | enum class StorageAccessWasGranted : bool; |
84 | struct ClientOrigin; |
85 | struct MessageWithMessagePorts; |
86 | struct SecurityOriginData; |
87 | struct SoupNetworkProxySettings; |
88 | struct ServiceWorkerClientIdentifier; |
89 | } |
90 | |
91 | namespace WebKit { |
92 | |
93 | class AuthenticationManager; |
94 | class NetworkConnectionToWebProcess; |
95 | class NetworkProcessSupplement; |
96 | class NetworkProximityManager; |
97 | class NetworkResourceLoader; |
98 | class WebSWServerConnection; |
99 | class WebSWServerToContextConnection; |
100 | enum class ShouldGrandfatherStatistics : bool; |
101 | enum class StorageAccessStatus : uint8_t; |
102 | enum class WebsiteDataFetchOption; |
103 | enum class WebsiteDataType; |
104 | struct NetworkProcessCreationParameters; |
105 | struct WebsiteDataStoreParameters; |
106 | |
107 | #if ENABLE(SERVICE_WORKER) |
108 | class WebSWOriginStore; |
109 | #endif |
110 | |
111 | namespace CacheStorage { |
112 | class Engine; |
113 | } |
114 | |
115 | namespace NetworkCache { |
116 | class Cache; |
117 | } |
118 | |
119 | class NetworkProcess : public AuxiliaryProcess, private DownloadManager::Client, public ThreadSafeRefCounted<NetworkProcess> |
120 | #if ENABLE(INDEXED_DATABASE) |
121 | , public WebCore::IDBServer::IDBBackingStoreTemporaryFileHandler |
122 | #endif |
123 | , public CanMakeWeakPtr<NetworkProcess> |
124 | { |
125 | WTF_MAKE_NONCOPYABLE(NetworkProcess); |
126 | public: |
127 | using RegistrableDomain = WebCore::RegistrableDomain; |
128 | using TopFrameDomain = WebCore::RegistrableDomain; |
129 | using SubFrameDomain = WebCore::RegistrableDomain; |
130 | using SubResourceDomain = WebCore::RegistrableDomain; |
131 | using RedirectDomain = WebCore::RegistrableDomain; |
132 | using RedirectedFromDomain = WebCore::RegistrableDomain; |
133 | using RedirectedToDomain = WebCore::RegistrableDomain; |
134 | using NavigatedFromDomain = WebCore::RegistrableDomain; |
135 | using NavigatedToDomain = WebCore::RegistrableDomain; |
136 | using DomainInNeedOfStorageAccess = WebCore::RegistrableDomain; |
137 | using OpenerDomain = WebCore::RegistrableDomain; |
138 | using OpenerPageID = uint64_t; |
139 | using PageID = uint64_t; |
140 | using FrameID = uint64_t; |
141 | |
142 | NetworkProcess(AuxiliaryProcessInitializationParameters&&); |
143 | ~NetworkProcess(); |
144 | static constexpr ProcessType processType = ProcessType::Network; |
145 | |
146 | template <typename T> |
147 | T* supplement() |
148 | { |
149 | return static_cast<T*>(m_supplements.get(T::supplementName())); |
150 | } |
151 | |
152 | template <typename T> |
153 | void addSupplement() |
154 | { |
155 | m_supplements.add(T::supplementName(), std::make_unique<T>(*this)); |
156 | } |
157 | |
158 | void removeNetworkConnectionToWebProcess(NetworkConnectionToWebProcess&); |
159 | |
160 | AuthenticationManager& authenticationManager(); |
161 | DownloadManager& downloadManager(); |
162 | |
163 | NetworkCache::Cache* cache() { return m_cache.get(); } |
164 | |
165 | void setSession(const PAL::SessionID&, Ref<NetworkSession>&&); |
166 | NetworkSession* networkSession(const PAL::SessionID&) const override; |
167 | void destroySession(const PAL::SessionID&); |
168 | |
169 | // Needed for test infrastructure |
170 | HashMap<PAL::SessionID, Ref<NetworkSession>>& networkSessions() { return m_networkSessions; } |
171 | |
172 | void forEachNetworkStorageSession(const Function<void(WebCore::NetworkStorageSession&)>&); |
173 | WebCore::NetworkStorageSession* storageSession(const PAL::SessionID&) const; |
174 | WebCore::NetworkStorageSession& defaultStorageSession() const; |
175 | void switchToNewTestingSession(); |
176 | #if PLATFORM(COCOA) |
177 | void ensureSession(const PAL::SessionID&, const String& identifier, RetainPtr<CFHTTPCookieStorageRef>&&); |
178 | #else |
179 | void ensureSession(const PAL::SessionID&, const String& identifier); |
180 | #endif |
181 | |
182 | bool canHandleHTTPSServerTrustEvaluation() const { return m_canHandleHTTPSServerTrustEvaluation; } |
183 | |
184 | void processWillSuspendImminently(); |
185 | void prepareToSuspend(); |
186 | void cancelPrepareToSuspend(); |
187 | void processDidResume(); |
188 | void resume(); |
189 | |
190 | // Diagnostic messages logging. |
191 | void logDiagnosticMessage(uint64_t webPageID, const String& message, const String& description, WebCore::ShouldSample); |
192 | void logDiagnosticMessageWithResult(uint64_t webPageID, const String& message, const String& description, WebCore::DiagnosticLoggingResultType, WebCore::ShouldSample); |
193 | void logDiagnosticMessageWithValue(uint64_t webPageID, const String& message, const String& description, double value, unsigned significantFigures, WebCore::ShouldSample); |
194 | |
195 | #if PLATFORM(COCOA) |
196 | RetainPtr<CFDataRef> sourceApplicationAuditData() const; |
197 | void getHostNamesWithHSTSCache(WebCore::NetworkStorageSession&, HashSet<String>&); |
198 | void deleteHSTSCacheForHostNames(WebCore::NetworkStorageSession&, const Vector<String>&); |
199 | void clearHSTSCache(WebCore::NetworkStorageSession&, WallTime modifiedSince); |
200 | bool suppressesConnectionTerminationOnSystemChange() const { return m_suppressesConnectionTerminationOnSystemChange; } |
201 | #endif |
202 | |
203 | void findPendingDownloadLocation(NetworkDataTask&, ResponseCompletionHandler&&, const WebCore::ResourceResponse&); |
204 | |
205 | void prefetchDNS(const String&); |
206 | |
207 | void addWebsiteDataStore(WebsiteDataStoreParameters&&); |
208 | |
209 | #if ENABLE(RESOURCE_LOAD_STATISTICS) |
210 | void clearPrevalentResource(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&); |
211 | void clearUserInteraction(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&); |
212 | void deleteWebsiteDataForRegistrableDomains(PAL::SessionID, OptionSet<WebsiteDataType>, HashMap<RegistrableDomain, WebsiteDataToRemove>&&, bool shouldNotifyPage, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&&); |
213 | void deleteCookiesForTesting(PAL::SessionID, RegistrableDomain, bool includeHttpOnlyCookies, CompletionHandler<void()>&&); |
214 | void dumpResourceLoadStatistics(PAL::SessionID, CompletionHandler<void(String)>&&); |
215 | void updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID, const Vector<RegistrableDomain>& domainsToBlock, CompletionHandler<void()>&&); |
216 | void isGrandfathered(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void(bool)>&&); |
217 | void isPrevalentResource(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void(bool)>&&); |
218 | void isVeryPrevalentResource(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void(bool)>&&); |
219 | void setAgeCapForClientSideCookies(PAL::SessionID, Optional<Seconds>, CompletionHandler<void()>&&); |
220 | void isRegisteredAsRedirectingTo(PAL::SessionID, const RedirectedFromDomain&, const RedirectedToDomain&, CompletionHandler<void(bool)>&&); |
221 | void isRegisteredAsSubFrameUnder(PAL::SessionID, const SubFrameDomain&, const TopFrameDomain&, CompletionHandler<void(bool)>&&); |
222 | void isRegisteredAsSubresourceUnder(PAL::SessionID, const SubResourceDomain&, const TopFrameDomain&, CompletionHandler<void(bool)>&&); |
223 | void setGrandfathered(PAL::SessionID, const RegistrableDomain&, bool isGrandfathered, CompletionHandler<void()>&&); |
224 | void setMaxStatisticsEntries(PAL::SessionID, uint64_t maximumEntryCount, CompletionHandler<void()>&&); |
225 | void setPrevalentResource(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&); |
226 | void setPrevalentResourceForDebugMode(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&); |
227 | void setVeryPrevalentResource(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&); |
228 | void setPruneEntriesDownTo(PAL::SessionID, uint64_t pruneTargetCount, CompletionHandler<void()>&&); |
229 | void hadUserInteraction(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void(bool)>&&); |
230 | void getAllStorageAccessEntries(PAL::SessionID, CompletionHandler<void(Vector<String> domains)>&&); |
231 | void logFrameNavigation(PAL::SessionID, const NavigatedToDomain&, const TopFrameDomain&, const NavigatedFromDomain&, bool isRedirect, bool isMainFrame); |
232 | void logUserInteraction(PAL::SessionID, const TopFrameDomain&, CompletionHandler<void()>&&); |
233 | void removePrevalentDomains(PAL::SessionID, const Vector<RegistrableDomain>&); |
234 | void resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID, CompletionHandler<void()>&&); |
235 | void resetParametersToDefaultValues(PAL::SessionID, CompletionHandler<void()>&&); |
236 | void scheduleClearInMemoryAndPersistent(PAL::SessionID, Optional<WallTime> modifiedSince, ShouldGrandfatherStatistics, CompletionHandler<void()>&&); |
237 | void scheduleCookieBlockingUpdate(PAL::SessionID, CompletionHandler<void()>&&); |
238 | void scheduleStatisticsAndDataRecordsProcessing(PAL::SessionID, CompletionHandler<void()>&&); |
239 | void submitTelemetry(PAL::SessionID, CompletionHandler<void()>&&); |
240 | void setCacheMaxAgeCapForPrevalentResources(PAL::SessionID, Seconds, CompletionHandler<void()>&&); |
241 | void setGrandfatheringTime(PAL::SessionID, Seconds, CompletionHandler<void()>&&); |
242 | void setLastSeen(PAL::SessionID, const RegistrableDomain&, Seconds, CompletionHandler<void()>&&); |
243 | void setMinimumTimeBetweenDataRecordsRemoval(PAL::SessionID, Seconds, CompletionHandler<void()>&&); |
244 | void setNotifyPagesWhenDataRecordsWereScanned(PAL::SessionID, bool value, CompletionHandler<void()>&&); |
245 | void setIsRunningResourceLoadStatisticsTest(PAL::SessionID, bool value, CompletionHandler<void()>&&); |
246 | void setNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID, bool value, CompletionHandler<void()>&&); |
247 | void setResourceLoadStatisticsEnabled(bool); |
248 | void setResourceLoadStatisticsDebugMode(PAL::SessionID, bool debugMode, CompletionHandler<void()>&&d); |
249 | void setShouldClassifyResourcesBeforeDataRecordsRemoval(PAL::SessionID, bool value, CompletionHandler<void()>&&); |
250 | void setSubframeUnderTopFrameDomain(PAL::SessionID, const SubFrameDomain&, const TopFrameDomain&, CompletionHandler<void()>&&); |
251 | void setSubresourceUnderTopFrameDomain(PAL::SessionID, const SubResourceDomain&, const TopFrameDomain&, CompletionHandler<void()>&&); |
252 | void setSubresourceUniqueRedirectTo(PAL::SessionID, const SubResourceDomain&, const RedirectedToDomain&, CompletionHandler<void()>&&); |
253 | void setSubresourceUniqueRedirectFrom(PAL::SessionID, const SubResourceDomain&, const RedirectedFromDomain&, CompletionHandler<void()>&&); |
254 | void setTimeToLiveUserInteraction(PAL::SessionID, Seconds, CompletionHandler<void()>&&); |
255 | void setTopFrameUniqueRedirectTo(PAL::SessionID, const TopFrameDomain&, const RedirectedToDomain&, CompletionHandler<void()>&&); |
256 | void setTopFrameUniqueRedirectFrom(PAL::SessionID, const TopFrameDomain&, const RedirectedFromDomain&, CompletionHandler<void()>&&); |
257 | void registrableDomainsWithWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<RegistrableDomain>&&)>&&); |
258 | void committedCrossSiteLoadWithLinkDecoration(PAL::SessionID, const RegistrableDomain& fromDomain, const RegistrableDomain& toDomain, uint64_t pageID, CompletionHandler<void()>&&); |
259 | void setCrossSiteLoadWithLinkDecorationForTesting(PAL::SessionID, const RegistrableDomain& fromDomain, const RegistrableDomain& toDomain, CompletionHandler<void()>&&); |
260 | void resetCrossSiteLoadsWithLinkDecorationForTesting(PAL::SessionID, CompletionHandler<void()>&&); |
261 | #endif |
262 | |
263 | using CacheStorageRootPathCallback = CompletionHandler<void(String&&)>; |
264 | void cacheStorageRootPath(PAL::SessionID, CacheStorageRootPathCallback&&); |
265 | |
266 | void preconnectTo(const URL&, WebCore::StoredCredentialsPolicy); |
267 | |
268 | void setSessionIsControlledByAutomation(PAL::SessionID, bool); |
269 | bool sessionIsControlledByAutomation(PAL::SessionID) const; |
270 | |
271 | #if ENABLE(CONTENT_EXTENSIONS) |
272 | NetworkContentRuleListManager& networkContentRuleListManager() { return m_networkContentRuleListManager; } |
273 | #endif |
274 | |
275 | #if ENABLE(INDEXED_DATABASE) |
276 | WebCore::IDBServer::IDBServer& idbServer(PAL::SessionID); |
277 | // WebCore::IDBServer::IDBBackingStoreFileHandler. |
278 | void accessToTemporaryFileComplete(const String& path) final; |
279 | void setIDBPerOriginQuota(uint64_t); |
280 | #endif |
281 | void updateQuotaBasedOnSpaceUsageForTesting(PAL::SessionID, const WebCore::ClientOrigin&); |
282 | |
283 | #if ENABLE(SANDBOX_EXTENSIONS) |
284 | void getSandboxExtensionsForBlobFiles(const Vector<String>& filenames, CompletionHandler<void(SandboxExtension::HandleArray&&)>&&); |
285 | #endif |
286 | |
287 | void didReceiveNetworkProcessMessage(IPC::Connection&, IPC::Decoder&); |
288 | |
289 | #if ENABLE(SERVICE_WORKER) |
290 | WebSWServerToContextConnection* serverToContextConnectionForRegistrableDomain(const WebCore::RegistrableDomain&); |
291 | void createServerToContextConnection(const WebCore::RegistrableDomain&, Optional<PAL::SessionID>); |
292 | |
293 | WebCore::SWServer& swServerForSession(PAL::SessionID); |
294 | void registerSWServerConnection(WebSWServerConnection&); |
295 | void unregisterSWServerConnection(WebSWServerConnection&); |
296 | |
297 | void swContextConnectionMayNoLongerBeNeeded(WebSWServerToContextConnection&); |
298 | |
299 | WebSWServerToContextConnection* connectionToContextProcessFromIPCConnection(IPC::Connection&); |
300 | void connectionToContextProcessWasClosed(Ref<WebSWServerToContextConnection>&&); |
301 | #endif |
302 | |
303 | #if PLATFORM(IOS_FAMILY) |
304 | bool parentProcessHasServiceWorkerEntitlement() const; |
305 | #else |
306 | bool parentProcessHasServiceWorkerEntitlement() const { return true; } |
307 | #endif |
308 | |
309 | #if PLATFORM(COCOA) |
310 | NetworkHTTPSUpgradeChecker& networkHTTPSUpgradeChecker() { return m_networkHTTPSUpgradeChecker; } |
311 | #endif |
312 | |
313 | const String& uiProcessBundleIdentifier() const { return m_uiProcessBundleIdentifier; } |
314 | |
315 | void ref() const override { ThreadSafeRefCounted<NetworkProcess>::ref(); } |
316 | void deref() const override { ThreadSafeRefCounted<NetworkProcess>::deref(); } |
317 | |
318 | CacheStorage::Engine* findCacheEngine(const PAL::SessionID&); |
319 | CacheStorage::Engine& ensureCacheEngine(const PAL::SessionID&, Function<Ref<CacheStorage::Engine>()>&&); |
320 | void removeCacheEngine(const PAL::SessionID&); |
321 | void requestStorageSpace(PAL::SessionID, const WebCore::ClientOrigin&, uint64_t quota, uint64_t currentSize, uint64_t spaceRequired, CompletionHandler<void(Optional<uint64_t>)>&&); |
322 | |
323 | NetworkBlobRegistry& networkBlobRegistry() override { return m_networkBlobRegistry; } |
324 | |
325 | void storeAdClickAttribution(PAL::SessionID, WebCore::AdClickAttribution&&); |
326 | void dumpAdClickAttribution(PAL::SessionID, CompletionHandler<void(String)>&&); |
327 | void clearAdClickAttribution(PAL::SessionID, CompletionHandler<void()>&&); |
328 | void setAdClickAttributionOverrideTimerForTesting(PAL::SessionID, bool value, CompletionHandler<void()>&&); |
329 | void setAdClickAttributionConversionURLForTesting(PAL::SessionID, URL&&, CompletionHandler<void()>&&); |
330 | void markAdClickAttributionsAsExpiredForTesting(PAL::SessionID, CompletionHandler<void()>&&); |
331 | |
332 | WebCore::StorageQuotaManager& storageQuotaManager(PAL::SessionID, const WebCore::ClientOrigin&); |
333 | |
334 | void addKeptAliveLoad(Ref<NetworkResourceLoader>&&); |
335 | void removeKeptAliveLoad(NetworkResourceLoader&); |
336 | |
337 | private: |
338 | void platformInitializeNetworkProcess(const NetworkProcessCreationParameters&); |
339 | std::unique_ptr<WebCore::NetworkStorageSession> platformCreateDefaultStorageSession() const; |
340 | |
341 | void terminate() override; |
342 | void platformTerminate(); |
343 | |
344 | void lowMemoryHandler(Critical); |
345 | |
346 | void processDidTransitionToForeground(); |
347 | void processDidTransitionToBackground(); |
348 | void platformProcessDidTransitionToForeground(); |
349 | void platformProcessDidTransitionToBackground(); |
350 | |
351 | enum class ShouldAcknowledgeWhenReadyToSuspend { No, Yes }; |
352 | void actualPrepareToSuspend(ShouldAcknowledgeWhenReadyToSuspend); |
353 | void platformPrepareToSuspend(CompletionHandler<void()>&&); |
354 | void platformProcessDidResume(); |
355 | |
356 | // AuxiliaryProcess |
357 | void initializeProcess(const AuxiliaryProcessInitializationParameters&) override; |
358 | void initializeProcessName(const AuxiliaryProcessInitializationParameters&) override; |
359 | void initializeSandbox(const AuxiliaryProcessInitializationParameters&, SandboxInitializationParameters&) override; |
360 | void initializeConnection(IPC::Connection*) override; |
361 | bool shouldTerminate() override; |
362 | |
363 | // IPC::Connection::Client |
364 | void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override; |
365 | void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) override; |
366 | void didClose(IPC::Connection&) override; |
367 | |
368 | // DownloadManager::Client |
369 | void didCreateDownload() override; |
370 | void didDestroyDownload() override; |
371 | IPC::Connection* downloadProxyConnection() override; |
372 | IPC::Connection* parentProcessConnectionForDownloads() override { return parentProcessConnection(); } |
373 | AuthenticationManager& downloadsAuthenticationManager() override; |
374 | void pendingDownloadCanceled(DownloadID) override; |
375 | uint32_t downloadMonitorSpeedMultiplier() const override { return m_downloadMonitorSpeedMultiplier; } |
376 | |
377 | // Message Handlers |
378 | void didReceiveSyncNetworkProcessMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&); |
379 | void initializeNetworkProcess(NetworkProcessCreationParameters&&); |
380 | void createNetworkConnectionToWebProcess(bool isServiceWorkerProcess, WebCore::RegistrableDomain&&); |
381 | |
382 | void fetchWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, uint64_t callbackID); |
383 | void deleteWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, WallTime modifiedSince, uint64_t callbackID); |
384 | void deleteWebsiteDataForOrigins(PAL::SessionID, OptionSet<WebsiteDataType>, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostnames, uint64_t callbackID); |
385 | |
386 | void clearCachedCredentials(); |
387 | |
388 | void setCacheStorageParameters(PAL::SessionID, String&& cacheStorageDirectory, SandboxExtension::Handle&&); |
389 | void initializeQuotaUsers(WebCore::StorageQuotaManager&, PAL::SessionID, const WebCore::ClientOrigin&); |
390 | |
391 | // FIXME: This should take a session ID so we can identify which disk cache to delete. |
392 | void clearDiskCache(WallTime modifiedSince, CompletionHandler<void()>&&); |
393 | |
394 | void downloadRequest(PAL::SessionID, DownloadID, const WebCore::ResourceRequest&, const String& suggestedFilename); |
395 | void resumeDownload(PAL::SessionID, DownloadID, const IPC::DataReference& resumeData, const String& path, SandboxExtension::Handle&&); |
396 | void cancelDownload(DownloadID); |
397 | #if PLATFORM(COCOA) |
398 | void publishDownloadProgress(DownloadID, const URL&, SandboxExtension::Handle&&); |
399 | #endif |
400 | void continueWillSendRequest(DownloadID, WebCore::ResourceRequest&&); |
401 | void continueDecidePendingDownloadDestination(DownloadID, String destination, SandboxExtension::Handle&&, bool allowOverwrite); |
402 | void applicationDidEnterBackground(); |
403 | void applicationWillEnterForeground(); |
404 | |
405 | void setCacheModel(CacheModel); |
406 | void allowSpecificHTTPSCertificateForHost(const WebCore::CertificateInfo&, const String& host); |
407 | void setCanHandleHTTPSServerTrustEvaluation(bool); |
408 | void getNetworkProcessStatistics(uint64_t callbackID); |
409 | void clearCacheForAllOrigins(uint32_t cachesToClear); |
410 | void setAllowsAnySSLCertificateForWebSocket(bool, CompletionHandler<void()>&&); |
411 | |
412 | void syncAllCookies(); |
413 | void didSyncAllCookies(); |
414 | |
415 | #if USE(SOUP) |
416 | void setIgnoreTLSErrors(bool); |
417 | void userPreferredLanguagesChanged(const Vector<String>&); |
418 | void setNetworkProxySettings(const WebCore::SoupNetworkProxySettings&); |
419 | #endif |
420 | |
421 | #if USE(CURL) |
422 | void setNetworkProxySettings(PAL::SessionID, WebCore::CurlProxySettings&&); |
423 | #endif |
424 | |
425 | #if PLATFORM(MAC) |
426 | static void setSharedHTTPCookieStorage(const Vector<uint8_t>& identifier); |
427 | #endif |
428 | |
429 | void platformSyncAllCookies(CompletionHandler<void()>&&); |
430 | |
431 | void originsWithPersistentCredentials(CompletionHandler<void(Vector<WebCore::SecurityOriginData>)>&&); |
432 | void removeCredentialsWithOrigins(const Vector<WebCore::SecurityOriginData>& origins, CompletionHandler<void()>&&); |
433 | |
434 | void registerURLSchemeAsSecure(const String&) const; |
435 | void registerURLSchemeAsBypassingContentSecurityPolicy(const String&) const; |
436 | void registerURLSchemeAsLocal(const String&) const; |
437 | void registerURLSchemeAsNoAccess(const String&) const; |
438 | void registerURLSchemeAsDisplayIsolated(const String&) const; |
439 | void registerURLSchemeAsCORSEnabled(const String&) const; |
440 | void registerURLSchemeAsCanDisplayOnlyIfCanRequest(const String&) const; |
441 | |
442 | #if ENABLE(INDEXED_DATABASE) |
443 | void addIndexedDatabaseSession(PAL::SessionID, String&, SandboxExtension::Handle&); |
444 | void collectIndexedDatabaseOriginsForVersion(const String&, HashSet<WebCore::SecurityOriginData>&); |
445 | HashSet<WebCore::SecurityOriginData> indexedDatabaseOrigins(const String& path); |
446 | Ref<WebCore::IDBServer::IDBServer> createIDBServer(PAL::SessionID); |
447 | #endif |
448 | |
449 | #if ENABLE(SERVICE_WORKER) |
450 | void didCreateWorkerContextProcessConnection(const IPC::Attachment&); |
451 | |
452 | void postMessageToServiceWorkerClient(const WebCore::ServiceWorkerClientIdentifier& destinationIdentifier, WebCore::MessageWithMessagePorts&&, WebCore::ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin); |
453 | void postMessageToServiceWorker(WebCore::ServiceWorkerIdentifier destination, WebCore::MessageWithMessagePorts&&, const WebCore::ServiceWorkerOrClientIdentifier& source, WebCore::SWServerConnectionIdentifier); |
454 | |
455 | void disableServiceWorkerProcessTerminationDelay(); |
456 | |
457 | WebSWOriginStore& swOriginStoreForSession(PAL::SessionID); |
458 | WebSWOriginStore* existingSWOriginStoreForSession(PAL::SessionID) const; |
459 | bool needsServerToContextConnectionForRegistrableDomain(const WebCore::RegistrableDomain&) const; |
460 | |
461 | void addServiceWorkerSession(PAL::SessionID, String& serviceWorkerRegistrationDirectory, const SandboxExtension::Handle&); |
462 | #endif |
463 | |
464 | void postStorageTask(CrossThreadTask&&); |
465 | // For execution on work queue thread only. |
466 | void performNextStorageTask(); |
467 | void ensurePathExists(const String& path); |
468 | |
469 | void clearStorageQuota(PAL::SessionID); |
470 | void initializeStorageQuota(const WebsiteDataStoreParameters&); |
471 | |
472 | // Connections to WebProcesses. |
473 | Vector<Ref<NetworkConnectionToWebProcess>> m_webProcessConnections; |
474 | |
475 | String m_diskCacheDirectory; |
476 | bool m_hasSetCacheModel { false }; |
477 | CacheModel m_cacheModel { CacheModel::DocumentViewer }; |
478 | bool m_suppressMemoryPressureHandler { false }; |
479 | bool m_diskCacheIsDisabledForTesting { false }; |
480 | bool m_canHandleHTTPSServerTrustEvaluation { true }; |
481 | String m_uiProcessBundleIdentifier; |
482 | DownloadManager m_downloadManager; |
483 | |
484 | HashMap<PAL::SessionID, Ref<CacheStorage::Engine>> m_cacheEngines; |
485 | |
486 | RefPtr<NetworkCache::Cache> m_cache; |
487 | |
488 | typedef HashMap<const char*, std::unique_ptr<NetworkProcessSupplement>, PtrHash<const char*>> NetworkProcessSupplementMap; |
489 | NetworkProcessSupplementMap m_supplements; |
490 | |
491 | HashSet<PAL::SessionID> m_sessionsControlledByAutomation; |
492 | HashMap<PAL::SessionID, Vector<CacheStorageRootPathCallback>> m_cacheStorageParametersCallbacks; |
493 | |
494 | HashMap<PAL::SessionID, Ref<NetworkSession>> m_networkSessions; |
495 | HashMap<PAL::SessionID, std::unique_ptr<WebCore::NetworkStorageSession>> m_networkStorageSessions; |
496 | mutable std::unique_ptr<WebCore::NetworkStorageSession> m_defaultNetworkStorageSession; |
497 | NetworkBlobRegistry m_networkBlobRegistry; |
498 | |
499 | #if PLATFORM(COCOA) |
500 | void platformInitializeNetworkProcessCocoa(const NetworkProcessCreationParameters&); |
501 | void setStorageAccessAPIEnabled(bool); |
502 | |
503 | // FIXME: We'd like to be able to do this without the #ifdef, but WorkQueue + BinarySemaphore isn't good enough since |
504 | // multiple requests to clear the cache can come in before previous requests complete, and we need to wait for all of them. |
505 | // In the future using WorkQueue and a counting semaphore would work, as would WorkQueue supporting the libdispatch concept of "work groups". |
506 | dispatch_group_t m_clearCacheDispatchGroup { nullptr }; |
507 | |
508 | bool m_suppressesConnectionTerminationOnSystemChange { false }; |
509 | #endif |
510 | |
511 | #if ENABLE(CONTENT_EXTENSIONS) |
512 | NetworkContentRuleListManager m_networkContentRuleListManager; |
513 | #endif |
514 | |
515 | #if PLATFORM(IOS_FAMILY) |
516 | WebSQLiteDatabaseTracker m_webSQLiteDatabaseTracker; |
517 | #endif |
518 | |
519 | Ref<WorkQueue> m_storageTaskQueue { WorkQueue::create("com.apple.WebKit.StorageTask" ) }; |
520 | |
521 | #if ENABLE(INDEXED_DATABASE) |
522 | HashMap<PAL::SessionID, String> m_idbDatabasePaths; |
523 | HashMap<PAL::SessionID, RefPtr<WebCore::IDBServer::IDBServer>> m_idbServers; |
524 | uint64_t m_idbPerOriginQuota { WebCore::IDBServer::defaultPerOriginQuota }; |
525 | #endif |
526 | |
527 | Deque<CrossThreadTask> m_storageTasks; |
528 | Lock m_storageTaskMutex; |
529 | |
530 | #if ENABLE(SERVICE_WORKER) |
531 | HashMap<WebCore::RegistrableDomain, RefPtr<WebSWServerToContextConnection>> m_serverToContextConnections; |
532 | bool m_waitingForServerToContextProcessConnection { false }; |
533 | bool m_shouldDisableServiceWorkerProcessTerminationDelay { false }; |
534 | HashMap<PAL::SessionID, String> m_swDatabasePaths; |
535 | HashMap<PAL::SessionID, std::unique_ptr<WebCore::SWServer>> m_swServers; |
536 | HashMap<WebCore::SWServerConnectionIdentifier, WebSWServerConnection*> m_swServerConnections; |
537 | #endif |
538 | |
539 | #if PLATFORM(COCOA) |
540 | NetworkHTTPSUpgradeChecker m_networkHTTPSUpgradeChecker; |
541 | #endif |
542 | |
543 | class StorageQuotaManagers { |
544 | public: |
545 | uint64_t defaultQuota(const WebCore::ClientOrigin& origin) const { return origin.topOrigin == origin.clientOrigin ? m_defaultQuota : m_defaultThirdPartyQuota; } |
546 | void setDefaultQuotas(uint64_t defaultQuota, uint64_t defaultThirdPartyQuota) |
547 | { |
548 | m_defaultQuota = defaultQuota; |
549 | m_defaultThirdPartyQuota = defaultThirdPartyQuota; |
550 | } |
551 | |
552 | HashMap<WebCore::ClientOrigin, std::unique_ptr<WebCore::StorageQuotaManager>>& managersPerOrigin() { return m_managersPerOrigin; } |
553 | |
554 | private: |
555 | uint64_t m_defaultQuota { WebCore::StorageQuotaManager::defaultQuota() }; |
556 | uint64_t m_defaultThirdPartyQuota { WebCore::StorageQuotaManager::defaultThirdPartyQuota() }; |
557 | HashMap<WebCore::ClientOrigin, std::unique_ptr<WebCore::StorageQuotaManager>> m_managersPerOrigin; |
558 | }; |
559 | HashMap<PAL::SessionID, StorageQuotaManagers> m_storageQuotaManagers; |
560 | uint32_t m_downloadMonitorSpeedMultiplier { 1 }; |
561 | }; |
562 | |
563 | } // namespace WebKit |
564 | |