summaryrefslogtreecommitdiff
path: root/Source/WebKit2/WebProcess/qt/WebProcessQt.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2013-09-13 12:51:20 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-19 20:50:05 +0200
commitd441d6f39bb846989d95bcf5caf387b42414718d (patch)
treee367e64a75991c554930278175d403c072de6bb8 /Source/WebKit2/WebProcess/qt/WebProcessQt.cpp
parent0060b2994c07842f4c59de64b5e3e430525c4b90 (diff)
downloadqtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit. Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/WebKit2/WebProcess/qt/WebProcessQt.cpp')
-rw-r--r--Source/WebKit2/WebProcess/qt/WebProcessQt.cpp80
1 files changed, 28 insertions, 52 deletions
diff --git a/Source/WebKit2/WebProcess/qt/WebProcessQt.cpp b/Source/WebKit2/WebProcess/qt/WebProcessQt.cpp
index 92caebe29..0dcaf9d17 100644
--- a/Source/WebKit2/WebProcess/qt/WebProcessQt.cpp
+++ b/Source/WebKit2/WebProcess/qt/WebProcessQt.cpp
@@ -29,6 +29,7 @@
#include "InjectedBundle.h"
#include "QtBuiltinBundle.h"
#include "QtNetworkAccessManager.h"
+#include "SeccompFiltersWebProcessQt.h"
#include "WKBundleAPICast.h"
#include "WebProcessCreationParameters.h"
@@ -41,6 +42,7 @@
#include <WebCore/MemoryCache.h>
#include <WebCore/PageCache.h>
#include <WebCore/RuntimeEnabledFeatures.h>
+#include <wtf/RAMSize.h>
#if defined(Q_OS_MACX)
#include <dispatch/dispatch.h>
@@ -55,50 +57,15 @@ using namespace WebCore;
namespace WebKit {
-static uint64_t physicalMemorySizeInBytes()
-{
- static uint64_t physicalMemorySize = 0;
-
- if (!physicalMemorySize) {
-#if defined(Q_OS_MACX)
- host_basic_info_data_t hostInfo;
- 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)
- physicalMemorySize = hostInfo.max_mem;
-
-#elif defined(Q_OS_WIN)
- MEMORYSTATUSEX statex;
- statex.dwLength = sizeof(statex);
- GlobalMemoryStatusEx(&statex);
- physicalMemorySize = static_cast<uint64_t>(statex.ullTotalPhys);
-
-#else
- long pageSize = sysconf(_SC_PAGESIZE);
- long numberOfPages = sysconf(_SC_PHYS_PAGES);
-
- if (pageSize > 0 && numberOfPages > 0)
- physicalMemorySize = static_cast<uint64_t>(pageSize) * static_cast<uint64_t>(numberOfPages);
-
-#endif
- }
- return physicalMemorySize;
-}
-
void WebProcess::platformSetCacheModel(CacheModel cacheModel)
{
- QNetworkDiskCache* diskCache = qobject_cast<QNetworkDiskCache*>(m_networkAccessManager->cache());
- ASSERT(diskCache);
-
- uint64_t physicalMemorySizeInMegabytes = physicalMemorySizeInBytes() / 1024 / 1024;
+ uint64_t physicalMemorySizeInMegabytes = WTF::ramSize() / 1024 / 1024;
// The Mac port of WebKit2 uses a fudge factor of 1000 here to account for misalignment, however,
// that tends to overestimate the memory quite a bit (1 byte misalignment ~ 48 MiB misestimation).
// We use 1024 * 1023 for now to keep the estimation error down to +/- ~1 MiB.
- uint64_t freeVolumeSpace = WebCore::getVolumeFreeSizeForPath(diskCache->cacheDirectory().toLocal8Bit().constData()) / 1024 / 1023;
+ QNetworkDiskCache* diskCache = qobject_cast<QNetworkDiskCache*>(m_networkAccessManager->cache());
+ uint64_t freeVolumeSpace = !diskCache ? 0 : WebCore::getVolumeFreeSizeForPath(diskCache->cacheDirectory().toLocal8Bit().constData()) / 1024 / 1023;
// The following variables are initialised to 0 because WebProcess::calculateCacheSizes might not
// set them in some rare cases.
@@ -114,7 +81,8 @@ void WebProcess::platformSetCacheModel(CacheModel cacheModel)
cacheTotalCapacity, cacheMinDeadCapacity, cacheMaxDeadCapacity, deadDecodedDataDeletionInterval,
pageCacheCapacity, urlCacheMemoryCapacity, urlCacheDiskCapacity);
- diskCache->setMaximumCacheSize(urlCacheDiskCapacity);
+ if (diskCache)
+ diskCache->setMaximumCacheSize(urlCacheDiskCapacity);
memoryCache()->setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity);
memoryCache()->setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval);
@@ -137,18 +105,28 @@ static void parentProcessDiedCallback(void*)
void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters& parameters, CoreIPC::MessageDecoder&)
{
+#if ENABLE(SECCOMP_FILTERS)
+ {
+ WebKit::SeccompFiltersWebProcessQt seccompFilters(parameters);
+ seccompFilters.initialize();
+ }
+#endif
+
m_networkAccessManager = new QtNetworkAccessManager(this);
- ASSERT(!parameters.cookieStorageDirectory.isEmpty() && !parameters.cookieStorageDirectory.isNull());
- WebCore::SharedCookieJarQt* jar = WebCore::SharedCookieJarQt::create(parameters.cookieStorageDirectory);
- m_networkAccessManager->setCookieJar(jar);
- // Do not let QNetworkAccessManager delete the jar.
- jar->setParent(0);
-
- ASSERT(!parameters.diskCacheDirectory.isEmpty() && !parameters.diskCacheDirectory.isNull());
- QNetworkDiskCache* diskCache = new QNetworkDiskCache();
- diskCache->setCacheDirectory(parameters.diskCacheDirectory);
- // The m_networkAccessManager takes ownership of the diskCache object upon the following call.
- m_networkAccessManager->setCache(diskCache);
+
+ if (!parameters.cookieStorageDirectory.isEmpty()) {
+ WebCore::SharedCookieJarQt* jar = WebCore::SharedCookieJarQt::create(parameters.cookieStorageDirectory);
+ m_networkAccessManager->setCookieJar(jar);
+ // Do not let QNetworkAccessManager delete the jar.
+ jar->setParent(0);
+ }
+
+ if (!parameters.diskCacheDirectory.isEmpty()) {
+ QNetworkDiskCache* diskCache = new QNetworkDiskCache();
+ diskCache->setCacheDirectory(parameters.diskCacheDirectory);
+ // The m_networkAccessManager takes ownership of the diskCache object upon the following call.
+ m_networkAccessManager->setCache(diskCache);
+ }
#if defined(Q_OS_MACX)
pid_t ppid = getppid();
@@ -160,9 +138,7 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters
}
#endif
-#if ENABLE(SPEECH_INPUT)
WebCore::RuntimeEnabledFeatures::setSpeechInputEnabled(false);
-#endif
// We'll only install the Qt builtin bundle if we don't have one given by the UI process.
// Currently only WTR provides its own bundle.