[iOS] We should not take a background assertion for the UIProcess when app is MobileMail
[WebKit-https.git] / Source / WebKit2 / UIProcess / API / APIProcessPoolConfiguration.cpp
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 #include "config.h"
27 #include "APIProcessPoolConfiguration.h"
28
29 #include "APIWebsiteDataStore.h"
30 #include "WebProcessPool.h"
31
32 namespace API {
33
34 Ref<ProcessPoolConfiguration> ProcessPoolConfiguration::create()
35 {
36     return adoptRef(*new ProcessPoolConfiguration);
37 }
38
39 Ref<ProcessPoolConfiguration> ProcessPoolConfiguration::createWithLegacyOptions()
40 {
41     auto configuration = ProcessPoolConfiguration::create();
42
43     configuration->m_shouldHaveLegacyDataStore = true;
44     configuration->m_maximumProcessCount = 1;
45     configuration->m_cacheModel = WebKit::CacheModelDocumentViewer;
46
47     configuration->m_applicationCacheDirectory = WebKit::WebProcessPool::legacyPlatformDefaultApplicationCacheDirectory();
48     configuration->m_applicationCacheFlatFileSubdirectoryName = "ApplicationCache";
49     configuration->m_diskCacheDirectory = WebKit::WebProcessPool::legacyPlatformDefaultNetworkCacheDirectory();
50     configuration->m_mediaCacheDirectory = WebKit::WebProcessPool::legacyPlatformDefaultMediaCacheDirectory();
51     configuration->m_indexedDBDatabaseDirectory = WebKit::WebProcessPool::legacyPlatformDefaultIndexedDBDatabaseDirectory();
52     configuration->m_localStorageDirectory = WebKit::WebProcessPool::legacyPlatformDefaultLocalStorageDirectory();
53     configuration->m_mediaKeysStorageDirectory = WebKit::WebProcessPool::legacyPlatformDefaultMediaKeysStorageDirectory();
54     configuration->m_webSQLDatabaseDirectory = WebKit::WebProcessPool::legacyPlatformDefaultWebSQLDatabaseDirectory();
55     configuration->m_javaScriptConfigurationDirectory = WebKit::WebProcessPool::legacyPlatformDefaultJavaScriptConfigurationDirectory();
56
57     return configuration;
58 }
59
60 Ref<ProcessPoolConfiguration> ProcessPoolConfiguration::createWithWebsiteDataStoreConfiguration(const WebKit::WebsiteDataStore::Configuration& legacyConfiguration)
61 {
62     auto configuration = ProcessPoolConfiguration::create();
63
64     configuration->m_applicationCacheDirectory = legacyConfiguration.applicationCacheDirectory;
65     configuration->m_applicationCacheFlatFileSubdirectoryName = legacyConfiguration.applicationCacheFlatFileSubdirectoryName;
66     configuration->m_diskCacheDirectory = legacyConfiguration.networkCacheDirectory;
67     configuration->m_mediaCacheDirectory = legacyConfiguration.mediaCacheDirectory;
68     configuration->m_indexedDBDatabaseDirectory = WebKit::WebProcessPool::legacyPlatformDefaultIndexedDBDatabaseDirectory();
69     configuration->m_localStorageDirectory = legacyConfiguration.localStorageDirectory;
70     configuration->m_mediaKeysStorageDirectory = legacyConfiguration.mediaKeysStorageDirectory;
71     configuration->m_webSQLDatabaseDirectory = legacyConfiguration.webSQLDatabaseDirectory;
72
73     return configuration;
74 }
75
76 ProcessPoolConfiguration::ProcessPoolConfiguration()
77     : m_applicationCacheDirectory(WebsiteDataStore::defaultApplicationCacheDirectory())
78     , m_applicationCacheFlatFileSubdirectoryName("Files")
79     , m_diskCacheDirectory(WebsiteDataStore::defaultNetworkCacheDirectory())
80     , m_mediaCacheDirectory(WebsiteDataStore::defaultMediaCacheDirectory())
81     , m_indexedDBDatabaseDirectory(WebsiteDataStore::defaultIndexedDBDatabaseDirectory())
82     , m_localStorageDirectory(WebsiteDataStore::defaultLocalStorageDirectory())
83     , m_webSQLDatabaseDirectory(WebsiteDataStore::defaultWebSQLDatabaseDirectory())
84     , m_mediaKeysStorageDirectory(WebsiteDataStore::defaultMediaKeysStorageDirectory())
85     , m_javaScriptConfigurationDirectory(WebsiteDataStore::defaultJavaScriptConfigurationDirectory())
86 {
87 }
88
89 ProcessPoolConfiguration::~ProcessPoolConfiguration()
90 {
91 }
92
93 Ref<ProcessPoolConfiguration> ProcessPoolConfiguration::copy()
94 {
95     auto copy = this->create();
96
97     copy->m_shouldHaveLegacyDataStore = this->m_shouldHaveLegacyDataStore;
98     copy->m_maximumProcessCount = this->m_maximumProcessCount;
99     copy->m_cacheModel = this->m_cacheModel;
100     copy->m_diskCacheSpeculativeValidationEnabled = this->m_diskCacheSpeculativeValidationEnabled;
101     copy->m_diskCacheSizeOverride = this->m_diskCacheSizeOverride;
102     copy->m_applicationCacheDirectory = this->m_applicationCacheDirectory;
103     copy->m_applicationCacheFlatFileSubdirectoryName = this->m_applicationCacheFlatFileSubdirectoryName;
104     copy->m_diskCacheDirectory = this->m_diskCacheDirectory;
105     copy->m_mediaCacheDirectory = this->m_mediaCacheDirectory;
106     copy->m_indexedDBDatabaseDirectory = this->m_indexedDBDatabaseDirectory;
107     copy->m_injectedBundlePath = this->m_injectedBundlePath;
108     copy->m_localStorageDirectory = this->m_localStorageDirectory;
109     copy->m_mediaKeysStorageDirectory = this->m_mediaKeysStorageDirectory;
110     copy->m_javaScriptConfigurationDirectory = this->m_javaScriptConfigurationDirectory;
111     copy->m_webSQLDatabaseDirectory = this->m_webSQLDatabaseDirectory;
112     copy->m_cachePartitionedURLSchemes = this->m_cachePartitionedURLSchemes;
113     copy->m_alwaysRevalidatedURLSchemes = this->m_alwaysRevalidatedURLSchemes;
114     copy->m_additionalReadAccessAllowedPaths = this->m_additionalReadAccessAllowedPaths;
115     copy->m_fullySynchronousModeIsAllowedForTesting = this->m_fullySynchronousModeIsAllowedForTesting;
116     copy->m_ignoreSynchronousMessagingTimeoutsForTesting = this->m_ignoreSynchronousMessagingTimeoutsForTesting;
117     copy->m_overrideLanguages = this->m_overrideLanguages;
118     copy->m_sourceApplicationBundleIdentifier = this->m_sourceApplicationBundleIdentifier;
119     copy->m_sourceApplicationSecondaryIdentifier = this->m_sourceApplicationSecondaryIdentifier;
120     copy->m_alwaysRunsAtBackgroundPriority = this->m_alwaysRunsAtBackgroundPriority;
121     copy->m_shouldTakeUIBackgroundAssertion = this->m_shouldTakeUIBackgroundAssertion;
122     copy->m_shouldCaptureAudioInUIProcess = this->m_shouldCaptureAudioInUIProcess;
123 #if PLATFORM(IOS)
124     copy->m_ctDataConnectionServiceType = this->m_ctDataConnectionServiceType;
125 #endif
126     
127     return copy;
128 }
129
130 } // namespace API