[PSON] Introduce a WebContent Process cache
[WebKit-https.git] / Source / WebKit / UIProcess / API / APIProcessPoolConfiguration.h
1 /*
2  * Copyright (C) 2014 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 "APIObject.h"
29 #include "CacheModel.h"
30 #include "WebsiteDataStore.h"
31 #include <wtf/ProcessID.h>
32 #include <wtf/Ref.h>
33 #include <wtf/Vector.h>
34 #include <wtf/text/CString.h>
35 #include <wtf/text/WTFString.h>
36
37 namespace API {
38
39 #if PLATFORM(COCOA) && !PLATFORM(IOS_FAMILY_SIMULATOR)
40 #define DEFAULT_CAPTURE_DISPLAY_IN_UI_PROCESS true
41 #else
42 #define DEFAULT_CAPTURE_DISPLAY_IN_UI_PROCESS false
43 #endif
44
45 class ProcessPoolConfiguration final : public ObjectImpl<Object::Type::ProcessPoolConfiguration> {
46 public:
47     static Ref<ProcessPoolConfiguration> create();
48     static Ref<ProcessPoolConfiguration> createWithLegacyOptions();
49     static Ref<ProcessPoolConfiguration> createWithWebsiteDataStoreConfiguration(const WebKit::WebsiteDataStoreConfiguration&);
50
51     explicit ProcessPoolConfiguration();
52     virtual ~ProcessPoolConfiguration();
53     
54     Ref<ProcessPoolConfiguration> copy();
55
56     bool shouldHaveLegacyDataStore() const { return m_shouldHaveLegacyDataStore; }
57     void setShouldHaveLegacyDataStore(bool shouldHaveLegacyDataStore) { m_shouldHaveLegacyDataStore = shouldHaveLegacyDataStore; }
58
59     bool usesSingleWebProcess() const { return m_usesSingleWebProcess; }
60     void setUsesSingleWebProcess(bool enabled) { m_usesSingleWebProcess = enabled; }
61
62     bool isAutomaticProcessWarmingEnabled() const
63     {
64         return m_isAutomaticProcessWarmingEnabledByClient.valueOr(m_clientWouldBenefitFromAutomaticProcessPrewarming);
65     }
66
67     bool wasAutomaticProcessWarmingSetByClient() const { return !!m_isAutomaticProcessWarmingEnabledByClient; }
68     void setIsAutomaticProcessWarmingEnabled(bool value) { m_isAutomaticProcessWarmingEnabledByClient = value; }
69
70     void setUsesWebProcessCache(bool value) { m_usesWebProcessCache = value; }
71     bool usesWebProcessCache() const { return m_usesWebProcessCache; }
72
73     bool clientWouldBenefitFromAutomaticProcessPrewarming() const { return m_clientWouldBenefitFromAutomaticProcessPrewarming; }
74     void setClientWouldBenefitFromAutomaticProcessPrewarming(bool value) { m_clientWouldBenefitFromAutomaticProcessPrewarming = value; }
75
76     bool diskCacheSpeculativeValidationEnabled() const { return m_diskCacheSpeculativeValidationEnabled; }
77     void setDiskCacheSpeculativeValidationEnabled(bool enabled) { m_diskCacheSpeculativeValidationEnabled = enabled; }
78
79     WebKit::CacheModel cacheModel() const { return m_cacheModel; }
80     void setCacheModel(WebKit::CacheModel cacheModel) { m_cacheModel = cacheModel; }
81
82     const WTF::String& applicationCacheDirectory() const { return m_applicationCacheDirectory; }
83     void setApplicationCacheDirectory(const WTF::String& applicationCacheDirectory) { m_applicationCacheDirectory = applicationCacheDirectory; }
84
85     const WTF::String& applicationCacheFlatFileSubdirectoryName() const { return m_applicationCacheFlatFileSubdirectoryName; }
86
87     const WTF::String& diskCacheDirectory() const { return m_diskCacheDirectory; }
88     void setDiskCacheDirectory(const WTF::String& diskCacheDirectory) { m_diskCacheDirectory = diskCacheDirectory; }
89
90     const WTF::String& mediaCacheDirectory() const { return m_mediaCacheDirectory; }
91     void setMediaCacheDirectory(const WTF::String& mediaCacheDirectory) { m_mediaCacheDirectory = mediaCacheDirectory; }
92     
93     const WTF::String& indexedDBDatabaseDirectory() const { return m_indexedDBDatabaseDirectory; }
94     void setIndexedDBDatabaseDirectory(const WTF::String& indexedDBDatabaseDirectory) { m_indexedDBDatabaseDirectory = indexedDBDatabaseDirectory; }
95
96     const WTF::String& injectedBundlePath() const { return m_injectedBundlePath; }
97     void setInjectedBundlePath(const WTF::String& injectedBundlePath) { m_injectedBundlePath = injectedBundlePath; }
98
99     const WTF::String& localStorageDirectory() const { return m_localStorageDirectory; }
100     void setLocalStorageDirectory(const WTF::String& localStorageDirectory) { m_localStorageDirectory = localStorageDirectory; }
101
102     const WTF::String& deviceIdHashSaltsStorageDirectory() const { return m_deviceIdHashSaltsStorageDirectory; }
103     void setDeviceIdHashSaltsStorageDirectory(const WTF::String& directory) { m_deviceIdHashSaltsStorageDirectory = directory; }
104
105     const WTF::String& webSQLDatabaseDirectory() const { return m_webSQLDatabaseDirectory; }
106     void setWebSQLDatabaseDirectory(const WTF::String& webSQLDatabaseDirectory) { m_webSQLDatabaseDirectory = webSQLDatabaseDirectory; }
107
108     const WTF::String& mediaKeysStorageDirectory() const { return m_mediaKeysStorageDirectory; }
109     void setMediaKeysStorageDirectory(const WTF::String& mediaKeysStorageDirectory) { m_mediaKeysStorageDirectory = mediaKeysStorageDirectory; }
110
111     const WTF::String& resourceLoadStatisticsDirectory() const { return m_resourceLoadStatisticsDirectory; }
112     void setResourceLoadStatisticsDirectory(const WTF::String& resourceLoadStatisticsDirectory) { m_resourceLoadStatisticsDirectory = resourceLoadStatisticsDirectory; }
113
114     const WTF::String& javaScriptConfigurationDirectory() const { return m_javaScriptConfigurationDirectory; }
115     void setJavaScriptConfigurationDirectory(const WTF::String& javaScriptConfigurationDirectory) { m_javaScriptConfigurationDirectory = javaScriptConfigurationDirectory; }
116
117     const Vector<WTF::String>& cachePartitionedURLSchemes() { return m_cachePartitionedURLSchemes; }
118     void setCachePartitionedURLSchemes(Vector<WTF::String>&& cachePartitionedURLSchemes) { m_cachePartitionedURLSchemes = WTFMove(cachePartitionedURLSchemes); }
119
120     const Vector<WTF::String>& alwaysRevalidatedURLSchemes() { return m_alwaysRevalidatedURLSchemes; }
121     void setAlwaysRevalidatedURLSchemes(Vector<WTF::String>&& alwaysRevalidatedURLSchemes) { m_alwaysRevalidatedURLSchemes = WTFMove(alwaysRevalidatedURLSchemes); }
122
123     const Vector<WTF::CString>& additionalReadAccessAllowedPaths() { return m_additionalReadAccessAllowedPaths; }
124     void setAdditionalReadAccessAllowedPaths(Vector<WTF::CString>&& additionalReadAccessAllowedPaths) { m_additionalReadAccessAllowedPaths = additionalReadAccessAllowedPaths; }
125
126     bool fullySynchronousModeIsAllowedForTesting() const { return m_fullySynchronousModeIsAllowedForTesting; }
127     void setFullySynchronousModeIsAllowedForTesting(bool allowed) { m_fullySynchronousModeIsAllowedForTesting = allowed; }
128
129     bool ignoreSynchronousMessagingTimeoutsForTesting() const { return m_ignoreSynchronousMessagingTimeoutsForTesting; }
130     void setIgnoreSynchronousMessagingTimeoutsForTesting(bool allowed) { m_ignoreSynchronousMessagingTimeoutsForTesting = allowed; }
131
132     bool attrStyleEnabled() const { return m_attrStyleEnabled; }
133     void setAttrStyleEnabled(bool enabled) { m_attrStyleEnabled = enabled; }
134
135     const Vector<WTF::String>& overrideLanguages() const { return m_overrideLanguages; }
136     void setOverrideLanguages(Vector<WTF::String>&& languages) { m_overrideLanguages = WTFMove(languages); }
137     
138     bool alwaysRunsAtBackgroundPriority() const { return m_alwaysRunsAtBackgroundPriority; }
139     void setAlwaysRunsAtBackgroundPriority(bool alwaysRunsAtBackgroundPriority) { m_alwaysRunsAtBackgroundPriority = alwaysRunsAtBackgroundPriority; }
140
141     bool shouldTakeUIBackgroundAssertion() const { return m_shouldTakeUIBackgroundAssertion; }
142     void setShouldTakeUIBackgroundAssertion(bool shouldTakeUIBackgroundAssertion) { m_shouldTakeUIBackgroundAssertion = shouldTakeUIBackgroundAssertion; }
143
144     bool shouldCaptureAudioInUIProcess() const { return m_shouldCaptureAudioInUIProcess; }
145     void setShouldCaptureAudioInUIProcess(bool shouldCaptureAudioInUIProcess) { m_shouldCaptureAudioInUIProcess = shouldCaptureAudioInUIProcess; }
146
147     bool shouldCaptureVideoInUIProcess() const { return m_shouldCaptureVideoInUIProcess; }
148     void setShouldCaptureVideoInUIProcess(bool shouldCaptureVideoInUIProcess) { m_shouldCaptureVideoInUIProcess = shouldCaptureVideoInUIProcess; }
149
150     bool shouldCaptureDisplayInUIProcess() const { return m_shouldCaptureDisplayInUIProcess; }
151     void setShouldCaptureDisplayInUIProcess(bool shouldCaptureDisplayInUIProcess) { m_shouldCaptureDisplayInUIProcess = shouldCaptureDisplayInUIProcess; }
152
153     bool isJITEnabled() const { return m_isJITEnabled; }
154     void setJITEnabled(bool enabled) { m_isJITEnabled = enabled; }
155     
156 #if PLATFORM(IOS_FAMILY)
157     const WTF::String& ctDataConnectionServiceType() const { return m_ctDataConnectionServiceType; }
158     void setCTDataConnectionServiceType(const WTF::String& ctDataConnectionServiceType) { m_ctDataConnectionServiceType = ctDataConnectionServiceType; }
159 #endif
160
161     ProcessID presentingApplicationPID() const { return m_presentingApplicationPID; }
162     void setPresentingApplicationPID(ProcessID pid) { m_presentingApplicationPID = pid; }
163
164     bool processSwapsOnNavigation() const
165     {
166         return m_processSwapsOnNavigationFromClient.valueOr(m_processSwapsOnNavigationFromExperimentalFeatures);
167     }
168     void setProcessSwapsOnNavigation(bool swaps) { m_processSwapsOnNavigationFromClient = swaps; }
169     void setProcessSwapsOnNavigationFromExperimentalFeatures(bool swaps) { m_processSwapsOnNavigationFromExperimentalFeatures = swaps; }
170
171     bool alwaysKeepAndReuseSwappedProcesses() const { return m_alwaysKeepAndReuseSwappedProcesses; }
172     void setAlwaysKeepAndReuseSwappedProcesses(bool keepAndReuse) { m_alwaysKeepAndReuseSwappedProcesses = keepAndReuse; }
173
174     bool processSwapsOnWindowOpenWithOpener() const { return m_processSwapsOnWindowOpenWithOpener; }
175     void setProcessSwapsOnWindowOpenWithOpener(bool swaps) { m_processSwapsOnWindowOpenWithOpener = swaps; }
176
177     const WTF::String& customWebContentServiceBundleIdentifier() const { return m_customWebContentServiceBundleIdentifier; }
178     void setCustomWebContentServiceBundleIdentifier(const WTF::String& customWebContentServiceBundleIdentifier) { m_customWebContentServiceBundleIdentifier = customWebContentServiceBundleIdentifier; }
179
180 #if ENABLE(PROXIMITY_NETWORKING)
181     unsigned wirelessContextIdentifier() const { return m_wirelessContextIdentifier; }
182     void setWirelessContextIdentifier(unsigned wirelessContextIdentifier) { m_wirelessContextIdentifier = wirelessContextIdentifier; }
183 #endif
184
185 #if PLATFORM(COCOA)
186     bool suppressesConnectionTerminationOnSystemChange() const { return m_suppressesConnectionTerminationOnSystemChange; }
187     void setSuppressesConnectionTerminationOnSystemChange(bool suppressesConnectionTerminationOnSystemChange) { m_suppressesConnectionTerminationOnSystemChange = suppressesConnectionTerminationOnSystemChange; }
188
189     bool usesNetworkingDaemon() const { return m_usesNetworkingDaemon; }
190     void setUsesNetworkingDaemon(bool usesNetworkingDaemon) { m_usesNetworkingDaemon = usesNetworkingDaemon; }
191 #endif
192
193 private:
194     bool m_shouldHaveLegacyDataStore { false };
195
196     bool m_diskCacheSpeculativeValidationEnabled { false };
197     WebKit::CacheModel m_cacheModel { WebKit::CacheModel::PrimaryWebBrowser };
198
199     WTF::String m_applicationCacheDirectory;
200     WTF::String m_applicationCacheFlatFileSubdirectoryName;
201     WTF::String m_diskCacheDirectory;
202     WTF::String m_mediaCacheDirectory;
203     WTF::String m_indexedDBDatabaseDirectory;
204     WTF::String m_injectedBundlePath;
205     WTF::String m_localStorageDirectory;
206     WTF::String m_deviceIdHashSaltsStorageDirectory;
207     WTF::String m_webSQLDatabaseDirectory;
208     WTF::String m_mediaKeysStorageDirectory;
209     WTF::String m_resourceLoadStatisticsDirectory;
210     WTF::String m_javaScriptConfigurationDirectory;
211     Vector<WTF::String> m_cachePartitionedURLSchemes;
212     Vector<WTF::String> m_alwaysRevalidatedURLSchemes;
213     Vector<WTF::CString> m_additionalReadAccessAllowedPaths;
214     bool m_fullySynchronousModeIsAllowedForTesting { false };
215     bool m_ignoreSynchronousMessagingTimeoutsForTesting { false };
216     bool m_attrStyleEnabled { false };
217     Vector<WTF::String> m_overrideLanguages;
218     bool m_alwaysRunsAtBackgroundPriority { false };
219     bool m_shouldTakeUIBackgroundAssertion { true };
220     bool m_shouldCaptureAudioInUIProcess { false };
221     bool m_shouldCaptureVideoInUIProcess { false };
222     bool m_shouldCaptureDisplayInUIProcess { DEFAULT_CAPTURE_DISPLAY_IN_UI_PROCESS };
223     ProcessID m_presentingApplicationPID { getCurrentProcessID() };
224     Optional<bool> m_processSwapsOnNavigationFromClient;
225     bool m_processSwapsOnNavigationFromExperimentalFeatures { false };
226     bool m_alwaysKeepAndReuseSwappedProcesses { false };
227     bool m_processSwapsOnWindowOpenWithOpener { false };
228     Optional<bool> m_isAutomaticProcessWarmingEnabledByClient;
229     bool m_usesWebProcessCache { false };
230     bool m_clientWouldBenefitFromAutomaticProcessPrewarming { false };
231     WTF::String m_customWebContentServiceBundleIdentifier;
232     bool m_isJITEnabled { true };
233     bool m_usesSingleWebProcess { false };
234
235 #if PLATFORM(IOS_FAMILY)
236     WTF::String m_ctDataConnectionServiceType;
237 #endif
238
239 #if ENABLE(PROXIMITY_NETWORKING)
240     unsigned m_wirelessContextIdentifier { 0 };
241 #endif
242
243 #if PLATFORM(COCOA)
244     bool m_suppressesConnectionTerminationOnSystemChange { false };
245     bool m_usesNetworkingDaemon { false };
246 #endif
247 };
248
249 } // namespace API