df9ee2a36a2359acf9b7cd5f542cf229f42d7524
[WebKit-https.git] / Source / WebKit / UIProcess / WebProcessPool.h
1 /*
2  * Copyright (C) 2010-2016 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 "APIDictionary.h"
29 #include "APIObject.h"
30 #include "APIProcessPoolConfiguration.h"
31 #include "APIWebsiteDataStore.h"
32 #include "DownloadProxyMap.h"
33 #include "GenericCallback.h"
34 #include "HiddenPageThrottlingAutoIncreasesCounter.h"
35 #include "MessageReceiver.h"
36 #include "MessageReceiverMap.h"
37 #include "NetworkProcessProxy.h"
38 #include "PlugInAutoStartProvider.h"
39 #include "PluginInfoStore.h"
40 #include "ProcessThrottler.h"
41 #include "StatisticsRequest.h"
42 #include "StorageProcessProxy.h"
43 #include "VisitedLinkStore.h"
44 #include "WebContextClient.h"
45 #include "WebContextConnectionClient.h"
46 #include "WebProcessProxy.h"
47 #include <WebCore/LinkHash.h>
48 #include <WebCore/SessionID.h>
49 #include <wtf/Forward.h>
50 #include <wtf/HashMap.h>
51 #include <wtf/HashSet.h>
52 #include <wtf/RefCounter.h>
53 #include <wtf/RefPtr.h>
54 #include <wtf/text/StringHash.h>
55 #include <wtf/text/WTFString.h>
56
57 #if ENABLE(MEDIA_SESSION)
58 #include "WebMediaSessionFocusManager.h"
59 #endif
60
61 #if USE(SOUP)
62 #include <WebCore/SoupNetworkProxySettings.h>
63 #endif
64
65 #if PLATFORM(COCOA)
66 OBJC_CLASS NSMutableDictionary;
67 OBJC_CLASS NSObject;
68 OBJC_CLASS NSString;
69 #endif
70
71 namespace API {
72 class AutomationClient;
73 class CustomProtocolManagerClient;
74 class DownloadClient;
75 class HTTPCookieStore;
76 class InjectedBundleClient;
77 class LegacyContextHistoryClient;
78 class PageConfiguration;
79 }
80
81 namespace WebKit {
82
83 class DownloadProxy;
84 class HighPerformanceGraphicsUsageSampler;
85 class UIGamepad;
86 class PerActivityStateCPUUsageSampler;
87 class WebAutomationSession;
88 class WebContextSupplement;
89 class WebPageGroup;
90 class WebPageProxy;
91 struct NetworkProcessCreationParameters;
92 struct StatisticsData;
93 struct WebProcessCreationParameters;
94     
95 typedef GenericCallback<API::Dictionary*> DictionaryCallback;
96
97 #if PLATFORM(COCOA)
98 int networkProcessLatencyQOS();
99 int networkProcessThroughputQOS();
100 int webProcessLatencyQOS();
101 int webProcessThroughputQOS();
102 #endif
103
104 class WebProcessPool final : public API::ObjectImpl<API::Object::Type::ProcessPool>, private IPC::MessageReceiver
105     {
106 public:
107     static Ref<WebProcessPool> create(API::ProcessPoolConfiguration&);
108
109     explicit WebProcessPool(API::ProcessPoolConfiguration&);        
110     virtual ~WebProcessPool();
111
112     void notifyThisWebProcessPoolWasCreated();
113
114     API::ProcessPoolConfiguration& configuration() { return m_configuration.get(); }
115
116     static const Vector<WebProcessPool*>& allProcessPools();
117
118     template <typename T>
119     T* supplement()
120     {
121         return static_cast<T*>(m_supplements.get(T::supplementName()));
122     }
123
124     template <typename T>
125     void addSupplement()
126     {
127         m_supplements.add(T::supplementName(), T::create(this));
128     }
129
130     void addMessageReceiver(IPC::StringReference messageReceiverName, IPC::MessageReceiver&);
131     void addMessageReceiver(IPC::StringReference messageReceiverName, uint64_t destinationID, IPC::MessageReceiver&);
132     void removeMessageReceiver(IPC::StringReference messageReceiverName);
133     void removeMessageReceiver(IPC::StringReference messageReceiverName, uint64_t destinationID);
134
135     bool dispatchMessage(IPC::Connection&, IPC::Decoder&);
136     bool dispatchSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&);
137
138     void initializeClient(const WKContextClientBase*);
139     void setInjectedBundleClient(std::unique_ptr<API::InjectedBundleClient>&&);
140     void initializeConnectionClient(const WKContextConnectionClientBase*);
141     void setHistoryClient(std::unique_ptr<API::LegacyContextHistoryClient>&&);
142     void setDownloadClient(std::unique_ptr<API::DownloadClient>&&);
143     void setAutomationClient(std::unique_ptr<API::AutomationClient>&&);
144     void setLegacyCustomProtocolManagerClient(std::unique_ptr<API::CustomProtocolManagerClient>&&);
145
146     void setMaximumNumberOfProcesses(unsigned); // Can only be called when there are no processes running.
147     unsigned maximumNumberOfProcesses() const { return !m_configuration->maximumProcessCount() ? UINT_MAX : m_configuration->maximumProcessCount(); }
148
149     const Vector<RefPtr<WebProcessProxy>>& processes() const { return m_processes; }
150
151     // WebProcess or NetworkProcess as approporiate for current process model. The connection must be non-null.
152     IPC::Connection* networkingProcessConnection();
153
154     template<typename T> void sendToAllProcesses(const T& message);
155     template<typename T> void sendToAllProcessesRelaunchingThemIfNecessary(const T& message);
156     template<typename T> void sendToOneProcess(T&& message);
157
158     // Sends the message to WebProcess or NetworkProcess as approporiate for current process model.
159     template<typename T> void sendToNetworkingProcess(T&& message);
160     template<typename T, typename U> void sendSyncToNetworkingProcess(T&& message, U&& reply);
161     template<typename T> void sendToNetworkingProcessRelaunchingIfNecessary(T&& message);
162
163     // Sends the message to WebProcess or DatabaseProcess as approporiate for current process model.
164     template<typename T> void sendToDatabaseProcessRelaunchingIfNecessary(T&& message);
165
166     void processDidFinishLaunching(WebProcessProxy*);
167
168     // Disconnect the process from the context.
169     void disconnectProcess(WebProcessProxy*);
170
171     API::WebsiteDataStore& websiteDataStore() const { return m_websiteDataStore.get(); }
172
173     Ref<WebPageProxy> createWebPage(PageClient&, Ref<API::PageConfiguration>&&);
174
175     void pageAddedToProcess(WebPageProxy&);
176     void pageRemovedFromProcess(WebPageProxy&);
177
178     const String& injectedBundlePath() const { return m_configuration->injectedBundlePath(); }
179
180     DownloadProxy* download(WebPageProxy* initiatingPage, const WebCore::ResourceRequest&, const String& suggestedFilename = { });
181     DownloadProxy* resumeDownload(const API::Data* resumeData, const String& path);
182
183     void setInjectedBundleInitializationUserData(RefPtr<API::Object>&& userData) { m_injectedBundleInitializationUserData = WTFMove(userData); }
184
185     void postMessageToInjectedBundle(const String&, API::Object*);
186
187     void populateVisitedLinks();
188
189 #if ENABLE(NETSCAPE_PLUGIN_API)
190     void setAdditionalPluginsDirectory(const String&);
191     void refreshPlugins();
192
193     PluginInfoStore& pluginInfoStore() { return m_pluginInfoStore; }
194
195     void setPluginLoadClientPolicy(WebCore::PluginLoadClientPolicy, const String& host, const String& bundleIdentifier, const String& versionString);
196     void resetPluginLoadClientPolicies(HashMap<String, HashMap<String, HashMap<String, uint8_t>>>&&);
197     void clearPluginClientPolicies();
198     const HashMap<String, HashMap<String, HashMap<String, uint8_t>>>& pluginLoadClientPolicies() const { return m_pluginLoadClientPolicies; }
199 #endif
200
201     pid_t networkProcessIdentifier();
202     pid_t databaseProcessIdentifier();
203
204     void setAlwaysUsesComplexTextCodePath(bool);
205     void setShouldUseFontSmoothing(bool);
206     
207     void registerURLSchemeAsEmptyDocument(const String&);
208     void registerURLSchemeAsSecure(const String&);
209     void registerURLSchemeAsBypassingContentSecurityPolicy(const String&);
210     void setDomainRelaxationForbiddenForURLScheme(const String&);
211     void setCanHandleHTTPSServerTrustEvaluation(bool);
212     void registerURLSchemeAsLocal(const String&);
213     void registerURLSchemeAsNoAccess(const String&);
214     void registerURLSchemeAsDisplayIsolated(const String&);
215     void registerURLSchemeAsCORSEnabled(const String&);
216     void registerURLSchemeAsCachePartitioned(const String&);
217
218     VisitedLinkStore& visitedLinkStore() { return m_visitedLinkStore.get(); }
219
220     void setCacheModel(CacheModel);
221     CacheModel cacheModel() const { return m_configuration->cacheModel(); }
222
223     void setDefaultRequestTimeoutInterval(double);
224
225     void startMemorySampler(const double interval);
226     void stopMemorySampler();
227
228 #if USE(SOUP)
229     void setInitialHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy) { m_initialHTTPCookieAcceptPolicy = policy; }
230     void setNetworkProxySettings(const WebCore::SoupNetworkProxySettings&);
231 #endif
232     void setEnhancedAccessibility(bool);
233     
234     // Downloads.
235     DownloadProxy* createDownloadProxy(const WebCore::ResourceRequest&);
236     API::DownloadClient& downloadClient() { return *m_downloadClient; }
237
238     API::LegacyContextHistoryClient& historyClient() { return *m_historyClient; }
239     WebContextClient& client() { return m_client; }
240
241     API::CustomProtocolManagerClient& customProtocolManagerClient() const { return *m_customProtocolManagerClient; }
242
243     struct Statistics {
244         unsigned wkViewCount;
245         unsigned wkPageCount;
246         unsigned wkFrameCount;
247     };
248     static Statistics& statistics();    
249
250     void setCookieStorageDirectory(const String& dir) { m_overrideCookieStorageDirectory = dir; }
251
252     void useTestingNetworkSession();
253     bool isUsingTestingNetworkSession() const { return m_shouldUseTestingNetworkSession; }
254
255     void setAllowsAnySSLCertificateForWebSocket(bool);
256
257     void clearCachedCredentials();
258     void terminateDatabaseProcess();
259     void terminateNetworkProcess();
260
261     void syncNetworkProcessCookies();
262
263     void reportWebContentCPUTime(Seconds cpuTime, uint64_t activityState);
264
265     void allowSpecificHTTPSCertificateForHost(const WebCertificateInfo*, const String& host);
266
267     WebProcessProxy& createNewWebProcessRespectingProcessCountLimit(WebsiteDataStore&); // Will return an existing one if limit is met.
268     void warmInitialProcess();
269
270     bool shouldTerminate(WebProcessProxy*);
271
272     void disableProcessTermination() { m_processTerminationEnabled = false; }
273     void enableProcessTermination();
274
275     void updateAutomationCapabilities() const;
276     void setAutomationSession(RefPtr<WebAutomationSession>&&);
277     WebAutomationSession* automationSession() const { return m_automationSession.get(); }
278
279     // Defaults to false.
280     void setHTTPPipeliningEnabled(bool);
281     bool httpPipeliningEnabled() const;
282
283     void getStatistics(uint32_t statisticsMask, Function<void (API::Dictionary*, CallbackBase::Error)>&&);
284     
285     bool javaScriptConfigurationFileEnabled() { return m_javaScriptConfigurationFileEnabled; }
286     void setJavaScriptConfigurationFileEnabled(bool flag);
287 #if PLATFORM(IOS)
288     void setJavaScriptConfigurationFileEnabledFromDefaults();
289 #endif
290
291     void garbageCollectJavaScriptObjects();
292     void setJavaScriptGarbageCollectorTimerEnabled(bool flag);
293
294 #if PLATFORM(COCOA)
295     static bool omitPDFSupport();
296 #endif
297
298     void fullKeyboardAccessModeChanged(bool fullKeyboardAccessEnabled);
299
300     void textCheckerStateChanged();
301
302     Ref<API::Dictionary> plugInAutoStartOriginHashes() const;
303     void setPlugInAutoStartOriginHashes(API::Dictionary&);
304     void setPlugInAutoStartOrigins(API::Array&);
305     void setPlugInAutoStartOriginsFilteringOutEntriesAddedAfterTime(API::Dictionary&, double time);
306
307     // Network Process Management
308     NetworkProcessProxy& ensureNetworkProcess(WebsiteDataStore* withWebsiteDataStore = nullptr);
309     NetworkProcessProxy* networkProcess() { return m_networkProcess.get(); }
310     void networkProcessCrashed(NetworkProcessProxy&, Vector<Ref<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply>>&&);
311     void networkProcessFailedToLaunch(NetworkProcessProxy&);
312
313     void getNetworkProcessConnection(Ref<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply>&&);
314
315     void ensureDatabaseProcessAndWebsiteDataStore(WebsiteDataStore* relevantDataStore);
316     StorageProcessProxy* databaseProcess() { return m_databaseProcess.get(); }
317     void getDatabaseProcessConnection(Ref<Messages::WebProcessProxy::GetDatabaseProcessConnection::DelayedReply>&&);
318     void databaseProcessCrashed(StorageProcessProxy*);
319
320 #if PLATFORM(COCOA)
321     bool processSuppressionEnabled() const;
322 #endif
323
324     void windowServerConnectionStateChanged();
325
326     static void willStartUsingPrivateBrowsing();
327     static void willStopUsingPrivateBrowsing();
328
329 #if USE(SOUP)
330     void setIgnoreTLSErrors(bool);
331     bool ignoreTLSErrors() const { return m_ignoreTLSErrors; }
332 #endif
333
334     static void setInvalidMessageCallback(void (*)(WKStringRef));
335     static void didReceiveInvalidMessage(const IPC::StringReference& messageReceiverName, const IPC::StringReference& messageName);
336
337     void processDidCachePage(WebProcessProxy*);
338
339     bool isURLKnownHSTSHost(const String& urlString, bool privateBrowsingEnabled) const;
340     void resetHSTSHosts();
341     void resetHSTSHostsAddedAfterDate(double startDateIntervalSince1970);
342
343     void registerSchemeForCustomProtocol(const String&);
344     void unregisterSchemeForCustomProtocol(const String&);
345
346     static void registerGlobalURLSchemeAsHavingCustomProtocolHandlers(const String&);
347     static void unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers(const String&);
348
349 #if PLATFORM(COCOA)
350     void updateProcessSuppressionState();
351
352     NSMutableDictionary *ensureBundleParameters();
353     NSMutableDictionary *bundleParameters() { return m_bundleParameters.get(); }
354 #else
355     void updateProcessSuppressionState() const { }
356 #endif
357
358     void updateHiddenPageThrottlingAutoIncreaseLimit();
359
360     void setMemoryCacheDisabled(bool);
361     void setFontWhitelist(API::Array*);
362
363     UserObservablePageCounter::Token userObservablePageCount()
364     {
365         return m_userObservablePageCounter.count();
366     }
367
368     ProcessSuppressionDisabledToken processSuppressionDisabledForPageCount()
369     {
370         return m_processSuppressionDisabledForPageCounter.count();
371     }
372
373     HiddenPageThrottlingAutoIncreasesCounter::Token hiddenPageThrottlingAutoIncreasesCount()
374     {
375         return m_hiddenPageThrottlingAutoIncreasesCounter.count();
376     }
377
378     // FIXME: Move these to API::WebsiteDataStore.
379     static String legacyPlatformDefaultLocalStorageDirectory();
380     static String legacyPlatformDefaultIndexedDBDatabaseDirectory();
381     static String legacyPlatformDefaultWebSQLDatabaseDirectory();
382     static String legacyPlatformDefaultMediaKeysStorageDirectory();
383     static String legacyPlatformDefaultMediaCacheDirectory();
384     static String legacyPlatformDefaultApplicationCacheDirectory();
385     static String legacyPlatformDefaultNetworkCacheDirectory();
386     static String legacyPlatformDefaultJavaScriptConfigurationDirectory();
387     static bool isNetworkCacheEnabled();
388
389     bool resourceLoadStatisticsEnabled() { return m_resourceLoadStatisticsEnabled; }
390     void setResourceLoadStatisticsEnabled(bool);
391
392     bool alwaysRunsAtBackgroundPriority() const { return m_alwaysRunsAtBackgroundPriority; }
393     bool shouldTakeUIBackgroundAssertion() const { return m_shouldTakeUIBackgroundAssertion; }
394
395 #if ENABLE(GAMEPAD)
396     void gamepadConnected(const UIGamepad&);
397     void gamepadDisconnected(const UIGamepad&);
398
399     void setInitialConnectedGamepads(const Vector<std::unique_ptr<UIGamepad>>&);
400 #endif
401
402 #if PLATFORM(COCOA)
403     bool cookieStoragePartitioningEnabled() const { return m_cookieStoragePartitioningEnabled; }
404     void setCookieStoragePartitioningEnabled(bool);
405 #endif
406
407     static uint64_t registerProcessPoolCreationListener(Function<void(WebProcessPool&)>&&);
408     static void unregisterProcessPoolCreationListener(uint64_t identifier);
409
410 private:
411     void platformInitialize();
412
413     void platformInitializeWebProcess(WebProcessCreationParameters&);
414     void platformInvalidateContext();
415
416     WebProcessProxy& createNewWebProcess(WebsiteDataStore&);
417
418     void requestWebContentStatistics(StatisticsRequest*);
419     void requestNetworkingStatistics(StatisticsRequest*);
420
421     void platformInitializeNetworkProcess(NetworkProcessCreationParameters&);
422
423     void handleMessage(IPC::Connection&, const String& messageName, const UserData& messageBody);
424     void handleSynchronousMessage(IPC::Connection&, const String& messageName, const UserData& messageBody, UserData& returnUserData);
425
426     void didGetStatistics(const StatisticsData&, uint64_t callbackID);
427
428 #if ENABLE(GAMEPAD)
429     void startedUsingGamepads(IPC::Connection&);
430     void stoppedUsingGamepads(IPC::Connection&);
431
432     void processStoppedUsingGamepads(WebProcessProxy&);
433 #endif
434
435     // IPC::MessageReceiver.
436     // Implemented in generated WebProcessPoolMessageReceiver.cpp
437     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
438     void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) override;
439
440     static void languageChanged(void* context);
441     void languageChanged();
442
443 #if PLATFORM(IOS)
444     String cookieStorageDirectory() const;
445 #endif
446
447 #if PLATFORM(IOS)
448     String parentBundleDirectory() const;
449     String networkingCachesDirectory() const;
450     String webContentCachesDirectory() const;
451     String containerTemporaryDirectory() const;
452 #endif
453
454 #if PLATFORM(COCOA)
455     void registerNotificationObservers();
456     void unregisterNotificationObservers();
457 #endif
458
459     void addPlugInAutoStartOriginHash(const String& pageOrigin, unsigned plugInOriginHash, WebCore::SessionID);
460     void plugInDidReceiveUserInteraction(unsigned plugInOriginHash, WebCore::SessionID);
461
462     void setAnyPageGroupMightHavePrivateBrowsingEnabled(bool);
463
464     void resolvePathsForSandboxExtensions();
465     void platformResolvePathsForSandboxExtensions();
466
467     Ref<API::ProcessPoolConfiguration> m_configuration;
468
469     IPC::MessageReceiverMap m_messageReceiverMap;
470
471     Vector<RefPtr<WebProcessProxy>> m_processes;
472     bool m_haveInitialEmptyProcess;
473
474     WebProcessProxy* m_processWithPageCache;
475
476     Ref<WebPageGroup> m_defaultPageGroup;
477
478     RefPtr<API::Object> m_injectedBundleInitializationUserData;
479     std::unique_ptr<API::InjectedBundleClient> m_injectedBundleClient;
480
481     WebContextClient m_client;
482     WebContextConnectionClient m_connectionClient;
483     std::unique_ptr<API::AutomationClient> m_automationClient;
484     std::unique_ptr<API::DownloadClient> m_downloadClient;
485     std::unique_ptr<API::LegacyContextHistoryClient> m_historyClient;
486     std::unique_ptr<API::CustomProtocolManagerClient> m_customProtocolManagerClient;
487
488     RefPtr<WebAutomationSession> m_automationSession;
489
490 #if ENABLE(NETSCAPE_PLUGIN_API)
491     PluginInfoStore m_pluginInfoStore;
492 #endif
493     Ref<VisitedLinkStore> m_visitedLinkStore;
494     bool m_visitedLinksPopulated;
495
496     PlugInAutoStartProvider m_plugInAutoStartProvider;
497         
498     HashSet<String> m_schemesToRegisterAsEmptyDocument;
499     HashSet<String> m_schemesToRegisterAsSecure;
500     HashSet<String> m_schemesToRegisterAsBypassingContentSecurityPolicy;
501     HashSet<String> m_schemesToSetDomainRelaxationForbiddenFor;
502     HashSet<String> m_schemesToRegisterAsLocal;
503     HashSet<String> m_schemesToRegisterAsNoAccess;
504     HashSet<String> m_schemesToRegisterAsDisplayIsolated;
505     HashSet<String> m_schemesToRegisterAsCORSEnabled;
506     HashSet<String> m_schemesToRegisterAsAlwaysRevalidated;
507     HashSet<String> m_schemesToRegisterAsCachePartitioned;
508
509     bool m_alwaysUsesComplexTextCodePath;
510     bool m_shouldUseFontSmoothing;
511
512     Vector<String> m_fontWhitelist;
513
514     // Messages that were posted before any pages were created.
515     // The client should use initialization messages instead, so that a restarted process would get the same state.
516     Vector<std::pair<String, RefPtr<API::Object>>> m_messagesToInjectedBundlePostedToEmptyContext;
517
518     bool m_memorySamplerEnabled;
519     double m_memorySamplerInterval;
520
521     const Ref<API::WebsiteDataStore> m_websiteDataStore;
522
523     typedef HashMap<const char*, RefPtr<WebContextSupplement>, PtrHash<const char*>> WebContextSupplementMap;
524     WebContextSupplementMap m_supplements;
525
526 #if USE(SOUP)
527     HTTPCookieAcceptPolicy m_initialHTTPCookieAcceptPolicy { HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain };
528     WebCore::SoupNetworkProxySettings m_networkProxySettings;
529 #endif
530     HashSet<String, ASCIICaseInsensitiveHash> m_urlSchemesRegisteredForCustomProtocols;
531
532 #if PLATFORM(MAC)
533     RetainPtr<NSObject> m_enhancedAccessibilityObserver;
534     RetainPtr<NSObject> m_automaticTextReplacementNotificationObserver;
535     RetainPtr<NSObject> m_automaticSpellingCorrectionNotificationObserver;
536     RetainPtr<NSObject> m_automaticQuoteSubstitutionNotificationObserver;
537     RetainPtr<NSObject> m_automaticDashSubstitutionNotificationObserver;
538
539     std::unique_ptr<HighPerformanceGraphicsUsageSampler> m_highPerformanceGraphicsUsageSampler;
540     std::unique_ptr<PerActivityStateCPUUsageSampler> m_perActivityStateCPUUsageSampler;
541 #endif
542
543     String m_overrideCookieStorageDirectory;
544
545     bool m_shouldUseTestingNetworkSession;
546
547     bool m_processTerminationEnabled;
548
549     bool m_canHandleHTTPSServerTrustEvaluation;
550     bool m_didNetworkProcessCrash;
551     RefPtr<NetworkProcessProxy> m_networkProcess;
552     RefPtr<StorageProcessProxy> m_databaseProcess;
553
554     HashMap<uint64_t, RefPtr<DictionaryCallback>> m_dictionaryCallbacks;
555     HashMap<uint64_t, RefPtr<StatisticsRequest>> m_statisticsRequests;
556
557 #if USE(SOUP)
558     bool m_ignoreTLSErrors { true };
559 #endif
560
561     bool m_memoryCacheDisabled;
562     bool m_resourceLoadStatisticsEnabled { false };
563     bool m_javaScriptConfigurationFileEnabled { false };
564     bool m_alwaysRunsAtBackgroundPriority;
565     bool m_shouldTakeUIBackgroundAssertion;
566
567     UserObservablePageCounter m_userObservablePageCounter;
568     ProcessSuppressionDisabledCounter m_processSuppressionDisabledForPageCounter;
569     HiddenPageThrottlingAutoIncreasesCounter m_hiddenPageThrottlingAutoIncreasesCounter;
570     RunLoop::Timer<WebProcessPool> m_hiddenPageThrottlingTimer;
571
572 #if PLATFORM(COCOA)
573     RetainPtr<NSMutableDictionary> m_bundleParameters;
574     ProcessSuppressionDisabledToken m_pluginProcessManagerProcessSuppressionDisabledToken;
575 #endif
576
577 #if ENABLE(CONTENT_EXTENSIONS)
578     HashMap<String, String> m_encodedContentExtensions;
579 #endif
580
581 #if ENABLE(NETSCAPE_PLUGIN_API)
582     HashMap<String, HashMap<String, HashMap<String, uint8_t>>> m_pluginLoadClientPolicies;
583 #endif
584
585 #if ENABLE(GAMEPAD)
586     HashSet<WebProcessProxy*> m_processesUsingGamepads;
587 #endif
588
589 #if PLATFORM(COCOA)
590     bool m_cookieStoragePartitioningEnabled { false };
591 #endif
592
593     struct Paths {
594         String injectedBundlePath;
595         String applicationCacheDirectory;
596         String webSQLDatabaseDirectory;
597         String mediaCacheDirectory;
598         String mediaKeyStorageDirectory;
599         String uiProcessBundleResourcePath;
600         String indexedDatabaseDirectory;
601
602 #if PLATFORM(IOS)
603         String cookieStorageDirectory;
604         String containerCachesDirectory;
605         String containerTemporaryDirectory;
606 #endif
607
608         Vector<String> additionalWebProcessSandboxExtensionPaths;
609     };
610     Paths m_resolvedPaths;
611
612     HashMap<WebCore::SessionID, HashSet<WebPageProxy*>> m_sessionToPagesMap;
613 };
614
615 template<typename T>
616 void WebProcessPool::sendToNetworkingProcess(T&& message)
617 {
618     if (m_networkProcess && m_networkProcess->canSendMessage())
619         m_networkProcess->send(std::forward<T>(message), 0);
620 }
621
622 template<typename T>
623 void WebProcessPool::sendToNetworkingProcessRelaunchingIfNecessary(T&& message)
624 {
625     ensureNetworkProcess();
626     m_networkProcess->send(std::forward<T>(message), 0);
627 }
628
629 template<typename T>
630 void WebProcessPool::sendToDatabaseProcessRelaunchingIfNecessary(T&& message)
631 {
632     ensureDatabaseProcessAndWebsiteDataStore(nullptr);
633     m_databaseProcess->send(std::forward<T>(message), 0);
634 }
635
636 template<typename T>
637 void WebProcessPool::sendToAllProcesses(const T& message)
638 {
639     size_t processCount = m_processes.size();
640     for (size_t i = 0; i < processCount; ++i) {
641         WebProcessProxy* process = m_processes[i].get();
642         if (process->canSendMessage())
643             process->send(T(message), 0);
644     }
645 }
646
647 template<typename T>
648 void WebProcessPool::sendToAllProcessesRelaunchingThemIfNecessary(const T& message)
649 {
650     // FIXME (Multi-WebProcess): WebProcessPool doesn't track processes that have exited, so it cannot relaunch these. Perhaps this functionality won't be needed in this mode.
651     sendToAllProcesses(message);
652 }
653
654 template<typename T>
655 void WebProcessPool::sendToOneProcess(T&& message)
656 {
657     bool messageSent = false;
658     size_t processCount = m_processes.size();
659     for (size_t i = 0; i < processCount; ++i) {
660         WebProcessProxy* process = m_processes[i].get();
661         if (process->canSendMessage()) {
662             process->send(std::forward<T>(message), 0);
663             messageSent = true;
664             break;
665         }
666     }
667
668     if (!messageSent) {
669         warmInitialProcess();
670         RefPtr<WebProcessProxy> process = m_processes.last();
671         if (process->canSendMessage())
672             process->send(std::forward<T>(message), 0);
673     }
674 }
675
676 } // namespace WebKit