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 | uint32_t downloadMonitorSpeedMultiplier() const { return m_downloadMonitorSpeedMultiplier; } |
63 | void setDownloadMonitorSpeedMultiplier(uint32_t multiplier) { m_downloadMonitorSpeedMultiplier = multiplier; } |
64 | |
65 | bool isAutomaticProcessWarmingEnabled() const |
66 | { |
67 | return m_isAutomaticProcessWarmingEnabledByClient.valueOr(m_clientWouldBenefitFromAutomaticProcessPrewarming); |
68 | } |
69 | |
70 | bool wasAutomaticProcessWarmingSetByClient() const { return !!m_isAutomaticProcessWarmingEnabledByClient; } |
71 | void setIsAutomaticProcessWarmingEnabled(bool value) { m_isAutomaticProcessWarmingEnabledByClient = value; } |
72 | |
73 | void setUsesWebProcessCache(bool value) { m_usesWebProcessCache = value; } |
74 | bool usesWebProcessCache() const { return m_usesWebProcessCache; } |
75 | |
76 | bool clientWouldBenefitFromAutomaticProcessPrewarming() const { return m_clientWouldBenefitFromAutomaticProcessPrewarming; } |
77 | void setClientWouldBenefitFromAutomaticProcessPrewarming(bool value) { m_clientWouldBenefitFromAutomaticProcessPrewarming = value; } |
78 | |
79 | bool diskCacheSpeculativeValidationEnabled() const { return m_diskCacheSpeculativeValidationEnabled; } |
80 | void setDiskCacheSpeculativeValidationEnabled(bool enabled) { m_diskCacheSpeculativeValidationEnabled = enabled; } |
81 | |
82 | WebKit::CacheModel cacheModel() const { return m_cacheModel; } |
83 | void setCacheModel(WebKit::CacheModel cacheModel) { m_cacheModel = cacheModel; } |
84 | |
85 | const WTF::String& applicationCacheDirectory() const { return m_applicationCacheDirectory; } |
86 | void setApplicationCacheDirectory(const WTF::String& applicationCacheDirectory) { m_applicationCacheDirectory = applicationCacheDirectory; } |
87 | |
88 | const WTF::String& applicationCacheFlatFileSubdirectoryName() const { return m_applicationCacheFlatFileSubdirectoryName; } |
89 | |
90 | const WTF::String& diskCacheDirectory() const { return m_diskCacheDirectory; } |
91 | void setDiskCacheDirectory(const WTF::String& diskCacheDirectory) { m_diskCacheDirectory = diskCacheDirectory; } |
92 | |
93 | const WTF::String& mediaCacheDirectory() const { return m_mediaCacheDirectory; } |
94 | void setMediaCacheDirectory(const WTF::String& mediaCacheDirectory) { m_mediaCacheDirectory = mediaCacheDirectory; } |
95 | |
96 | const WTF::String& indexedDBDatabaseDirectory() const { return m_indexedDBDatabaseDirectory; } |
97 | void setIndexedDBDatabaseDirectory(const WTF::String& indexedDBDatabaseDirectory) { m_indexedDBDatabaseDirectory = indexedDBDatabaseDirectory; } |
98 | |
99 | const WTF::String& injectedBundlePath() const { return m_injectedBundlePath; } |
100 | void setInjectedBundlePath(const WTF::String& injectedBundlePath) { m_injectedBundlePath = injectedBundlePath; } |
101 | |
102 | const WTF::String& localStorageDirectory() const { return m_localStorageDirectory; } |
103 | void setLocalStorageDirectory(const WTF::String& localStorageDirectory) { m_localStorageDirectory = localStorageDirectory; } |
104 | |
105 | const WTF::String& deviceIdHashSaltsStorageDirectory() const { return m_deviceIdHashSaltsStorageDirectory; } |
106 | void setDeviceIdHashSaltsStorageDirectory(const WTF::String& directory) { m_deviceIdHashSaltsStorageDirectory = directory; } |
107 | |
108 | const WTF::String& webSQLDatabaseDirectory() const { return m_webSQLDatabaseDirectory; } |
109 | void setWebSQLDatabaseDirectory(const WTF::String& webSQLDatabaseDirectory) { m_webSQLDatabaseDirectory = webSQLDatabaseDirectory; } |
110 | |
111 | const WTF::String& mediaKeysStorageDirectory() const { return m_mediaKeysStorageDirectory; } |
112 | void setMediaKeysStorageDirectory(const WTF::String& mediaKeysStorageDirectory) { m_mediaKeysStorageDirectory = mediaKeysStorageDirectory; } |
113 | |
114 | const WTF::String& resourceLoadStatisticsDirectory() const { return m_resourceLoadStatisticsDirectory; } |
115 | void setResourceLoadStatisticsDirectory(const WTF::String& resourceLoadStatisticsDirectory) { m_resourceLoadStatisticsDirectory = resourceLoadStatisticsDirectory; } |
116 | |
117 | const WTF::String& javaScriptConfigurationDirectory() const { return m_javaScriptConfigurationDirectory; } |
118 | void setJavaScriptConfigurationDirectory(const WTF::String& javaScriptConfigurationDirectory) { m_javaScriptConfigurationDirectory = javaScriptConfigurationDirectory; } |
119 | |
120 | const Vector<WTF::String>& cachePartitionedURLSchemes() { return m_cachePartitionedURLSchemes; } |
121 | void setCachePartitionedURLSchemes(Vector<WTF::String>&& cachePartitionedURLSchemes) { m_cachePartitionedURLSchemes = WTFMove(cachePartitionedURLSchemes); } |
122 | |
123 | const Vector<WTF::String>& alwaysRevalidatedURLSchemes() { return m_alwaysRevalidatedURLSchemes; } |
124 | void setAlwaysRevalidatedURLSchemes(Vector<WTF::String>&& alwaysRevalidatedURLSchemes) { m_alwaysRevalidatedURLSchemes = WTFMove(alwaysRevalidatedURLSchemes); } |
125 | |
126 | const Vector<WTF::CString>& additionalReadAccessAllowedPaths() { return m_additionalReadAccessAllowedPaths; } |
127 | void setAdditionalReadAccessAllowedPaths(Vector<WTF::CString>&& additionalReadAccessAllowedPaths) { m_additionalReadAccessAllowedPaths = additionalReadAccessAllowedPaths; } |
128 | |
129 | bool fullySynchronousModeIsAllowedForTesting() const { return m_fullySynchronousModeIsAllowedForTesting; } |
130 | void setFullySynchronousModeIsAllowedForTesting(bool allowed) { m_fullySynchronousModeIsAllowedForTesting = allowed; } |
131 | |
132 | bool ignoreSynchronousMessagingTimeoutsForTesting() const { return m_ignoreSynchronousMessagingTimeoutsForTesting; } |
133 | void setIgnoreSynchronousMessagingTimeoutsForTesting(bool allowed) { m_ignoreSynchronousMessagingTimeoutsForTesting = allowed; } |
134 | |
135 | bool attrStyleEnabled() const { return m_attrStyleEnabled; } |
136 | void setAttrStyleEnabled(bool enabled) { m_attrStyleEnabled = enabled; } |
137 | |
138 | const Vector<WTF::String>& overrideLanguages() const { return m_overrideLanguages; } |
139 | void setOverrideLanguages(Vector<WTF::String>&& languages) { m_overrideLanguages = WTFMove(languages); } |
140 | |
141 | bool alwaysRunsAtBackgroundPriority() const { return m_alwaysRunsAtBackgroundPriority; } |
142 | void setAlwaysRunsAtBackgroundPriority(bool alwaysRunsAtBackgroundPriority) { m_alwaysRunsAtBackgroundPriority = alwaysRunsAtBackgroundPriority; } |
143 | |
144 | bool shouldTakeUIBackgroundAssertion() const { return m_shouldTakeUIBackgroundAssertion; } |
145 | void setShouldTakeUIBackgroundAssertion(bool shouldTakeUIBackgroundAssertion) { m_shouldTakeUIBackgroundAssertion = shouldTakeUIBackgroundAssertion; } |
146 | |
147 | bool shouldCaptureAudioInUIProcess() const { return m_shouldCaptureAudioInUIProcess; } |
148 | void setShouldCaptureAudioInUIProcess(bool shouldCaptureAudioInUIProcess) { m_shouldCaptureAudioInUIProcess = shouldCaptureAudioInUIProcess; } |
149 | |
150 | bool shouldCaptureVideoInUIProcess() const { return m_shouldCaptureVideoInUIProcess; } |
151 | void setShouldCaptureVideoInUIProcess(bool shouldCaptureVideoInUIProcess) { m_shouldCaptureVideoInUIProcess = shouldCaptureVideoInUIProcess; } |
152 | |
153 | bool shouldCaptureDisplayInUIProcess() const { return m_shouldCaptureDisplayInUIProcess; } |
154 | void setShouldCaptureDisplayInUIProcess(bool shouldCaptureDisplayInUIProcess) { m_shouldCaptureDisplayInUIProcess = shouldCaptureDisplayInUIProcess; } |
155 | |
156 | bool isJITEnabled() const { return m_isJITEnabled; } |
157 | void setJITEnabled(bool enabled) { m_isJITEnabled = enabled; } |
158 | |
159 | #if PLATFORM(IOS_FAMILY) |
160 | const WTF::String& ctDataConnectionServiceType() const { return m_ctDataConnectionServiceType; } |
161 | void setCTDataConnectionServiceType(const WTF::String& ctDataConnectionServiceType) { m_ctDataConnectionServiceType = ctDataConnectionServiceType; } |
162 | #endif |
163 | |
164 | ProcessID presentingApplicationPID() const { return m_presentingApplicationPID; } |
165 | void setPresentingApplicationPID(ProcessID pid) { m_presentingApplicationPID = pid; } |
166 | |
167 | bool processSwapsOnNavigation() const |
168 | { |
169 | return m_processSwapsOnNavigationFromClient.valueOr(m_processSwapsOnNavigationFromExperimentalFeatures); |
170 | } |
171 | void setProcessSwapsOnNavigation(bool swaps) { m_processSwapsOnNavigationFromClient = swaps; } |
172 | void setProcessSwapsOnNavigationFromExperimentalFeatures(bool swaps) { m_processSwapsOnNavigationFromExperimentalFeatures = swaps; } |
173 | |
174 | bool alwaysKeepAndReuseSwappedProcesses() const { return m_alwaysKeepAndReuseSwappedProcesses; } |
175 | void setAlwaysKeepAndReuseSwappedProcesses(bool keepAndReuse) { m_alwaysKeepAndReuseSwappedProcesses = keepAndReuse; } |
176 | |
177 | bool processSwapsOnWindowOpenWithOpener() const { return m_processSwapsOnWindowOpenWithOpener; } |
178 | void setProcessSwapsOnWindowOpenWithOpener(bool swaps) { m_processSwapsOnWindowOpenWithOpener = swaps; } |
179 | |
180 | const WTF::String& customWebContentServiceBundleIdentifier() const { return m_customWebContentServiceBundleIdentifier; } |
181 | void setCustomWebContentServiceBundleIdentifier(const WTF::String& customWebContentServiceBundleIdentifier) { m_customWebContentServiceBundleIdentifier = customWebContentServiceBundleIdentifier; } |
182 | |
183 | const WTF::String& hstsStorageDirectory() const { return m_hstsStorageDirectory; } |
184 | void setHSTSStorageDirectory(WTF::String&& directory) { m_hstsStorageDirectory = WTFMove(directory); } |
185 | |
186 | #if PLATFORM(COCOA) |
187 | bool suppressesConnectionTerminationOnSystemChange() const { return m_suppressesConnectionTerminationOnSystemChange; } |
188 | void setSuppressesConnectionTerminationOnSystemChange(bool suppressesConnectionTerminationOnSystemChange) { m_suppressesConnectionTerminationOnSystemChange = suppressesConnectionTerminationOnSystemChange; } |
189 | #endif |
190 | |
191 | private: |
192 | bool m_shouldHaveLegacyDataStore { false }; |
193 | |
194 | bool m_diskCacheSpeculativeValidationEnabled { false }; |
195 | WebKit::CacheModel m_cacheModel { WebKit::CacheModel::PrimaryWebBrowser }; |
196 | |
197 | WTF::String m_applicationCacheDirectory; |
198 | WTF::String m_applicationCacheFlatFileSubdirectoryName; |
199 | WTF::String m_diskCacheDirectory; |
200 | WTF::String m_mediaCacheDirectory; |
201 | WTF::String m_indexedDBDatabaseDirectory; |
202 | WTF::String m_injectedBundlePath; |
203 | WTF::String m_localStorageDirectory; |
204 | WTF::String m_deviceIdHashSaltsStorageDirectory; |
205 | WTF::String m_webSQLDatabaseDirectory; |
206 | WTF::String m_mediaKeysStorageDirectory; |
207 | WTF::String m_resourceLoadStatisticsDirectory; |
208 | WTF::String m_javaScriptConfigurationDirectory; |
209 | Vector<WTF::String> m_cachePartitionedURLSchemes; |
210 | Vector<WTF::String> m_alwaysRevalidatedURLSchemes; |
211 | Vector<WTF::CString> m_additionalReadAccessAllowedPaths; |
212 | bool m_fullySynchronousModeIsAllowedForTesting { false }; |
213 | bool m_ignoreSynchronousMessagingTimeoutsForTesting { false }; |
214 | bool m_attrStyleEnabled { false }; |
215 | Vector<WTF::String> m_overrideLanguages; |
216 | bool m_alwaysRunsAtBackgroundPriority { false }; |
217 | bool m_shouldTakeUIBackgroundAssertion { true }; |
218 | bool m_shouldCaptureAudioInUIProcess { false }; |
219 | bool m_shouldCaptureVideoInUIProcess { false }; |
220 | bool m_shouldCaptureDisplayInUIProcess { DEFAULT_CAPTURE_DISPLAY_IN_UI_PROCESS }; |
221 | ProcessID m_presentingApplicationPID { getCurrentProcessID() }; |
222 | Optional<bool> m_processSwapsOnNavigationFromClient; |
223 | bool m_processSwapsOnNavigationFromExperimentalFeatures { false }; |
224 | bool m_alwaysKeepAndReuseSwappedProcesses { false }; |
225 | bool m_processSwapsOnWindowOpenWithOpener { false }; |
226 | Optional<bool> m_isAutomaticProcessWarmingEnabledByClient; |
227 | bool m_usesWebProcessCache { false }; |
228 | bool m_clientWouldBenefitFromAutomaticProcessPrewarming { false }; |
229 | WTF::String m_customWebContentServiceBundleIdentifier; |
230 | bool m_isJITEnabled { true }; |
231 | bool m_usesSingleWebProcess { false }; |
232 | uint32_t m_downloadMonitorSpeedMultiplier { 1 }; |
233 | WTF::String m_hstsStorageDirectory; |
234 | |
235 | #if PLATFORM(IOS_FAMILY) |
236 | WTF::String m_ctDataConnectionServiceType; |
237 | #endif |
238 | |
239 | #if PLATFORM(COCOA) |
240 | bool m_suppressesConnectionTerminationOnSystemChange { false }; |
241 | #endif |
242 | }; |
243 | |
244 | } // namespace API |
245 | |