0ac7cc6aec88227a7b8f7711fda61531af187d60
[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 class ProcessPoolConfiguration final : public ObjectImpl<Object::Type::ProcessPoolConfiguration> {
40 public:
41     static Ref<ProcessPoolConfiguration> create();
42     static Ref<ProcessPoolConfiguration> createWithLegacyOptions();
43     static Ref<ProcessPoolConfiguration> createWithWebsiteDataStoreConfiguration(const WebKit::WebsiteDataStore::Configuration&);
44
45     explicit ProcessPoolConfiguration();
46     virtual ~ProcessPoolConfiguration();
47     
48     Ref<ProcessPoolConfiguration> copy();
49
50     bool shouldHaveLegacyDataStore() const { return m_shouldHaveLegacyDataStore; }
51     void setShouldHaveLegacyDataStore(bool shouldHaveLegacyDataStore) { m_shouldHaveLegacyDataStore = shouldHaveLegacyDataStore; }
52
53     unsigned maximumProcessCount() const { return m_maximumProcessCount; }
54     void setMaximumProcessCount(unsigned maximumProcessCount) { m_maximumProcessCount = maximumProcessCount; } 
55
56     bool diskCacheSpeculativeValidationEnabled() const { return m_diskCacheSpeculativeValidationEnabled; }
57     void setDiskCacheSpeculativeValidationEnabled(bool enabled) { m_diskCacheSpeculativeValidationEnabled = enabled; }
58
59     WebKit::CacheModel cacheModel() const { return m_cacheModel; }
60     void setCacheModel(WebKit::CacheModel cacheModel) { m_cacheModel = cacheModel; }
61
62     int64_t diskCacheSizeOverride() const { return m_diskCacheSizeOverride; }
63     void setDiskCacheSizeOverride(int64_t size) { m_diskCacheSizeOverride = size; }
64
65     const WTF::String& applicationCacheDirectory() const { return m_applicationCacheDirectory; }
66     void setApplicationCacheDirectory(const WTF::String& applicationCacheDirectory) { m_applicationCacheDirectory = applicationCacheDirectory; }
67
68     const WTF::String& applicationCacheFlatFileSubdirectoryName() const { return m_applicationCacheFlatFileSubdirectoryName; }
69
70     const WTF::String& cacheStorageDirectory() const { return m_cacheStorageDirectory; }
71     void setCacheStorageDirectory(WTF::String&& cacheStorageDirectory) { m_cacheStorageDirectory = WTFMove(cacheStorageDirectory); }
72
73     const WTF::String& diskCacheDirectory() const { return m_diskCacheDirectory; }
74     void setDiskCacheDirectory(const WTF::String& diskCacheDirectory) { m_diskCacheDirectory = diskCacheDirectory; }
75
76     const WTF::String& mediaCacheDirectory() const { return m_mediaCacheDirectory; }
77     void setMediaCacheDirectory(const WTF::String& mediaCacheDirectory) { m_mediaCacheDirectory = mediaCacheDirectory; }
78     
79     const WTF::String& indexedDBDatabaseDirectory() const { return m_indexedDBDatabaseDirectory; }
80     void setIndexedDBDatabaseDirectory(const WTF::String& indexedDBDatabaseDirectory) { m_indexedDBDatabaseDirectory = indexedDBDatabaseDirectory; }
81
82     const WTF::String& injectedBundlePath() const { return m_injectedBundlePath; }
83     void setInjectedBundlePath(const WTF::String& injectedBundlePath) { m_injectedBundlePath = injectedBundlePath; }
84
85     const WTF::String& localStorageDirectory() const { return m_localStorageDirectory; }
86     void setLocalStorageDirectory(const WTF::String& localStorageDirectory) { m_localStorageDirectory = localStorageDirectory; }
87
88     const WTF::String& webSQLDatabaseDirectory() const { return m_webSQLDatabaseDirectory; }
89     void setWebSQLDatabaseDirectory(const WTF::String& webSQLDatabaseDirectory) { m_webSQLDatabaseDirectory = webSQLDatabaseDirectory; }
90
91     const WTF::String& mediaKeysStorageDirectory() const { return m_mediaKeysStorageDirectory; }
92     void setMediaKeysStorageDirectory(const WTF::String& mediaKeysStorageDirectory) { m_mediaKeysStorageDirectory = mediaKeysStorageDirectory; }
93
94     const WTF::String& resourceLoadStatisticsDirectory() const { return m_resourceLoadStatisticsDirectory; }
95     void setResourceLoadStatisticsDirectory(const WTF::String& resourceLoadStatisticsDirectory) { m_resourceLoadStatisticsDirectory = resourceLoadStatisticsDirectory; }
96
97     const WTF::String& javaScriptConfigurationDirectory() const { return m_javaScriptConfigurationDirectory; }
98     void setJavaScriptConfigurationDirectory(const WTF::String& javaScriptConfigurationDirectory) { m_javaScriptConfigurationDirectory = javaScriptConfigurationDirectory; }
99
100     const Vector<WTF::String>& cachePartitionedURLSchemes() { return m_cachePartitionedURLSchemes; }
101     void setCachePartitionedURLSchemes(Vector<WTF::String>&& cachePartitionedURLSchemes) { m_cachePartitionedURLSchemes = WTFMove(cachePartitionedURLSchemes); }
102
103     const Vector<WTF::String>& alwaysRevalidatedURLSchemes() { return m_alwaysRevalidatedURLSchemes; }
104     void setAlwaysRevalidatedURLSchemes(Vector<WTF::String>&& alwaysRevalidatedURLSchemes) { m_alwaysRevalidatedURLSchemes = WTFMove(alwaysRevalidatedURLSchemes); }
105
106     const Vector<WTF::CString>& additionalReadAccessAllowedPaths() { return m_additionalReadAccessAllowedPaths; }
107     void setAdditionalReadAccessAllowedPaths(Vector<WTF::CString>&& additionalReadAccessAllowedPaths) { m_additionalReadAccessAllowedPaths = additionalReadAccessAllowedPaths; }
108
109     bool fullySynchronousModeIsAllowedForTesting() const { return m_fullySynchronousModeIsAllowedForTesting; }
110     void setFullySynchronousModeIsAllowedForTesting(bool allowed) { m_fullySynchronousModeIsAllowedForTesting = allowed; }
111
112     bool ignoreSynchronousMessagingTimeoutsForTesting() const { return m_ignoreSynchronousMessagingTimeoutsForTesting; }
113     void setIgnoreSynchronousMessagingTimeoutsForTesting(bool allowed) { m_ignoreSynchronousMessagingTimeoutsForTesting = allowed; }
114
115     const Vector<WTF::String>& overrideLanguages() const { return m_overrideLanguages; }
116     void setOverrideLanguages(Vector<WTF::String>&& languages) { m_overrideLanguages = WTFMove(languages); }
117
118     const WTF::String& sourceApplicationBundleIdentifier() const { return m_sourceApplicationBundleIdentifier; }
119     void setSourceApplicationBundleIdentifier(const WTF::String& sourceApplicationBundleIdentifier) { m_sourceApplicationBundleIdentifier = sourceApplicationBundleIdentifier; }
120
121     const WTF::String& sourceApplicationSecondaryIdentifier() const { return m_sourceApplicationSecondaryIdentifier; }
122     void setSourceApplicationSecondaryIdentifier(const WTF::String& sourceApplicationSecondaryIdentifier) { m_sourceApplicationSecondaryIdentifier = sourceApplicationSecondaryIdentifier; }
123
124     bool allowsCellularAccess() const { return m_allowsCellularAccess; }
125     void setAllowsCellularAccess(bool allowsCellularAccess) { m_allowsCellularAccess = allowsCellularAccess; }
126     
127     bool alwaysRunsAtBackgroundPriority() const { return m_alwaysRunsAtBackgroundPriority; }
128     void setAlwaysRunsAtBackgroundPriority(bool alwaysRunsAtBackgroundPriority) { m_alwaysRunsAtBackgroundPriority = alwaysRunsAtBackgroundPriority; }
129
130     bool shouldTakeUIBackgroundAssertion() const { return m_shouldTakeUIBackgroundAssertion; }
131     void setShouldTakeUIBackgroundAssertion(bool shouldTakeUIBackgroundAssertion) { m_shouldTakeUIBackgroundAssertion = shouldTakeUIBackgroundAssertion; }
132
133     bool shouldCaptureAudioInUIProcess() const { return m_shouldCaptureAudioInUIProcess; }
134     void setShouldCaptureAudioInUIProcess(bool shouldCaptureAudioInUIProcess) { m_shouldCaptureAudioInUIProcess = shouldCaptureAudioInUIProcess; }
135
136 #if PLATFORM(IOS)
137     const WTF::String& ctDataConnectionServiceType() const { return m_ctDataConnectionServiceType; }
138     void setCTDataConnectionServiceType(const WTF::String& ctDataConnectionServiceType) { m_ctDataConnectionServiceType = ctDataConnectionServiceType; }
139 #endif
140
141     pid_t presentingApplicationPID() const { return m_presentingApplicationPID; }
142     void setPresentingApplicationPID(pid_t pid) { m_presentingApplicationPID = pid; }
143
144 private:
145     bool m_shouldHaveLegacyDataStore { false };
146
147     unsigned m_maximumProcessCount { 0 };
148     bool m_diskCacheSpeculativeValidationEnabled { false };
149     WebKit::CacheModel m_cacheModel { WebKit::CacheModelPrimaryWebBrowser };
150     int64_t m_diskCacheSizeOverride { -1 };
151
152     WTF::String m_applicationCacheDirectory;
153     WTF::String m_applicationCacheFlatFileSubdirectoryName;
154     WTF::String m_cacheStorageDirectory;
155     WTF::String m_diskCacheDirectory;
156     WTF::String m_mediaCacheDirectory;
157     WTF::String m_indexedDBDatabaseDirectory;
158     WTF::String m_injectedBundlePath;
159     WTF::String m_localStorageDirectory;
160     WTF::String m_webSQLDatabaseDirectory;
161     WTF::String m_mediaKeysStorageDirectory;
162     WTF::String m_resourceLoadStatisticsDirectory;
163     WTF::String m_javaScriptConfigurationDirectory;
164     Vector<WTF::String> m_cachePartitionedURLSchemes;
165     Vector<WTF::String> m_alwaysRevalidatedURLSchemes;
166     Vector<WTF::CString> m_additionalReadAccessAllowedPaths;
167     bool m_fullySynchronousModeIsAllowedForTesting { false };
168     bool m_ignoreSynchronousMessagingTimeoutsForTesting { false };
169     Vector<WTF::String> m_overrideLanguages;
170     WTF::String m_sourceApplicationBundleIdentifier;
171     WTF::String m_sourceApplicationSecondaryIdentifier;
172     bool m_allowsCellularAccess { true };
173     bool m_alwaysRunsAtBackgroundPriority { false };
174     bool m_shouldTakeUIBackgroundAssertion { true };
175     bool m_shouldCaptureAudioInUIProcess { false };
176     pid_t m_presentingApplicationPID { getCurrentProcessID() };
177 #if PLATFORM(IOS)
178     WTF::String m_ctDataConnectionServiceType;
179 #endif
180 };
181
182 } // namespace API