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