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