Title: [137821] trunk/Source/WebKit2
Revision
137821
Author
[email protected]
Date
2012-12-15 16:22:35 -0800 (Sat, 15 Dec 2012)

Log Message

The network process should use the correct NSURLCache location and set its size correctly for the CacheModel
<rdar://problem/12848505>
https://bugs.webkit.org/show_bug.cgi?id=105115

Reviewed by Anders Carlsson.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::NetworkProcess):
(WebKit::NetworkProcess::initializeNetworkProcess):
(WebKit::NetworkProcess::setCacheModel):
* NetworkProcess/NetworkProcess.h:
(NetworkProcess):
* NetworkProcess/mac/NetworkProcessMac.mm:
(WebKit::NetworkProcess::platformInitialize):
(WebKit::memorySize):
(WebKit::volumeFreeSize):
(WebKit::NetworkProcess::platformSetCacheModel):
Copy code from the WebProcess to set up the NSURLCache correctly (location and size).
We should eventually move the calculation of this to the WebContext so it can be done
once.

* Shared/Network/NetworkProcessCreationParameters.cpp:
(WebKit::NetworkProcessCreationParameters::encode):
(WebKit::NetworkProcessCreationParameters::decode):
* Shared/Network/NetworkProcessCreationParameters.h:
(NetworkProcessCreationParameters):
Add the necessary creation parameters to set up the cache.

* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::didFinishLaunching):
* UIProcess/Network/NetworkProcessProxy.h:
(NetworkProcessProxy):
* UIProcess/Network/mac/NetworkProcessProxyMac.mm:
* UIProcess/WebContext.cpp:
(WebKit::WebContext::ensureNetworkProcess):
(WebKit::WebContext::setCacheModel):
* UIProcess/WebContext.h:
(WebKit):
(WebContext):
* UIProcess/mac/WebContextMac.mm:
(WebKit):
(WebKit::WebContext::platformInitializeNetworkProcess):
Move initializing the NetworkProcess to just after creating (matching the WebProcess),
rather than waiting for it finish loading before sending the creation parameters.
Additionally, this moves the setting up of the creation parameters to the WebContext,
as that is where all the interesting state resides (and also matches the WebProcess).

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (137820 => 137821)


--- trunk/Source/WebKit2/ChangeLog	2012-12-16 00:18:49 UTC (rev 137820)
+++ trunk/Source/WebKit2/ChangeLog	2012-12-16 00:22:35 UTC (rev 137821)
@@ -1,3 +1,52 @@
+2012-12-15  Sam Weinig  <[email protected]>
+
+        The network process should use the correct NSURLCache location and set its size correctly for the CacheModel
+        <rdar://problem/12848505>
+        https://bugs.webkit.org/show_bug.cgi?id=105115
+
+        Reviewed by Anders Carlsson.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::NetworkProcess):
+        (WebKit::NetworkProcess::initializeNetworkProcess):
+        (WebKit::NetworkProcess::setCacheModel):
+        * NetworkProcess/NetworkProcess.h:
+        (NetworkProcess):
+        * NetworkProcess/mac/NetworkProcessMac.mm:
+        (WebKit::NetworkProcess::platformInitialize):
+        (WebKit::memorySize):
+        (WebKit::volumeFreeSize):
+        (WebKit::NetworkProcess::platformSetCacheModel):
+        Copy code from the WebProcess to set up the NSURLCache correctly (location and size).
+        We should eventually move the calculation of this to the WebContext so it can be done
+        once.
+
+        * Shared/Network/NetworkProcessCreationParameters.cpp:
+        (WebKit::NetworkProcessCreationParameters::encode):
+        (WebKit::NetworkProcessCreationParameters::decode):
+        * Shared/Network/NetworkProcessCreationParameters.h:
+        (NetworkProcessCreationParameters):
+        Add the necessary creation parameters to set up the cache.
+
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::didFinishLaunching):
+        * UIProcess/Network/NetworkProcessProxy.h:
+        (NetworkProcessProxy):
+        * UIProcess/Network/mac/NetworkProcessProxyMac.mm:
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::ensureNetworkProcess):
+        (WebKit::WebContext::setCacheModel):
+        * UIProcess/WebContext.h:
+        (WebKit):
+        (WebContext):
+        * UIProcess/mac/WebContextMac.mm:
+        (WebKit):
+        (WebKit::WebContext::platformInitializeNetworkProcess):
+        Move initializing the NetworkProcess to just after creating (matching the WebProcess),
+        rather than waiting for it finish loading before sending the creation parameters.
+        Additionally, this moves the setting up of the creation parameters to the WebContext,
+        as that is where all the interesting state resides (and also matches the WebProcess).
+
 2012-12-15  Andy Estes  <[email protected]>
 
         Clean up the previous build fix; access m_networkProcess directly.

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp (137820 => 137821)


--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp	2012-12-16 00:18:49 UTC (rev 137820)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp	2012-12-16 00:22:35 UTC (rev 137821)
@@ -52,6 +52,8 @@
 }
 
 NetworkProcess::NetworkProcess()
+    : m_hasSetCacheModel(false)
+    , m_cacheModel(CacheModelDocumentViewer)
 {
 }
 
@@ -99,13 +101,15 @@
 
 void NetworkProcess::initializeNetworkProcess(const NetworkProcessCreationParameters& parameters)
 {
-    platformInitialize(parameters);
-
 #if !LOG_DISABLED
     WebCore::initializeLoggingChannelsIfNecessary();
     WebKit::initializeLogChannelsIfNecessary();
 #endif // !LOG_DISABLED
 
+    platformInitialize(parameters);
+
+    setCacheModel(static_cast<uint32_t>(parameters.cacheModel));
+
 #if PLATFORM(MAC) || USE(CFNETWORK)
     RemoteNetworkingContext::setPrivateBrowsingStorageSessionIdentifierBase(parameters.uiProcessBundleIdentifier);
 #endif
@@ -159,6 +163,17 @@
 }
 #endif
 
+void NetworkProcess::setCacheModel(uint32_t cm)
+{
+    CacheModel cacheModel = static_cast<CacheModel>(cm);
+
+    if (!m_hasSetCacheModel || cacheModel != m_cacheModel) {
+        m_hasSetCacheModel = true;
+        m_cacheModel = cacheModel;
+        platformSetCacheModel(cacheModel);
+    }
+}
+
 } // namespace WebKit
 
 #endif // ENABLE(NETWORK_PROCESS)

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h (137820 => 137821)


--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h	2012-12-16 00:18:49 UTC (rev 137820)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h	2012-12-16 00:22:35 UTC (rev 137821)
@@ -28,6 +28,7 @@
 
 #if ENABLE(NETWORK_PROCESS)
 
+#include "CacheModel.h"
 #include "ChildProcess.h"
 #include "NetworkResourceLoadScheduler.h"
 #include <wtf/Forward.h>
@@ -72,12 +73,15 @@
     void createNetworkConnectionToWebProcess();
     void ensurePrivateBrowsingSession();
     void destroyPrivateBrowsingSession();
-
+    void setCacheModel(uint32_t);
 #if ENABLE(CUSTOM_PROTOCOLS)
     void registerSchemeForCustomProtocol(const String&);
     void unregisterSchemeForCustomProtocol(const String&);
 #endif
 
+    // Platform Helpers
+    void platformSetCacheModel(CacheModel);
+
     // The connection to the UI process.
     RefPtr<CoreIPC::Connection> m_uiConnection;
 
@@ -85,6 +89,10 @@
     Vector<RefPtr<NetworkConnectionToWebProcess> > m_webProcessConnections;
 
     NetworkResourceLoadScheduler m_networkResourceLoadScheduler;
+
+    String m_diskCacheDirectory;
+    bool m_hasSetCacheModel;
+    CacheModel m_cacheModel;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessMac.mm (137820 => 137821)


--- trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessMac.mm	2012-12-16 00:18:49 UTC (rev 137820)
+++ trunk/Source/WebKit2/NetworkProcess/mac/NetworkProcessMac.mm	2012-12-16 00:22:35 UTC (rev 137821)
@@ -29,8 +29,12 @@
 #if ENABLE(NETWORK_PROCESS)
 
 #import "NetworkProcessCreationParameters.h"
+#import "SandboxExtension.h"
 #import <WebCore/LocalizedStrings.h>
 #import <WebKitSystemInterface.h>
+#import <mach/host_info.h>
+#import <mach/mach.h>
+#import <mach/mach_error.h>
 #import <wtf/text/WTFString.h>
 
 using namespace WebCore;
@@ -39,12 +43,74 @@
 
 void NetworkProcess::platformInitialize(const NetworkProcessCreationParameters& parameters)
 {
+    m_diskCacheDirectory = parameters.diskCacheDirectory;
+
+    if (!m_diskCacheDirectory.isNull()) {
+        SandboxExtension::consumePermanently(parameters.diskCacheDirectoryExtensionHandle);
+        NSUInteger cacheMemoryCapacity = parameters.nsURLCacheMemoryCapacity;
+        NSUInteger cacheDiskCapacity = parameters.nsURLCacheDiskCapacity;
+
+        RetainPtr<NSURLCache> parentProcessURLCache(AdoptNS, [[NSURLCache alloc] initWithMemoryCapacity:cacheMemoryCapacity diskCapacity:cacheDiskCapacity diskPath:parameters.diskCacheDirectory]);
+        [NSURLCache setSharedURLCache:parentProcessURLCache.get()];
+    }
+
+    // FIXME: This should be moved to earlier in the setup process, as this won't work once sandboxing is enable.
     NSString *applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Networking", "visible name of the network process. The argument is the application name."),
         (NSString *)parameters.parentProcessName];
     
     WKSetVisibleApplicationName((CFStringRef)applicationName);
 }
 
+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.
+}
+
 } // namespace WebKit
 
 #endif // ENABLE(NETWORK_PROCESS)

Modified: trunk/Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.cpp (137820 => 137821)


--- trunk/Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.cpp	2012-12-16 00:18:49 UTC (rev 137820)
+++ trunk/Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.cpp	2012-12-16 00:22:35 UTC (rev 137821)
@@ -38,30 +38,45 @@
 
 void NetworkProcessCreationParameters::encode(CoreIPC::ArgumentEncoder& encoder) const
 {
+    encoder << diskCacheDirectory;
+    encoder << diskCacheDirectoryExtensionHandle;
+    encoder << privateBrowsingEnabled;
+    encoder.encodeEnum(cacheModel);
 #if PLATFORM(MAC)
     encoder << parentProcessName;
     encoder << uiProcessBundleIdentifier;
-#endif
-    encoder << privateBrowsingEnabled;
+    encoder << nsURLCacheMemoryCapacity;
+    encoder << nsURLCacheDiskCapacity;
 #if ENABLE(CUSTOM_PROTOCOLS)
     encoder << urlSchemesRegisteredForCustomProtocols;
 #endif
+#endif
 }
 
 bool NetworkProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, NetworkProcessCreationParameters& result)
 {
+    if (!decoder->decode(result.diskCacheDirectory))
+        return false;
+    if (!decoder->decode(result.diskCacheDirectoryExtensionHandle))
+        return false;
+    if (!decoder->decode(result.privateBrowsingEnabled))
+        return false;
+    if (!decoder->decodeEnum(result.cacheModel))
+        return false;
 #if PLATFORM(MAC)
     if (!decoder->decode(result.parentProcessName))
         return false;
     if (!decoder->decode(result.uiProcessBundleIdentifier))
         return false;
-#endif
-    if (!decoder->decode(result.privateBrowsingEnabled))
+    if (!decoder->decode(result.nsURLCacheMemoryCapacity))
         return false;
+    if (!decoder->decode(result.nsURLCacheDiskCapacity))
+        return false;
 #if ENABLE(CUSTOM_PROTOCOLS)
     if (!decoder->decode(result.urlSchemesRegisteredForCustomProtocols))
         return false;
 #endif
+#endif
 
     return true;
 }

Modified: trunk/Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.h (137820 => 137821)


--- trunk/Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.h	2012-12-16 00:18:49 UTC (rev 137820)
+++ trunk/Source/WebKit2/Shared/Network/NetworkProcessCreationParameters.h	2012-12-16 00:22:35 UTC (rev 137821)
@@ -28,6 +28,9 @@
 
 #if ENABLE(NETWORK_PROCESS)
 
+#include "CacheModel.h"
+#include "SandboxExtension.h"
+#include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
 
 namespace CoreIPC {
@@ -43,16 +46,22 @@
     void encode(CoreIPC::ArgumentEncoder&) const;
     static bool decode(CoreIPC::ArgumentDecoder*, NetworkProcessCreationParameters&);
 
+    bool privateBrowsingEnabled;
+    CacheModel cacheModel;
+
+    String diskCacheDirectory;
+    SandboxExtension::Handle diskCacheDirectoryExtensionHandle;
+
 #if PLATFORM(MAC)
     String parentProcessName;
     String uiProcessBundleIdentifier;
-#endif
+    uint64_t nsURLCacheMemoryCapacity;
+    uint64_t nsURLCacheDiskCapacity;
 
-    bool privateBrowsingEnabled;
-
 #if ENABLE(CUSTOM_PROTOCOLS)
     Vector<String> urlSchemesRegisteredForCustomProtocols;
 #endif
+#endif
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp (137820 => 137821)


--- trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp	2012-12-16 00:18:49 UTC (rev 137820)
+++ trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp	2012-12-16 00:22:35 UTC (rev 137821)
@@ -145,12 +145,6 @@
         return;
     }
 
-    NetworkProcessCreationParameters parameters;
-    platformInitializeNetworkProcess(parameters);
-
-    // Initialize the network host process.
-    connection()->send(Messages::NetworkProcess::InitializeNetworkProcess(parameters), 0);
-
     for (unsigned i = 0; i < m_numPendingConnectionRequests; ++i)
         connection()->send(Messages::NetworkProcess::CreateNetworkConnectionToWebProcess(), 0);
     

Modified: trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h (137820 => 137821)


--- trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h	2012-12-16 00:18:49 UTC (rev 137820)
+++ trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h	2012-12-16 00:22:35 UTC (rev 137821)
@@ -59,7 +59,6 @@
     NetworkProcessProxy(WebContext*);
 
     virtual void getLaunchOptions(ProcessLauncher::LaunchOptions&) OVERRIDE;
-    void platformInitializeNetworkProcess(NetworkProcessCreationParameters&);
 
     void networkProcessCrashedOrFailedToLaunch();
 

Modified: trunk/Source/WebKit2/UIProcess/Network/mac/NetworkProcessProxyMac.mm (137820 => 137821)


--- trunk/Source/WebKit2/UIProcess/Network/mac/NetworkProcessProxyMac.mm	2012-12-16 00:18:49 UTC (rev 137820)
+++ trunk/Source/WebKit2/UIProcess/Network/mac/NetworkProcessProxyMac.mm	2012-12-16 00:22:35 UTC (rev 137821)
@@ -26,9 +26,7 @@
 #import "config.h"
 #import "NetworkProcessProxy.h"
 
-#import "NetworkProcessCreationParameters.h"
 #import "NetworkProcessMessages.h"
-#import "WKBrowsingContextControllerInternal.h"
 
 #if ENABLE(NETWORK_PROCESS)
 
@@ -36,15 +34,6 @@
 
 namespace WebKit {
 
-void NetworkProcessProxy::platformInitializeNetworkProcess(NetworkProcessCreationParameters& parameters)
-{
-    parameters.parentProcessName = [[NSProcessInfo processInfo] processName];
-    parameters.uiProcessBundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
-    
-    for (NSString *scheme in [WKBrowsingContextController customSchemes])
-        parameters.urlSchemesRegisteredForCustomProtocols.append(scheme);
-}
-
 void NetworkProcessProxy::setApplicationIsOccluded(bool applicationIsOccluded)
 {
     if (!isValid())

Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (137820 => 137821)


--- trunk/Source/WebKit2/UIProcess/WebContext.cpp	2012-12-16 00:18:49 UTC (rev 137820)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp	2012-12-16 00:22:35 UTC (rev 137821)
@@ -72,6 +72,7 @@
 #endif
 
 #if ENABLE(NETWORK_PROCESS)
+#include "NetworkProcessCreationParameters.h"
 #include "NetworkProcessMessages.h"
 #include "NetworkProcessProxy.h"
 #endif
@@ -363,6 +364,20 @@
         return;
 
     m_networkProcess = NetworkProcessProxy::create(this);
+
+    NetworkProcessCreationParameters parameters;
+
+    parameters.diskCacheDirectory = diskCacheDirectory();
+    if (!parameters.diskCacheDirectory.isEmpty())
+        SandboxExtension::createHandleForReadWriteDirectory(parameters.diskCacheDirectory, parameters.diskCacheDirectoryExtensionHandle);
+
+    parameters.cacheModel = m_cacheModel;
+
+    // Add any platform specific parameters
+    platformInitializeNetworkProcess(parameters);
+
+    // Initialize the network process.
+    m_networkProcess->send(Messages::NetworkProcess::InitializeNetworkProcess(parameters), 0);
 }
 
 void WebContext::removeNetworkProcessProxy(NetworkProcessProxy* networkProcessProxy)
@@ -817,6 +832,8 @@
 {
     m_cacheModel = cacheModel;
     sendToAllProcesses(Messages::WebProcess::SetCacheModel(static_cast<uint32_t>(m_cacheModel)));
+
+    // FIXME: Inform the Network Process if in use.
 }
 
 void WebContext::setDefaultRequestTimeoutInterval(double timeoutInterval)

Modified: trunk/Source/WebKit2/UIProcess/WebContext.h (137820 => 137821)


--- trunk/Source/WebKit2/UIProcess/WebContext.h	2012-12-16 00:18:49 UTC (rev 137820)
+++ trunk/Source/WebKit2/UIProcess/WebContext.h	2012-12-16 00:22:35 UTC (rev 137821)
@@ -51,6 +51,7 @@
 namespace WebKit {
 
 class DownloadProxy;
+class NetworkProcessProxy;
 class WebApplicationCacheManagerProxy;
 class WebCookieManagerProxy;
 class WebDatabaseManagerProxy;
@@ -58,7 +59,6 @@
 class WebIconDatabase;
 class WebKeyValueStorageManagerProxy;
 class WebMediaCacheManagerProxy;
-class NetworkProcessProxy;
 class WebNotificationManagerProxy;
 class WebPageGroup;
 class WebPageProxy;
@@ -77,6 +77,9 @@
 #if USE(SOUP)
 class WebSoupRequestManagerProxy;
 #endif
+#if ENABLE(NETWORK_PROCESS)
+struct NetworkProcessCreationParameters;
+#endif
 
 #if PLATFORM(MAC)
 extern NSString *SchemeForCustomProtocolRegisteredNotificationName;
@@ -282,6 +285,10 @@
 
     WebProcessProxy* createNewWebProcess();
 
+#if ENABLE(NETWORK_PROCESS)
+    void platformInitializeNetworkProcess(NetworkProcessCreationParameters&);
+#endif
+
 #if PLATFORM(MAC)
     void getPasteboardTypes(const String& pasteboardName, Vector<String>& pasteboardTypes);
     void getPasteboardPathnamesForType(const String& pasteboardName, const String& pasteboardType, Vector<String>& pathnames);

Modified: trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm (137820 => 137821)


--- trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm	2012-12-16 00:18:49 UTC (rev 137820)
+++ trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm	2012-12-16 00:22:35 UTC (rev 137821)
@@ -26,20 +26,24 @@
 #import "config.h"
 #import "WebContext.h"
 
-#import "NetworkProcessProxy.h"
 #import "PluginProcessManager.h"
 #import "SharedWorkerProcessManager.h"
 #import "WKBrowsingContextControllerInternal.h"
+#import "WKBrowsingContextControllerInternal.h"
 #import "WebKitSystemInterface.h"
 #import "WebProcessCreationParameters.h"
 #import "WebProcessMessages.h"
+#import <QuartzCore/CARemoteLayerServer.h>
 #import <WebCore/Color.h>
 #import <WebCore/FileSystem.h>
 #import <WebCore/NotImplemented.h>
 #import <WebCore/PlatformPasteboard.h>
 #import <sys/param.h>
 
-#import <QuartzCore/CARemoteLayerServer.h>
+#if ENABLE(NETWORK_PROCESS)
+#import "NetworkProcessCreationParameters.h"
+#import "NetworkProcessProxy.h"
+#endif
 
 using namespace WebCore;
 
@@ -139,6 +143,21 @@
 #endif
 }
 
+#if ENABLE(NETWORK_PROCESS)
+void WebContext::platformInitializeNetworkProcess(NetworkProcessCreationParameters& parameters)
+{
+    NSURLCache *urlCache = [NSURLCache sharedURLCache];
+    parameters.nsURLCacheMemoryCapacity = [urlCache memoryCapacity];
+    parameters.nsURLCacheDiskCapacity = [urlCache diskCapacity];
+
+    parameters.parentProcessName = [[NSProcessInfo processInfo] processName];
+    parameters.uiProcessBundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
+
+    for (NSString *scheme in [WKBrowsingContextController customSchemes])
+        parameters.urlSchemesRegisteredForCustomProtocols.append(scheme);
+}
+#endif
+
 void WebContext::platformInvalidateContext()
 {
     unregisterNotificationObservers();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to