Diff
Modified: trunk/Source/WebKit2/ChangeLog (166384 => 166385)
--- trunk/Source/WebKit2/ChangeLog 2014-03-27 23:41:46 UTC (rev 166384)
+++ trunk/Source/WebKit2/ChangeLog 2014-03-27 23:46:32 UTC (rev 166385)
@@ -1,3 +1,29 @@
+2014-03-27 Pratik Solanki <psola...@apple.com>
+
+ [iOS WebKit2] Share network process code between iOS and Mac
+ https://bugs.webkit.org/show_bug.cgi?id=130861
+
+ Reviewed by Sam Weinig.
+
+ Implement network process functions for iOS by moving common code from NetworkProcessMac.mm
+ to a new shared file NetworkProcessCocoa.mm and sharing between iOS and Mac.
+
+ * NetworkProcess/NetworkProcess.h:
+ * NetworkProcess/cocoa/NetworkProcessCocoa.mm: Added.
+ (WebKit::NetworkProcess::platformLowMemoryHandler):
+ (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
+ Common initialization code for iOS and Mac.
+ (WebKit::memorySize):
+ (WebKit::volumeFreeSize):
+ (WebKit::NetworkProcess::platformSetCacheModel):
+ * NetworkProcess/ios/NetworkProcessIOS.mm:
+ (WebKit::NetworkProcess::initializeProcess):
+ Remove unnecessary #if PLATFORM(IOS).
+ (WebKit::NetworkProcess::platformInitializeNetworkProcess):
+ * NetworkProcess/mac/NetworkProcessMac.mm:
+ (WebKit::NetworkProcess::platformInitializeNetworkProcess):
+ * WebKit2.xcodeproj/project.pbxproj:
+
2014-03-27 Enrica Casucci <enr...@apple.com>
Add support for AirPlay picker in WK2 for iOS.
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h (166384 => 166385)
--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h 2014-03-27 23:41:46 UTC (rev 166384)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h 2014-03-27 23:46:32 UTC (rev 166385)
@@ -138,6 +138,8 @@
NetworkProcessSupplementMap m_supplements;
#if PLATFORM(COCOA)
+ void platformInitializeNetworkProcessCocoa(const NetworkProcessCreationParameters&);
+
// FIXME: We'd like to be able to do this without the #ifdef, but WorkQueue + BinarySemaphore isn't good enough since
// multiple requests to clear the cache can come in before previous requests complete, and we need to wait for all of them.
// In the future using WorkQueue and a counting semaphore would work, as would WorkQueue supporting the libdispatch concept of "work groups".
Added: trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkProcessCocoa.mm (0 => 166385)
--- trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkProcessCocoa.mm (rev 0)
+++ trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkProcessCocoa.mm 2014-03-27 23:46:32 UTC (rev 166385)
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "NetworkProcess.h"
+
+#if ENABLE(NETWORK_PROCESS)
+
+#import "NetworkProcessCreationParameters.h"
+#import "NetworkResourceLoader.h"
+#import "SandboxExtension.h"
+#import <mach/host_info.h>
+#import <mach/mach.h>
+#import <mach/mach_error.h>
+
+typedef const struct _CFURLCache* CFURLCacheRef;
+extern "C" CFURLCacheRef CFURLCacheCopySharedURLCache();
+extern "C" void _CFURLCachePurgeMemoryCache(CFURLCacheRef);
+
+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+extern "C" void _CFURLCacheSetMinSizeForVMCachedResource(CFURLCacheRef, CFIndex);
+#endif
+
+namespace WebKit {
+
+void NetworkProcess::platformLowMemoryHandler(bool)
+{
+ _CFURLCachePurgeMemoryCache(adoptCF(CFURLCacheCopySharedURLCache()).get());
+}
+
+void NetworkProcess::platformInitializeNetworkProcessCocoa(const NetworkProcessCreationParameters& parameters)
+{
+ m_diskCacheDirectory = parameters.diskCacheDirectory;
+
+ if (!m_diskCacheDirectory.isNull()) {
+ SandboxExtension::consumePermanently(parameters.diskCacheDirectoryExtensionHandle);
+ [NSURLCache setSharedURLCache:adoptNS([[NSURLCache alloc]
+ initWithMemoryCapacity:parameters.nsURLCacheMemoryCapacity
+ diskCapacity:parameters.nsURLCacheDiskCapacity
+ diskPath:parameters.diskCacheDirectory]).get()];
+ }
+
+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+ RetainPtr<CFURLCacheRef> cache = adoptCF(CFURLCacheCopySharedURLCache());
+ if (!cache)
+ return;
+
+ _CFURLCacheSetMinSizeForVMCachedResource(cache.get(), NetworkResourceLoader::fileBackedResourceMinimumSize());
+#endif
+}
+
+static uint64_t memorySize()
+{
+ static host_basic_info_data_t hostInfo;
+
+ static dispatch_once_t once;
+ dispatch_once(&once, ^() {
+ mach_port_t host = mach_host_self();
+ mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT;
+ kern_return_t r = host_info(host, HOST_BASIC_INFO, (host_info_t)&hostInfo, &count);
+ mach_port_deallocate(mach_task_self(), host);
+
+ if (r != KERN_SUCCESS)
+ LOG_ERROR("%s : host_info(%d) : %s.\n", __FUNCTION__, r, mach_error_string(r));
+ });
+
+ return hostInfo.max_mem;
+}
+
+static uint64_t volumeFreeSize(const String& path)
+{
+ NSDictionary *fileSystemAttributesDictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:(NSString *)path error:NULL];
+ return [[fileSystemAttributesDictionary objectForKey:NSFileSystemFreeSize] unsignedLongLongValue];
+}
+
+void NetworkProcess::platformSetCacheModel(CacheModel cacheModel)
+{
+ // As a fudge factor, use 1000 instead of 1024, in case the reported byte
+ // count doesn't align exactly to a megabyte boundary.
+ uint64_t memSize = memorySize() / 1024 / 1000;
+ uint64_t diskFreeSize = volumeFreeSize(m_diskCacheDirectory) / 1024 / 1000;
+
+ unsigned cacheTotalCapacity = 0;
+ unsigned cacheMinDeadCapacity = 0;
+ unsigned cacheMaxDeadCapacity = 0;
+ double deadDecodedDataDeletionInterval = 0;
+ unsigned pageCacheCapacity = 0;
+ unsigned long urlCacheMemoryCapacity = 0;
+ unsigned long urlCacheDiskCapacity = 0;
+
+ calculateCacheSizes(cacheModel, memSize, diskFreeSize,
+ cacheTotalCapacity, cacheMinDeadCapacity, cacheMaxDeadCapacity, deadDecodedDataDeletionInterval,
+ pageCacheCapacity, urlCacheMemoryCapacity, urlCacheDiskCapacity);
+
+
+ NSURLCache *nsurlCache = [NSURLCache sharedURLCache];
+ [nsurlCache setMemoryCapacity:urlCacheMemoryCapacity];
+ [nsurlCache setDiskCapacity:std::max<unsigned long>(urlCacheDiskCapacity, [nsurlCache diskCapacity])]; // Don't shrink a big disk cache, since that would cause churn.
+}
+
+}
+
+#endif
Modified: trunk/Source/WebKit2/NetworkProcess/ios/NetworkProcessIOS.mm (166384 => 166385)
--- trunk/Source/WebKit2/NetworkProcess/ios/NetworkProcessIOS.mm 2014-03-27 23:41:46 UTC (rev 166384)
+++ trunk/Source/WebKit2/NetworkProcess/ios/NetworkProcessIOS.mm 2014-03-27 23:46:32 UTC (rev 166385)
@@ -28,6 +28,7 @@
#if PLATFORM(IOS) && ENABLE(NETWORK_PROCESS)
+#import "NetworkProcessCreationParameters.h"
#import <WebCore/CertificateInfo.h>
#import <WebCore/NotImplemented.h>
#import <WebCore/WebCoreThreadSystemInterface.h>
@@ -42,9 +43,7 @@
void NetworkProcess::initializeProcess(const ChildProcessInitializationParameters&)
{
-#if PLATFORM(IOS)
InitWebCoreThreadSystemInterface();
-#endif // PLATFORM(IOS)
}
void NetworkProcess::initializeProcessName(const ChildProcessInitializationParameters&)
@@ -57,11 +56,6 @@
notImplemented();
}
-void NetworkProcess::platformSetCacheModel(CacheModel)
-{
- notImplemented();
-}
-
void NetworkProcess::allowSpecificHTTPSCertificateForHost(const CertificateInfo& certificateInfo, const String& host)
{
[NSURLRequest setAllowsSpecificHTTPSCertificate:(NSArray *)certificateInfo.certificateChain() forHost:host];
@@ -71,16 +65,11 @@
{
}
-void NetworkProcess::platformLowMemoryHandler(bool)
+void NetworkProcess::platformInitializeNetworkProcess(const NetworkProcessCreationParameters& parameters)
{
- notImplemented();
+ platformInitializeNetworkProcessCocoa(parameters);
}
-void NetworkProcess::platformInitializeNetworkProcess(const NetworkProcessCreationParameters&)
-{
- notImplemented();
-}
-
void NetworkProcess::platformTerminate()
{
notImplemented();
Modified: trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessMac.mm (166384 => 166385)
--- trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessMac.mm 2014-03-27 23:41:46 UTC (rev 166384)
+++ trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessMac.mm 2014-03-27 23:46:32 UTC (rev 166385)
@@ -40,21 +40,10 @@
#import <WebCore/LocalizedStrings.h>
#import <WebCore/MemoryPressureHandler.h>
#import <WebKitSystemInterface.h>
-#import <mach/host_info.h>
-#import <mach/mach.h>
-#import <mach/mach_error.h>
#import <notify.h>
#import <sysexits.h>
#import <wtf/text/WTFString.h>
-typedef struct _CFURLCache* CFURLCacheRef;
-extern "C" CFURLCacheRef CFURLCacheCopySharedURLCache();
-extern "C" void _CFURLCachePurgeMemoryCache(CFURLCacheRef);
-
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
-extern "C" void _CFURLCacheSetMinSizeForVMCachedResource(CFURLCacheRef, CFIndex);
-#endif
-
using namespace WebCore;
@interface NSURLRequest (Details)
@@ -108,89 +97,18 @@
WKCFNetworkSetOverrideSystemProxySettings((CFDictionaryRef)proxySettings);
}
-void NetworkProcess::platformLowMemoryHandler(bool)
-{
- _CFURLCachePurgeMemoryCache(adoptCF(CFURLCacheCopySharedURLCache()).get());
-}
-
void NetworkProcess::platformInitializeNetworkProcess(const NetworkProcessCreationParameters& parameters)
{
- m_diskCacheDirectory = parameters.diskCacheDirectory;
+ platformInitializeNetworkProcessCocoa(parameters);
- if (!m_diskCacheDirectory.isNull()) {
- SandboxExtension::consumePermanently(parameters.diskCacheDirectoryExtensionHandle);
- [NSURLCache setSharedURLCache:adoptNS([[NSURLCache alloc]
- initWithMemoryCapacity:parameters.nsURLCacheMemoryCapacity
- diskCapacity:parameters.nsURLCacheDiskCapacity
- diskPath:parameters.diskCacheDirectory]).get()];
- }
-
#if ENABLE(SEC_ITEM_SHIM)
SecItemShim::shared().initialize(this);
#endif
if (!parameters.httpProxy.isNull() || !parameters.httpsProxy.isNull())
overrideSystemProxies(parameters.httpProxy, parameters.httpsProxy);
-
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
- RetainPtr<CFURLCacheRef> cache = adoptCF(CFURLCacheCopySharedURLCache());
- if (!cache)
- return;
-
- _CFURLCacheSetMinSizeForVMCachedResource(cache.get(), NetworkResourceLoader::fileBackedResourceMinimumSize());
-#endif
}
-static uint64_t memorySize()
-{
- static host_basic_info_data_t hostInfo;
-
- static dispatch_once_t once;
- dispatch_once(&once, ^() {
- mach_port_t host = mach_host_self();
- mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT;
- kern_return_t r = host_info(host, HOST_BASIC_INFO, (host_info_t)&hostInfo, &count);
- mach_port_deallocate(mach_task_self(), host);
-
- if (r != KERN_SUCCESS)
- LOG_ERROR("%s : host_info(%d) : %s.\n", __FUNCTION__, r, mach_error_string(r));
- });
-
- return hostInfo.max_mem;
-}
-
-static uint64_t volumeFreeSize(const String& path)
-{
- NSDictionary *fileSystemAttributesDictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:(NSString *)path error:NULL];
- return [[fileSystemAttributesDictionary objectForKey:NSFileSystemFreeSize] unsignedLongLongValue];
-}
-
-void NetworkProcess::platformSetCacheModel(CacheModel cacheModel)
-{
-
- // As a fudge factor, use 1000 instead of 1024, in case the reported byte
- // count doesn't align exactly to a megabyte boundary.
- uint64_t memSize = memorySize() / 1024 / 1000;
- uint64_t diskFreeSize = volumeFreeSize(m_diskCacheDirectory) / 1024 / 1000;
-
- unsigned cacheTotalCapacity = 0;
- unsigned cacheMinDeadCapacity = 0;
- unsigned cacheMaxDeadCapacity = 0;
- double deadDecodedDataDeletionInterval = 0;
- unsigned pageCacheCapacity = 0;
- unsigned long urlCacheMemoryCapacity = 0;
- unsigned long urlCacheDiskCapacity = 0;
-
- calculateCacheSizes(cacheModel, memSize, diskFreeSize,
- cacheTotalCapacity, cacheMinDeadCapacity, cacheMaxDeadCapacity, deadDecodedDataDeletionInterval,
- pageCacheCapacity, urlCacheMemoryCapacity, urlCacheDiskCapacity);
-
-
- NSURLCache *nsurlCache = [NSURLCache sharedURLCache];
- [nsurlCache setMemoryCapacity:urlCacheMemoryCapacity];
- [nsurlCache setDiskCapacity:std::max<unsigned long>(urlCacheDiskCapacity, [nsurlCache diskCapacity])]; // Don't shrink a big disk cache, since that would cause churn.
-}
-
void NetworkProcess::allowSpecificHTTPSCertificateForHost(const CertificateInfo& certificateInfo, const String& host)
{
[NSURLRequest setAllowsSpecificHTTPSCertificate:(NSArray *)certificateInfo.certificateChain() forHost:(NSString *)host];
Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (166384 => 166385)
--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2014-03-27 23:41:46 UTC (rev 166384)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2014-03-27 23:46:32 UTC (rev 166385)
@@ -971,6 +971,7 @@
7CF47FFB17275C57008ACB91 /* PageBanner.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CF47FF917275C57008ACB91 /* PageBanner.h */; };
7CF47FFE17276AE3008ACB91 /* WKBundlePageBannerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7CF47FFC17276AE3008ACB91 /* WKBundlePageBannerMac.mm */; };
7CF47FFF17276AE3008ACB91 /* WKBundlePageBannerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CF47FFD17276AE3008ACB91 /* WKBundlePageBannerMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 7EC4F0FB18E4ACBB008056AF /* NetworkProcessCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7EC4F0F918E4A945008056AF /* NetworkProcessCocoa.mm */; };
84477853176FCC0800CDC7BB /* InjectedBundleHitTestResultMediaType.h in Headers */ = {isa = PBXBuildFile; fileRef = 84477851176FCAC100CDC7BB /* InjectedBundleHitTestResultMediaType.h */; };
868160D0187645570021E79D /* WindowServerConnection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 868160CF187645370021E79D /* WindowServerConnection.mm */; };
8CFECE941490F140002AAA32 /* EditorState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CFECE931490F140002AAA32 /* EditorState.cpp */; };
@@ -2808,6 +2809,7 @@
7CF47FF917275C57008ACB91 /* PageBanner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageBanner.h; sourceTree = "<group>"; };
7CF47FFC17276AE3008ACB91 /* WKBundlePageBannerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKBundlePageBannerMac.mm; sourceTree = "<group>"; };
7CF47FFD17276AE3008ACB91 /* WKBundlePageBannerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundlePageBannerMac.h; sourceTree = "<group>"; };
+ 7EC4F0F918E4A945008056AF /* NetworkProcessCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = NetworkProcessCocoa.mm; path = NetworkProcess/cocoa/NetworkProcessCocoa.mm; sourceTree = "<group>"; };
84477851176FCAC100CDC7BB /* InjectedBundleHitTestResultMediaType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundleHitTestResultMediaType.h; sourceTree = "<group>"; };
868160CD18763D4B0021E79D /* WindowServerConnection.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WindowServerConnection.h; sourceTree = "<group>"; };
868160CF187645370021E79D /* WindowServerConnection.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WindowServerConnection.mm; sourceTree = "<group>"; };
@@ -4749,6 +4751,7 @@
510CC7DA16138E0100D03ED3 /* NetworkProcess */ = {
isa = PBXGroup;
children = (
+ 7EC4F0F818E4A922008056AF /* cocoa */,
2DA944BB188511DD00ED86DB /* ios */,
BC82837C16B45DA500A278FE /* EntryPoint */,
E1798C7616E6815500240139 /* FileAPI */,
@@ -5138,6 +5141,14 @@
path = Resources/PlugInSandboxProfiles;
sourceTree = "<group>";
};
+ 7EC4F0F818E4A922008056AF /* cocoa */ = {
+ isa = PBXGroup;
+ children = (
+ 7EC4F0F918E4A945008056AF /* NetworkProcessCocoa.mm */,
+ );
+ name = cocoa;
+ sourceTree = "<group>";
+ };
9394AE411702B25B00344232 /* mac */ = {
isa = PBXGroup;
children = (
@@ -8458,6 +8469,7 @@
BC857FB612B830E600EDEB2E /* WebOpenPanelParameters.cpp in Sources */,
BC857F8612B82D0B00EDEB2E /* WebOpenPanelResultListener.cpp in Sources */,
1AFDD3191891CA1200153970 /* WKPreferences.mm in Sources */,
+ 7EC4F0FB18E4ACBB008056AF /* NetworkProcessCocoa.mm in Sources */,
511D8201185BC217001AED56 /* SQLiteIDBTransaction.cpp in Sources */,
2DA944BD188511E700ED86DB /* NetworkProcessIOS.mm in Sources */,
BC857F7E12B82CEE00EDEB2E /* WebOpenPanelResultListenerProxy.cpp in Sources */,