4ceba880bdd87faf9c5e41ac071f4efdcff60458
[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     unsigned maximumProcessCount() const { return m_maximumProcessCount; }
60     void setMaximumProcessCount(unsigned maximumProcessCount) { m_maximumProcessCount = maximumProcessCount; }
61
62     bool isAutomaticProcessWarmingEnabled() const
63     {
64         return m_isAutomaticProcessWarmingEnabledByClient.value_or(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& webSQLDatabaseDirectory() const { return m_webSQLDatabaseDirectory; }
100     void setWebSQLDatabaseDirectory(const WTF::String& webSQLDatabaseDirectory) { m_webSQLDatabaseDirectory = webSQLDatabaseDirectory; }
101
102     const WTF::String& mediaKeysStorageDirectory() const { return m_mediaKeysStorageDirectory; }
103     void setMediaKeysStorageDirectory(const WTF::String& mediaKeysStorageDirectory) { m_mediaKeysStorageDirectory = mediaKeysStorageDirectory; }
104
105     const WTF::String& resourceLoadStatisticsDirectory() const { return m_resourceLoadStatisticsDirectory; }
106     void setResourceLoadStatisticsDirectory(const WTF::String& resourceLoadStatisticsDirectory) { m_resourceLoadStatisticsDirectory = resourceLoadStatisticsDirectory; }
107
108     const WTF::String& javaScriptConfigurationDirectory() const { return m_javaScriptConfigurationDirectory; }
109     void setJavaScriptConfigurationDirectory(const WTF::String& javaScriptConfigurationDirectory) { m_javaScriptConfigurationDirectory = javaScriptConfigurationDirectory; }
110
111     const Vector<WTF::String>& cachePartitionedURLSchemes() { return m_cachePartitionedURLSchemes; }
112     void setCachePartitionedURLSchemes(Vector<WTF::String>&& cachePartitionedURLSchemes) { m_cachePartitionedURLSchemes = WTFMove(cachePartitionedURLSchemes); }
113
114     const Vector<WTF::String>& alwaysRevalidatedURLSchemes() { return m_alwaysRevalidatedURLSchemes; }
115     void setAlwaysRevalidatedURLSchemes(Vector<WTF::String>&& alwaysRevalidatedURLSchemes) { m_alwaysRevalidatedURLSchemes = WTFMove(alwaysRevalidatedURLSchemes); }
116
117     const Vector<WTF::CString>& additionalReadAccessAllowedPaths() { return m_additionalReadAccessAllowedPaths; }
118     void setAdditionalReadAccessAllowedPaths(Vector<WTF::CString>&& additionalReadAccessAllowedPaths) { m_additionalReadAccessAllowedPaths = additionalReadAccessAllowedPaths; }
119
120     bool fullySynchronousModeIsAllowedForTesting() const { return m_fullySynchronousModeIsAllowedForTesting; }
121     void setFullySynchronousModeIsAllowedForTesting(bool allowed) { m_fullySynchronousModeIsAllowedForTesting = allowed; }
122
123     bool ignoreSynchronousMessagingTimeoutsForTesting() const { return m_ignoreSynchronousMessagingTimeoutsForTesting; }
124     void setIgnoreSynchronousMessagingTimeoutsForTesting(bool allowed) { m_ignoreSynchronousMessagingTimeoutsForTesting = allowed; }
125
126     bool attrStyleEnabled() const { return m_attrStyleEnabled; }
127     void setAttrStyleEnabled(bool enabled) { m_attrStyleEnabled = enabled; }
128
129     const Vector<WTF::String>& overrideLanguages() const { return m_overrideLanguages; }
130     void setOverrideLanguages(Vector<WTF::String>&& languages) { m_overrideLanguages = WTFMove(languages); }
131     
132     bool alwaysRunsAtBackgroundPriority() const { return m_alwaysRunsAtBackgroundPriority; }
133     void setAlwaysRunsAtBackgroundPriority(bool alwaysRunsAtBackgroundPriority) { m_alwaysRunsAtBackgroundPriority = alwaysRunsAtBackgroundPriority; }
134
135     bool shouldTakeUIBackgroundAssertion() const { return m_shouldTakeUIBackgroundAssertion; }
136     void setShouldTakeUIBackgroundAssertion(bool shouldTakeUIBackgroundAssertion) { m_shouldTakeUIBackgroundAssertion = shouldTakeUIBackgroundAssertion; }
137
138     bool shouldCaptureAudioInUIProcess() const { return m_shouldCaptureAudioInUIProcess; }
139     void setShouldCaptureAudioInUIProcess(bool shouldCaptureAudioInUIProcess) { m_shouldCaptureAudioInUIProcess = shouldCaptureAudioInUIProcess; }
140
141     bool shouldCaptureVideoInUIProcess() const { return m_shouldCaptureVideoInUIProcess; }
142     void setShouldCaptureVideoInUIProcess(bool shouldCaptureVideoInUIProcess) { m_shouldCaptureVideoInUIProcess = shouldCaptureVideoInUIProcess; }
143
144     bool shouldCaptureDisplayInUIProcess() const { return m_shouldCaptureDisplayInUIProcess; }
145     void setShouldCaptureDisplayInUIProcess(bool shouldCaptureDisplayInUIProcess) { m_shouldCaptureDisplayInUIProcess = shouldCaptureDisplayInUIProcess; }
146
147     bool isJITEnabled() const { return m_isJITEnabled; }
148     void setJITEnabled(bool enabled) { m_isJITEnabled = enabled; }
149     
150 #if PLATFORM(IOS_FAMILY)
151     const WTF::String& ctDataConnectionServiceType() const { return m_ctDataConnectionServiceType; }
152     void setCTDataConnectionServiceType(const WTF::String& ctDataConnectionServiceType) { m_ctDataConnectionServiceType = ctDataConnectionServiceType; }
153 #endif
154
155     ProcessID presentingApplicationPID() const { return m_presentingApplicationPID; }
156     void setPresentingApplicationPID(ProcessID pid) { m_presentingApplicationPID = pid; }
157
158     bool processSwapsOnNavigation() const
159     {
160         return m_processSwapsOnNavigationFromClient.value_or(m_processSwapsOnNavigationFromExperimentalFeatures);
161     }
162     void setProcessSwapsOnNavigation(bool swaps) { m_processSwapsOnNavigationFromClient = swaps; }
163     void setProcessSwapsOnNavigationFromExperimentalFeatures(bool swaps) { m_processSwapsOnNavigationFromExperimentalFeatures = swaps; }
164
165     bool alwaysKeepAndReuseSwappedProcesses() const { return m_alwaysKeepAndReuseSwappedProcesses; }
166     void setAlwaysKeepAndReuseSwappedProcesses(bool keepAndReuse) { m_alwaysKeepAndReuseSwappedProcesses = keepAndReuse; }
167
168     bool processSwapsOnWindowOpenWithOpener() const { return m_processSwapsOnWindowOpenWithOpener; }
169     void setProcessSwapsOnWindowOpenWithOpener(bool swaps) { m_processSwapsOnWindowOpenWithOpener = swaps; }
170
171     const WTF::String& customWebContentServiceBundleIdentifier() const { return m_customWebContentServiceBundleIdentifier; }
172     void setCustomWebContentServiceBundleIdentifier(const WTF::String& customWebContentServiceBundleIdentifier) { m_customWebContentServiceBundleIdentifier = customWebContentServiceBundleIdentifier; }
173
174 #if ENABLE(PROXIMITY_NETWORKING)
175     unsigned wirelessContextIdentifier() const { return m_wirelessContextIdentifier; }
176     void setWirelessContextIdentifier(unsigned wirelessContextIdentifier) { m_wirelessContextIdentifier = wirelessContextIdentifier; }
177 #endif
178
179 #if PLATFORM(COCOA)
180     bool suppressesConnectionTerminationOnSystemChange() const { return m_suppressesConnectionTerminationOnSystemChange; }
181     void setSuppressesConnectionTerminationOnSystemChange(bool suppressesConnectionTerminationOnSystemChange) { m_suppressesConnectionTerminationOnSystemChange = suppressesConnectionTerminationOnSystemChange; }
182 #endif
183
184 private:
185     bool m_shouldHaveLegacyDataStore { false };
186
187     unsigned m_maximumProcessCount { 0 };
188     bool m_diskCacheSpeculativeValidationEnabled { false };
189     WebKit::CacheModel m_cacheModel { WebKit::CacheModelPrimaryWebBrowser };
190
191     WTF::String m_applicationCacheDirectory;
192     WTF::String m_applicationCacheFlatFileSubdirectoryName;
193     WTF::String m_diskCacheDirectory;
194     WTF::String m_mediaCacheDirectory;
195     WTF::String m_indexedDBDatabaseDirectory;
196     WTF::String m_injectedBundlePath;
197     WTF::String m_localStorageDirectory;
198     WTF::String m_webSQLDatabaseDirectory;
199     WTF::String m_mediaKeysStorageDirectory;
200     WTF::String m_resourceLoadStatisticsDirectory;
201     WTF::String m_javaScriptConfigurationDirectory;
202     Vector<WTF::String> m_cachePartitionedURLSchemes;
203     Vector<WTF::String> m_alwaysRevalidatedURLSchemes;
204     Vector<WTF::CString> m_additionalReadAccessAllowedPaths;
205     bool m_fullySynchronousModeIsAllowedForTesting { false };
206     bool m_ignoreSynchronousMessagingTimeoutsForTesting { false };
207     bool m_attrStyleEnabled { false };
208     Vector<WTF::String> m_overrideLanguages;
209     bool m_alwaysRunsAtBackgroundPriority { false };
210     bool m_shouldTakeUIBackgroundAssertion { true };
211     bool m_shouldCaptureAudioInUIProcess { false };
212     bool m_shouldCaptureVideoInUIProcess { false };
213     bool m_shouldCaptureDisplayInUIProcess { DEFAULT_CAPTURE_DISPLAY_IN_UI_PROCESS };
214     ProcessID m_presentingApplicationPID { getCurrentProcessID() };
215     Optional<bool> m_processSwapsOnNavigationFromClient;
216     bool m_processSwapsOnNavigationFromExperimentalFeatures { false };
217     bool m_alwaysKeepAndReuseSwappedProcesses { false };
218     bool m_processSwapsOnWindowOpenWithOpener { false };
219     Optional<bool> m_isAutomaticProcessWarmingEnabledByClient;
220     bool m_clientWouldBenefitFromAutomaticProcessPrewarming { false };
221     WTF::String m_customWebContentServiceBundleIdentifier;
222     bool m_isJITEnabled { true };
223
224 #if PLATFORM(IOS_FAMILY)
225     WTF::String m_ctDataConnectionServiceType;
226 #endif
227
228 #if ENABLE(PROXIMITY_NETWORKING)
229     unsigned m_wirelessContextIdentifier { 0 };
230 #endif
231
232 #if PLATFORM(COCOA)
233     bool m_suppressesConnectionTerminationOnSystemChange { false };
234 #endif
235 };
236
237 } // namespace API