CFURLStorageSessionRef ResourceHandle::currentStorageSession()
{
    if (CFURLStorageSessionRef privateStorageSession = privateBrowsingStorageSession())
        return privateStorageSession;
#if PLATFORM(WIN)
    return defaultStorageSession();
#else
    return 0;
#endif
}
Ejemplo n.º 2
0
void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters& parameters, CoreIPC::MessageDecoder&)
{
    setShouldPaintNativeControls(parameters.shouldPaintNativeControls);

#if USE(CFNETWORK)
    RetainPtr<CFURLStorageSessionRef> defaultStorageSession(AdoptCF, wkDeserializeStorageSession(parameters.serializedDefaultStorageSession.get()));
    ResourceHandle::setDefaultStorageSession(defaultStorageSession.get());

    WebCookieManager::shared().setHTTPCookieAcceptPolicy(parameters.initialHTTPCookieAcceptPolicy);

    // By using the default storage session that came from the ui process, the web process
    // automatically uses the same the URL Cache as ui process.
    if (defaultStorageSession)
        return;

    if (!parameters.diskCacheDirectory)
        return;

    CFIndex cacheDiskCapacity = parameters.cfURLCacheDiskCapacity;
    CFIndex cacheMemoryCapacity = parameters.cfURLCacheMemoryCapacity;
    RetainPtr<CFURLCacheRef> uiProcessCache(AdoptCF, CFURLCacheCreate(kCFAllocatorDefault, cacheMemoryCapacity, cacheDiskCapacity, parameters.diskCacheDirectory.createCFString().get()));
    CFURLCacheSetSharedURLCache(uiProcessCache.get());
#endif // USE(CFNETWORK)
}
RetainPtr<CFURLStorageSessionRef> ResourceHandle::createPrivateBrowsingStorageSession(CFStringRef identifier)
{
#if PLATFORM(WIN)
    return RetainPtr<CFURLStorageSessionRef>(AdoptCF, wkCreatePrivateStorageSession(identifier, defaultStorageSession()));
#else
    return RetainPtr<CFURLStorageSessionRef>(AdoptCF, wkCreatePrivateStorageSession(identifier));
#endif
}