[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
weinig at apple.com
weinig at apple.com
Wed Dec 22 14:06:21 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 47a1504f9eb40de66dbd57aa859cc934a6959dc1
Author: weinig at apple.com <weinig at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Oct 4 17:15:41 2010 +0000
Add ability to set the CacheModel in Webkit2
https://bugs.webkit.org/show_bug.cgi?id=47066
Reviewed by Anders Carlsson.
WebKit2:
Add WKContext function to set the cache model for the context.
* Shared/CacheModel.h: Added.
* Shared/CoreIPCSupport/WebProcessMessageKinds.h:
* UIProcess/API/C/WKAPICast.h:
(WebKit::toCacheModel):
(WebKit::toRef):
* UIProcess/API/C/WKContext.cpp:
(WKContextSetCacheModel):
(WKContextGetCacheModel):
* UIProcess/API/C/WKContext.h:
* UIProcess/WebContext.cpp:
(WebKit::WebContext::WebContext):
(WebKit::WebContext::ensureWebProcess):
(WebKit::WebContext::setCacheModel):
* UIProcess/WebContext.h:
(WebKit::WebContext::cacheModel):
* WebKit2.pro:
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::WebProcess):
(WebKit::WebProcess::setCacheModel):
(WebKit::WebProcess::didReceiveMessage):
* WebProcess/WebProcess.h:
* WebProcess/mac/WebProcessMac.mm: Added.
(WebKit::memorySize):
(WebKit::volumeFreeSize):
(WebKit::WebProcess::platformSetCacheModel):
* WebProcess/qt/WebProcessQt.cpp: Added.
(WebKit::WebProcess::platformSetCacheModel):
* WebProcess/win/WebProcessWin.cpp: Added.
(WebKit::WebProcess::platformSetCacheModel):
* win/WebKit2.vcproj:
WebKitTools:
* MiniBrowser/mac/AppDelegate.m:
(-[BrowserAppDelegate init]): Opt minibrowser into
a PrimaryWebBrowser cache model.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69020 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 5894b12..bd0966d 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,44 @@
+2010-10-04 Sam Weinig <sam at webkit.org>
+
+ Reviewed by Anders Carlsson.
+
+ Add ability to set the CacheModel in Webkit2
+ https://bugs.webkit.org/show_bug.cgi?id=47066
+
+ Add WKContext function to set the cache model for the context.
+
+ * Shared/CacheModel.h: Added.
+ * Shared/CoreIPCSupport/WebProcessMessageKinds.h:
+ * UIProcess/API/C/WKAPICast.h:
+ (WebKit::toCacheModel):
+ (WebKit::toRef):
+ * UIProcess/API/C/WKContext.cpp:
+ (WKContextSetCacheModel):
+ (WKContextGetCacheModel):
+ * UIProcess/API/C/WKContext.h:
+ * UIProcess/WebContext.cpp:
+ (WebKit::WebContext::WebContext):
+ (WebKit::WebContext::ensureWebProcess):
+ (WebKit::WebContext::setCacheModel):
+ * UIProcess/WebContext.h:
+ (WebKit::WebContext::cacheModel):
+ * WebKit2.pro:
+ * WebKit2.xcodeproj/project.pbxproj:
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::WebProcess):
+ (WebKit::WebProcess::setCacheModel):
+ (WebKit::WebProcess::didReceiveMessage):
+ * WebProcess/WebProcess.h:
+ * WebProcess/mac/WebProcessMac.mm: Added.
+ (WebKit::memorySize):
+ (WebKit::volumeFreeSize):
+ (WebKit::WebProcess::platformSetCacheModel):
+ * WebProcess/qt/WebProcessQt.cpp: Added.
+ (WebKit::WebProcess::platformSetCacheModel):
+ * WebProcess/win/WebProcessWin.cpp: Added.
+ (WebKit::WebProcess::platformSetCacheModel):
+ * win/WebKit2.vcproj:
+
2010-10-03 Anders Carlsson <andersca at apple.com>
Reviewed by Sam Weinig.
diff --git a/WebKit2/Shared/CacheModel.h b/WebKit2/Shared/CacheModel.h
new file mode 100644
index 0000000..91704c4
--- /dev/null
+++ b/WebKit2/Shared/CacheModel.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef CacheModel_h
+#define CacheModel_h
+
+namespace WebKit {
+
+enum CacheModel {
+ CacheModelDocumentViewer,
+ CacheModelDocumentBrowser,
+ CacheModelPrimaryWebBrowser
+};
+
+} // namespace WebKit
+
+#endif // CacheModel_h
diff --git a/WebKit2/Shared/CoreIPCSupport/WebProcessMessageKinds.h b/WebKit2/Shared/CoreIPCSupport/WebProcessMessageKinds.h
index d50ccfe..20dbd4e 100644
--- a/WebKit2/Shared/CoreIPCSupport/WebProcessMessageKinds.h
+++ b/WebKit2/Shared/CoreIPCSupport/WebProcessMessageKinds.h
@@ -40,6 +40,7 @@ enum Kind {
LoadInjectedBundle,
SetApplicationCacheDirectory,
SetShouldTrackVisitedLinks,
+ SetCacheModel,
Create,
RegisterURLSchemeAsEmptyDocument,
#if PLATFORM(MAC)
diff --git a/WebKit2/UIProcess/API/C/WKAPICast.h b/WebKit2/UIProcess/API/C/WKAPICast.h
index 1e40b8b..0dc3f4d 100644
--- a/WebKit2/UIProcess/API/C/WKAPICast.h
+++ b/WebKit2/UIProcess/API/C/WKAPICast.h
@@ -26,8 +26,10 @@
#ifndef WKAPICast_h
#define WKAPICast_h
-#include "WKSharedAPICast.h"
+#include "CacheModel.h"
+#include "WKContext.h"
#include "WKPage.h"
+#include "WKSharedAPICast.h"
#include <WebCore/FrameLoaderTypes.h>
namespace WebKit {
@@ -84,6 +86,35 @@ inline WKFrameNavigationType toRef(WebCore::NavigationType type)
return wkType;
}
+inline CacheModel toCacheModel(WKCacheModel wkCacheModel)
+{
+ switch (wkCacheModel) {
+ case kWKCacheModelDocumentViewer:
+ return CacheModelDocumentViewer;
+ case kWKCacheModelDocumentBrowser:
+ return CacheModelDocumentBrowser;
+ case kWKCacheModelPrimaryWebBrowser:
+ return CacheModelPrimaryWebBrowser;
+ }
+
+ ASSERT_NOT_REACHED();
+ return CacheModelDocumentViewer;
+}
+
+inline WKCacheModel toRef(CacheModel cacheModel)
+{
+ switch (cacheModel) {
+ case CacheModelDocumentViewer:
+ return kWKCacheModelDocumentViewer;
+ case CacheModelDocumentBrowser:
+ return kWKCacheModelDocumentBrowser;
+ case CacheModelPrimaryWebBrowser:
+ return kWKCacheModelPrimaryWebBrowser;
+ }
+
+ return kWKCacheModelDocumentViewer;
+}
+
} // namespace WebKit
#if defined(WIN32) || defined(_WIN32)
diff --git a/WebKit2/UIProcess/API/C/WKContext.cpp b/WebKit2/UIProcess/API/C/WKContext.cpp
index 3e24733..916cb38 100644
--- a/WebKit2/UIProcess/API/C/WKContext.cpp
+++ b/WebKit2/UIProcess/API/C/WKContext.cpp
@@ -101,6 +101,16 @@ void WKContextAddVisitedLink(WKContextRef contextRef, WKStringRef visitedURL)
toWK(contextRef)->addVisitedLink(toWK(visitedURL)->string());
}
+void WKContextSetCacheModel(WKContextRef contextRef, WKCacheModel cacheModel)
+{
+ toWK(contextRef)->setCacheModel(toCacheModel(cacheModel));
+}
+
+WKCacheModel WKContextGetCacheModel(WKContextRef contextRef)
+{
+ return toRef(toWK(contextRef)->cacheModel());
+}
+
void _WKContextSetAdditionalPluginsDirectory(WKContextRef contextRef, WKStringRef pluginsDirectory)
{
toWK(contextRef)->setAdditionalPluginsDirectory(toWK(pluginsDirectory)->string());
diff --git a/WebKit2/UIProcess/API/C/WKContext.h b/WebKit2/UIProcess/API/C/WKContext.h
index cfe8253..2c22fb0 100644
--- a/WebKit2/UIProcess/API/C/WKContext.h
+++ b/WebKit2/UIProcess/API/C/WKContext.h
@@ -32,6 +32,13 @@
extern "C" {
#endif
+enum {
+ kWKCacheModelDocumentViewer = 0,
+ kWKCacheModelDocumentBrowser = 1,
+ kWKCacheModelPrimaryWebBrowser = 2
+};
+typedef uint32_t WKCacheModel;
+
// Injected Bundle Client
typedef void (*WKContextDidReceiveMessageFromInjectedBundleCallback)(WKContextRef page, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo);
typedef void (*WKContextDidReceiveSynchronousMessageFromInjectedBundleCallback)(WKContextRef page, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData, const void *clientInfo);
@@ -78,6 +85,9 @@ WK_EXPORT void WKContextPostMessageToInjectedBundle(WKContextRef context, WKStri
WK_EXPORT void WKContextAddVisitedLink(WKContextRef context, WKStringRef visitedURL);
+WK_EXPORT void WKContextSetCacheModel(WKContextRef context, WKCacheModel cacheModel);
+WK_EXPORT WKCacheModel WKContextGetCacheModel(WKContextRef context);
+
#ifdef __cplusplus
}
#endif
diff --git a/WebKit2/UIProcess/WebContext.cpp b/WebKit2/UIProcess/WebContext.cpp
index 280e091..137facd 100644
--- a/WebKit2/UIProcess/WebContext.cpp
+++ b/WebKit2/UIProcess/WebContext.cpp
@@ -79,6 +79,7 @@ WebContext::WebContext(ProcessModel processModel, const String& injectedBundlePa
: m_processModel(processModel)
, m_injectedBundlePath(injectedBundlePath)
, m_visitedLinkProvider(this)
+ , m_cacheModel(CacheModelDocumentViewer)
#if PLATFORM(WIN)
, m_shouldPaintNativeControls(true)
#endif
@@ -126,6 +127,7 @@ void WebContext::ensureWebProcess()
m_process = WebProcessManager::shared().getWebProcess(this);
m_process->send(WebProcessMessage::SetShouldTrackVisitedLinks, 0, CoreIPC::In(m_historyClient.shouldTrackVisitedLinks()));
+ m_process->send(WebProcessMessage::SetCacheModel, 0, CoreIPC::In(static_cast<uint32_t>(m_cacheModel)));
for (HashSet<String>::iterator it = m_schemesToRegisterAsEmptyDocument.begin(), end = m_schemesToRegisterAsEmptyDocument.end(); it != end; ++it)
m_process->send(WebProcessMessage::RegisterURLSchemeAsEmptyDocument, 0, CoreIPC::In(*it));
@@ -297,7 +299,16 @@ void WebContext::addVisitedLink(LinkHash linkHash)
{
m_visitedLinkProvider.addVisitedLink(linkHash);
}
-
+
+void WebContext::setCacheModel(CacheModel cacheModel)
+{
+ m_cacheModel = cacheModel;
+
+ if (!hasValidProcess())
+ return;
+ m_process->send(WebProcessMessage::SetCacheModel, 0, CoreIPC::In(static_cast<uint32_t>(m_cacheModel)));
+}
+
void WebContext::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
{
switch (messageID.get<WebContextMessage::Kind>()) {
diff --git a/WebKit2/UIProcess/WebContext.h b/WebKit2/UIProcess/WebContext.h
index 2aef3d4..046f1ec 100644
--- a/WebKit2/UIProcess/WebContext.h
+++ b/WebKit2/UIProcess/WebContext.h
@@ -108,6 +108,9 @@ public:
void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*);
+ void setCacheModel(CacheModel);
+ CacheModel cacheModel() const { return m_cacheModel; }
+
#if PLATFORM(WIN)
void setShouldPaintNativeControls(bool);
#endif
@@ -140,6 +143,8 @@ private:
HashSet<String> m_schemesToRegisterAsEmptyDocument;
Vector<pair<String, RefPtr<APIObject> > > m_pendingMessagesToPostToInjectedBundle;
+ CacheModel m_cacheModel;
+
#if PLATFORM(WIN)
bool m_shouldPaintNativeControls;
#endif
diff --git a/WebKit2/WebKit2.pro b/WebKit2/WebKit2.pro
index 8c718f6..611ccfc 100644
--- a/WebKit2/WebKit2.pro
+++ b/WebKit2/WebKit2.pro
@@ -176,6 +176,7 @@ HEADERS += \
Shared/CoreIPCSupport/DrawingAreaProxyMessageKinds.h \
Shared/CoreIPCSupport/WebPageProxyMessageKinds.h \
Shared/CoreIPCSupport/WebProcessMessageKinds.h \
+ Shared/CacheModel.h \
Shared/DrawingAreaBase.h \
Shared/ImmutableArray.h \
Shared/ImmutableDictionary.h \
@@ -417,4 +418,5 @@ SOURCES += \
UIProcess/qt/ChunkedUpdateDrawingAreaProxyQt.cpp \
UIProcess/qt/WebContextQt.cpp \
WebProcess/qt/WebProcessMainQt.cpp \
+ WebProcess/qt/WebProcessQt.cpp \
$$WEBKIT2_GENERATED_SOURCES
diff --git a/WebKit2/WebKit2.xcodeproj/project.pbxproj b/WebKit2/WebKit2.xcodeproj/project.pbxproj
index 6be3b18..7499e34 100644
--- a/WebKit2/WebKit2.xcodeproj/project.pbxproj
+++ b/WebKit2/WebKit2.xcodeproj/project.pbxproj
@@ -223,6 +223,8 @@
BC2E6E8C1141971500A63B1E /* WorkItem.h in Headers */ = {isa = PBXBuildFile; fileRef = BC2E6E7C1141970C00A63B1E /* WorkItem.h */; };
BC2E6E8D1141971500A63B1E /* WorkQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC2E6E7D1141970C00A63B1E /* WorkQueue.cpp */; };
BC2E6E8E1141971500A63B1E /* WorkQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = BC2E6E7E1141970C00A63B1E /* WorkQueue.h */; };
+ BC3065C412592F8900E71278 /* WebProcessMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC3065C312592F8900E71278 /* WebProcessMac.mm */; };
+ BC3065FA1259344E00E71278 /* CacheModel.h in Headers */ = {isa = PBXBuildFile; fileRef = BC3065F91259344E00E71278 /* CacheModel.h */; };
BC33DD681238464600360F3F /* WebNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = BC33DD671238464600360F3F /* WebNumber.h */; };
BC33E0D112408E8600360F3F /* InjectedBundleRangeHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = BC33E0CF12408E8600360F3F /* InjectedBundleRangeHandle.h */; };
BC33E0D212408E8600360F3F /* InjectedBundleRangeHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC33E0D012408E8600360F3F /* InjectedBundleRangeHandle.cpp */; };
@@ -670,6 +672,8 @@
BC2E6E7C1141970C00A63B1E /* WorkItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkItem.h; sourceTree = "<group>"; };
BC2E6E7D1141970C00A63B1E /* WorkQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueue.cpp; sourceTree = "<group>"; };
BC2E6E7E1141970C00A63B1E /* WorkQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkQueue.h; sourceTree = "<group>"; };
+ BC3065C312592F8900E71278 /* WebProcessMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessMac.mm; sourceTree = "<group>"; };
+ BC3065F91259344E00E71278 /* CacheModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheModel.h; sourceTree = "<group>"; };
BC33DD671238464600360F3F /* WebNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNumber.h; sourceTree = "<group>"; };
BC33E0CF12408E8600360F3F /* InjectedBundleRangeHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundleRangeHandle.h; sourceTree = "<group>"; };
BC33E0D012408E8600360F3F /* InjectedBundleRangeHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleRangeHandle.cpp; sourceTree = "<group>"; };
@@ -1019,6 +1023,7 @@
isa = PBXGroup;
children = (
1A6FA01D11E1526300DB1371 /* WebProcessMainMac.mm */,
+ BC3065C312592F8900E71278 /* WebProcessMac.mm */,
);
path = mac;
sourceTree = "<group>";
@@ -1102,6 +1107,7 @@
1A6F9F8E11E13EFC00DB1371 /* CommandLine.h */,
0FB659221208B4DB0044816C /* DrawingAreaBase.h */,
762B7481120BBA0100819339 /* FontSmoothingLevel.h */,
+ BC3065F91259344E00E71278 /* CacheModel.h */,
BC64696D11DBE603006455B0 /* ImmutableArray.cpp */,
BC64696E11DBE603006455B0 /* ImmutableArray.h */,
BCBCB0CC1215E33A00DE59CA /* ImmutableDictionary.cpp */,
@@ -1918,6 +1924,7 @@
1A8EFA711252B84100F7067F /* PluginProxyMessages.h in Headers */,
1A8EFDFA1253CAA200F7067F /* DataReference.h in Headers */,
BC9099801256A98200083756 /* WKStringPrivate.h in Headers */,
+ BC3065FA1259344E00E71278 /* CacheModel.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2212,6 +2219,7 @@
1A8EF96E1252AF6B00F7067F /* PluginControllerProxyMessageReceiver.cpp in Sources */,
1A8EFA701252B84100F7067F /* PluginProxyMessageReceiver.cpp in Sources */,
1A8EFDFE1253CB6E00F7067F /* DataReference.cpp in Sources */,
+ BC3065C412592F8900E71278 /* WebProcessMac.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/WebKit2/WebProcess/WebProcess.cpp b/WebKit2/WebProcess/WebProcess.cpp
index 157dd17..7545dc3 100644
--- a/WebKit2/WebProcess/WebProcess.cpp
+++ b/WebKit2/WebProcess/WebProcess.cpp
@@ -91,6 +91,8 @@ WebProcess& WebProcess::shared()
WebProcess::WebProcess()
: m_inDidClose(false)
+ , m_hasSetCacheModel(false)
+ , m_cacheModel(CacheModelDocumentViewer)
#if USE(ACCELERATED_COMPOSITING) && PLATFORM(MAC)
, m_compositingRenderServerPort(MACH_PORT_NULL)
#endif
@@ -181,6 +183,15 @@ void WebProcess::addVisitedLink(WebCore::LinkHash linkHash)
m_connection->send(WebProcessProxyMessage::AddVisitedLink, 0, CoreIPC::In(linkHash));
}
+void WebProcess::setCacheModel(CacheModel cacheModel)
+{
+ if (!m_hasSetCacheModel || cacheModel != m_cacheModel) {
+ m_hasSetCacheModel = true;
+ m_cacheModel = cacheModel;
+ platformSetCacheModel(cacheModel);
+ }
+}
+
WebPage* WebProcess::webPage(uint64_t pageID) const
{
return m_pageMap.get(pageID).get();
@@ -250,6 +261,7 @@ void WebProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::Mes
if (!arguments->decode(CoreIPC::Out(linkHashes)))
return;
visitedLinkStateChanged(linkHashes);
+ return;
}
case WebProcessMessage::AllVisitedLinkStateChanged:
allVisitedLinkStateChanged();
@@ -289,7 +301,14 @@ void WebProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::Mes
PageGroup::setShouldTrackVisitedLinks(shouldTrackVisitedLinks);
return;
}
-
+ case WebProcessMessage::SetCacheModel: {
+ uint32_t cacheModel;
+ if (!arguments->decode(CoreIPC::Out(cacheModel)))
+ return;
+
+ setCacheModel(static_cast<CacheModel>(cacheModel));
+ return;
+ }
case WebProcessMessage::Create: {
uint64_t pageID = arguments->destinationID();
WebPageCreationParameters parameters;
diff --git a/WebKit2/WebProcess/WebProcess.h b/WebKit2/WebProcess/WebProcess.h
index 5cf286c..8364f8e 100644
--- a/WebKit2/WebProcess/WebProcess.h
+++ b/WebKit2/WebProcess/WebProcess.h
@@ -26,6 +26,7 @@
#ifndef WebProcess_h
#define WebProcess_h
+#include "CacheModel.h"
#include "Connection.h"
#include "DrawingArea.h"
#include "SharedMemory.h"
@@ -92,7 +93,10 @@ private:
void setVisitedLinkTable(const SharedMemory::Handle&);
void visitedLinkStateChanged(const Vector<WebCore::LinkHash>& linkHashes);
void allVisitedLinkStateChanged();
-
+
+ void setCacheModel(CacheModel cacheModel);
+ void platformSetCacheModel(CacheModel);
+
// CoreIPC::Connection::Client
void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
void didClose(CoreIPC::Connection*);
@@ -109,6 +113,9 @@ private:
// FIXME: The visited link table should not be per process.
VisitedLinkTable m_visitedLinkTable;
+ bool m_hasSetCacheModel;
+ CacheModel m_cacheModel;
+
#if USE(ACCELERATED_COMPOSITING) && PLATFORM(MAC)
mach_port_t m_compositingRenderServerPort;
#endif
diff --git a/WebKit2/WebProcess/mac/WebProcessMac.mm b/WebKit2/WebProcess/mac/WebProcessMac.mm
new file mode 100644
index 0000000..a7aa867
--- /dev/null
+++ b/WebKit2/WebProcess/mac/WebProcessMac.mm
@@ -0,0 +1,233 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "WebProcess.h"
+
+#include <WebCore/Cache.h>
+#include <WebCore/PageCache.h>
+#include <WebKitSystemInterface.h>
+#include <algorithm>
+
+using namespace WebCore;
+using namespace std;
+
+namespace WebKit {
+
+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 unsigned long long volumeFreeSize(NSString *path)
+{
+ NSDictionary *fileSystemAttributesDictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:path error:NULL];
+ return [[fileSystemAttributesDictionary objectForKey:NSFileSystemFreeSize] unsignedLongLongValue];
+}
+
+void WebProcess::platformSetCacheModel(CacheModel cacheModel)
+{
+ RetainPtr<NSString> nsurlCacheDirectory(AdoptNS, (NSString *)WKCopyFoundationCacheDirectory());
+ if (!nsurlCacheDirectory)
+ nsurlCacheDirectory.adoptNS(NSHomeDirectory());
+
+ // 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;
+ unsigned long long diskFreeSize = volumeFreeSize(nsurlCacheDirectory.get()) / 1024 / 1000;
+ NSURLCache *nsurlCache = [NSURLCache sharedURLCache];
+
+ unsigned cacheTotalCapacity = 0;
+ unsigned cacheMinDeadCapacity = 0;
+ unsigned cacheMaxDeadCapacity = 0;
+ double deadDecodedDataDeletionInterval = 0;
+
+ unsigned pageCacheCapacity = 0;
+
+ NSUInteger nsurlCacheMemoryCapacity = 0;
+ NSUInteger nsurlCacheDiskCapacity = 0;
+
+ switch (cacheModel) {
+ case CacheModelDocumentViewer: {
+ // Page cache capacity (in pages)
+ pageCacheCapacity = 0;
+
+ // Object cache capacities (in bytes)
+ if (memSize >= 2048)
+ cacheTotalCapacity = 96 * 1024 * 1024;
+ else if (memSize >= 1536)
+ cacheTotalCapacity = 64 * 1024 * 1024;
+ else if (memSize >= 1024)
+ cacheTotalCapacity = 32 * 1024 * 1024;
+ else if (memSize >= 512)
+ cacheTotalCapacity = 16 * 1024 * 1024;
+
+ cacheMinDeadCapacity = 0;
+ cacheMaxDeadCapacity = 0;
+
+ // Foundation memory cache capacity (in bytes)
+ nsurlCacheMemoryCapacity = 0;
+
+ // Foundation disk cache capacity (in bytes)
+ nsurlCacheDiskCapacity = [nsurlCache diskCapacity];
+
+ break;
+ }
+ case CacheModelDocumentBrowser: {
+ // Page cache capacity (in pages)
+ if (memSize >= 1024)
+ pageCacheCapacity = 3;
+ else if (memSize >= 512)
+ pageCacheCapacity = 2;
+ else if (memSize >= 256)
+ pageCacheCapacity = 1;
+ else
+ pageCacheCapacity = 0;
+
+ // Object cache capacities (in bytes)
+ if (memSize >= 2048)
+ cacheTotalCapacity = 96 * 1024 * 1024;
+ else if (memSize >= 1536)
+ cacheTotalCapacity = 64 * 1024 * 1024;
+ else if (memSize >= 1024)
+ cacheTotalCapacity = 32 * 1024 * 1024;
+ else if (memSize >= 512)
+ cacheTotalCapacity = 16 * 1024 * 1024;
+
+ cacheMinDeadCapacity = cacheTotalCapacity / 8;
+ cacheMaxDeadCapacity = cacheTotalCapacity / 4;
+
+ // Foundation memory cache capacity (in bytes)
+ if (memSize >= 2048)
+ nsurlCacheMemoryCapacity = 4 * 1024 * 1024;
+ else if (memSize >= 1024)
+ nsurlCacheMemoryCapacity = 2 * 1024 * 1024;
+ else if (memSize >= 512)
+ nsurlCacheMemoryCapacity = 1 * 1024 * 1024;
+ else
+ nsurlCacheMemoryCapacity = 512 * 1024;
+
+ // Foundation disk cache capacity (in bytes)
+ if (diskFreeSize >= 16384)
+ nsurlCacheDiskCapacity = 50 * 1024 * 1024;
+ else if (diskFreeSize >= 8192)
+ nsurlCacheDiskCapacity = 40 * 1024 * 1024;
+ else if (diskFreeSize >= 4096)
+ nsurlCacheDiskCapacity = 30 * 1024 * 1024;
+ else
+ nsurlCacheDiskCapacity = 20 * 1024 * 1024;
+
+ break;
+ }
+ case CacheModelPrimaryWebBrowser: {
+ // Page cache capacity (in pages)
+ // (Research indicates that value / page drops substantially after 3 pages.)
+ if (memSize >= 2048)
+ pageCacheCapacity = 5;
+ else if (memSize >= 1024)
+ pageCacheCapacity = 4;
+ else if (memSize >= 512)
+ pageCacheCapacity = 3;
+ else if (memSize >= 256)
+ pageCacheCapacity = 2;
+ else
+ pageCacheCapacity = 1;
+
+ // Object cache capacities (in bytes)
+ // (Testing indicates that value / MB depends heavily on content and
+ // browsing pattern. Even growth above 128MB can have substantial
+ // value / MB for some content / browsing patterns.)
+ if (memSize >= 2048)
+ cacheTotalCapacity = 128 * 1024 * 1024;
+ else if (memSize >= 1536)
+ cacheTotalCapacity = 96 * 1024 * 1024;
+ else if (memSize >= 1024)
+ cacheTotalCapacity = 64 * 1024 * 1024;
+ else if (memSize >= 512)
+ cacheTotalCapacity = 32 * 1024 * 1024;
+
+ cacheMinDeadCapacity = cacheTotalCapacity / 4;
+ cacheMaxDeadCapacity = cacheTotalCapacity / 2;
+
+ // This code is here to avoid a PLT regression. We can remove it if we
+ // can prove that the overall system gain would justify the regression.
+ cacheMaxDeadCapacity = max(24u, cacheMaxDeadCapacity);
+
+ deadDecodedDataDeletionInterval = 60;
+
+ // Foundation memory cache capacity (in bytes)
+ // (These values are small because WebCore does most caching itself.)
+ if (memSize >= 1024)
+ nsurlCacheMemoryCapacity = 4 * 1024 * 1024;
+ else if (memSize >= 512)
+ nsurlCacheMemoryCapacity = 2 * 1024 * 1024;
+ else if (memSize >= 256)
+ nsurlCacheMemoryCapacity = 1 * 1024 * 1024;
+ else
+ nsurlCacheMemoryCapacity = 512 * 1024;
+
+ // Foundation disk cache capacity (in bytes)
+ if (diskFreeSize >= 16384)
+ nsurlCacheDiskCapacity = 175 * 1024 * 1024;
+ else if (diskFreeSize >= 8192)
+ nsurlCacheDiskCapacity = 150 * 1024 * 1024;
+ else if (diskFreeSize >= 4096)
+ nsurlCacheDiskCapacity = 125 * 1024 * 1024;
+ else if (diskFreeSize >= 2048)
+ nsurlCacheDiskCapacity = 100 * 1024 * 1024;
+ else if (diskFreeSize >= 1024)
+ nsurlCacheDiskCapacity = 75 * 1024 * 1024;
+ else
+ nsurlCacheDiskCapacity = 50 * 1024 * 1024;
+
+ break;
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ };
+
+ // Don't shrink a big disk cache, since that would cause churn.
+ nsurlCacheDiskCapacity = max(nsurlCacheDiskCapacity, [nsurlCache diskCapacity]);
+
+ cache()->setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity);
+ cache()->setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval);
+ pageCache()->setCapacity(pageCacheCapacity);
+ [nsurlCache setMemoryCapacity:nsurlCacheMemoryCapacity];
+ [nsurlCache setDiskCapacity:nsurlCacheDiskCapacity];
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/qt/WebProcessQt.cpp b/WebKit2/WebProcess/qt/WebProcessQt.cpp
new file mode 100644
index 0000000..faec27b
--- /dev/null
+++ b/WebKit2/WebProcess/qt/WebProcessQt.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "WebProcess.h"
+
+namespace WebKit {
+
+void WebProcess::platformSetCacheModel(CacheModel cacheModel)
+{
+ // FIXME: Implement.
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/win/WebProcessWin.cpp b/WebKit2/WebProcess/win/WebProcessWin.cpp
new file mode 100644
index 0000000..faec27b
--- /dev/null
+++ b/WebKit2/WebProcess/win/WebProcessWin.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "WebProcess.h"
+
+namespace WebKit {
+
+void WebProcess::platformSetCacheModel(CacheModel cacheModel)
+{
+ // FIXME: Implement.
+}
+
+} // namespace WebKit
diff --git a/WebKit2/win/WebKit2.vcproj b/WebKit2/win/WebKit2.vcproj
index d1278d5..761fbf9 100755
--- a/WebKit2/win/WebKit2.vcproj
+++ b/WebKit2/win/WebKit2.vcproj
@@ -397,6 +397,10 @@
>
</File>
<File
+ RelativePath="..\Shared\CacheModel.h"
+ >
+ </File>
+ <File
RelativePath="..\Shared\DrawingAreaBase.h"
>
</File>
@@ -1039,6 +1043,10 @@
RelativePath="..\WebProcess\win\WebProcessMainWin.cpp"
>
</File>
+ <File
+ RelativePath="..\WebProcess\win\WebProcessWin.cpp"
+ >
+ </File>
</Filter>
<Filter
Name="InjectedBundle"
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index cce8962..006ed50 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,14 @@
+2010-10-04 Sam Weinig <sam at webkit.org>
+
+ Reviewed by Anders Carlsson.
+
+ Add ability to set the CacheModel in Webkit2
+ https://bugs.webkit.org/show_bug.cgi?id=47066
+
+ * MiniBrowser/mac/AppDelegate.m:
+ (-[BrowserAppDelegate init]): Opt minibrowser into
+ a PrimaryWebBrowser cache model.
+
2010-10-03 Simon Fraser <simon.fraser at apple.com>
Make sure to enter all tests when creating the database
diff --git a/WebKitTools/MiniBrowser/mac/AppDelegate.m b/WebKitTools/MiniBrowser/mac/AppDelegate.m
index 7098cea..3747e28 100644
--- a/WebKitTools/MiniBrowser/mac/AppDelegate.m
+++ b/WebKitTools/MiniBrowser/mac/AppDelegate.m
@@ -118,7 +118,6 @@ static void populateVisitedLinks(WKContextRef context, const void *clientInfo)
else
currentProcessModel = kProcessModelSharedSecondaryProcess;
- WKContextRef threadContext = WKContextGetSharedThreadContext();
WKContextHistoryClient historyClient = {
0,
self,
@@ -128,8 +127,11 @@ static void populateVisitedLinks(WKContextRef context, const void *clientInfo)
didUpdateHistoryTitle,
populateVisitedLinks
};
+
+ WKContextRef threadContext = WKContextGetSharedThreadContext();
WKContextSetHistoryClient(threadContext, &historyClient);
-
+ WKContextSetCacheModel(threadContext, kWKCacheModelPrimaryWebBrowser);
+
threadPageNamespace = WKPageNamespaceCreate(threadContext);
WKRelease(threadContext);
@@ -146,7 +148,8 @@ static void populateVisitedLinks(WKContextRef context, const void *clientInfo)
};
WKContextSetInjectedBundleClient(processContext, &bundleClient);
WKContextSetHistoryClient(processContext, &historyClient);
-
+ WKContextSetCacheModel(processContext, kWKCacheModelPrimaryWebBrowser);
+
processPageNamespace = WKPageNamespaceCreate(processContext);
WKRelease(processContext);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list