Commit 340e4960 authored by carlosgc@webkit.org's avatar carlosgc@webkit.org

[GTK] Add webkit_web_context_set_disk_cache_directory to WebKit2 GTK+ API

https://bugs.webkit.org/show_bug.cgi?id=111848

Reviewed by Anders Carlsson.

This allow applications to set a custom directory for the disk
cache.

* UIProcess/API/gtk/WebKitWebContext.cpp:
(webkit_web_context_set_disk_cache_directory):
* UIProcess/API/gtk/WebKitWebContext.h:
* UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbol.
* UIProcess/API/gtk/tests/TestMain.cpp:
(removeNonEmptyDirectory):
(main): Use a different temporary disk cache directory for every
test.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@148887 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e3e1391b
2013-04-22 Carlos Garcia Campos <cgarcia@igalia.com>
[GTK] Add webkit_web_context_set_disk_cache_directory to WebKit2 GTK+ API
https://bugs.webkit.org/show_bug.cgi?id=111848
Reviewed by Anders Carlsson.
This allow applications to set a custom directory for the disk
cache.
* UIProcess/API/gtk/WebKitWebContext.cpp:
(webkit_web_context_set_disk_cache_directory):
* UIProcess/API/gtk/WebKitWebContext.h:
* UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbol.
* UIProcess/API/gtk/tests/TestMain.cpp:
(removeNonEmptyDirectory):
(main): Use a different temporary disk cache directory for every
test.
2013-04-22 Carlos Garcia Campos <cgarcia@igalia.com>
[SOUP] Soup disk cache should respect the diskCacheDirectory from the process initial parameters
......@@ -772,6 +772,23 @@ void webkit_web_context_set_web_extensions_directory(WebKitWebContext* context,
context->priv->context->setInjectedBundleInitializationUserData(WebString::create(WebCore::filenameToString(directory)));
}
/**
* webkit_web_context_set_disk_cache_directory:
* @context: a #WebKitWebContext
* @directory: the directory to set
*
* Set the directory where disk cache files will be stored
* This method must be called before loading anything in this context, otherwise
* it will not have any effect.
*/
void webkit_web_context_set_disk_cache_directory(WebKitWebContext* context, const char* directory)
{
g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
g_return_if_fail(directory);
context->priv->context->setDiskCacheDirectory(WebCore::filenameToString(directory));
}
/**
* webkit_web_context_prefetch_dns:
* @context: a #WebKitWebContext
......
......@@ -192,6 +192,10 @@ WEBKIT_API void
webkit_web_context_prefetch_dns (WebKitWebContext *context,
const gchar *hostname);
WEBKIT_API void
webkit_web_context_set_disk_cache_directory (WebKitWebContext *context,
const gchar *directory);
G_END_DECLS
#endif
......@@ -47,6 +47,7 @@ webkit_web_context_set_tls_errors_policy
webkit_web_context_get_tls_errors_policy
webkit_web_context_set_web_extensions_directory
webkit_web_context_prefetch_dns
webkit_web_context_set_disk_cache_directory
<SUBSECTION URI Scheme>
WebKitURISchemeRequestCallback
......
......@@ -20,7 +20,10 @@
#include "config.h"
#include "TestMain.h"
#include <glib/gstdio.h>
#include <gtk/gtk.h>
#include <webkit2/webkit2.h>
#include <wtf/gobject/GOwnPtr.h>
void beforeAll();
void afterAll();
......@@ -35,6 +38,19 @@ static void registerGResource(void)
g_resource_unref(resource);
}
static void removeNonEmptyDirectory(const char* directoryPath)
{
GDir* directory = g_dir_open(directoryPath, 0, 0);
g_assert(directory);
const char* fileName;
while ((fileName = g_dir_read_name(directory))) {
GOwnPtr<char> filePath(g_build_filename(directoryPath, fileName, NULL));
g_unlink(filePath.get());
}
g_dir_close(directory);
g_rmdir(directoryPath);
}
int main(int argc, char** argv)
{
gtk_test_init(&argc, &argv, 0);
......@@ -45,9 +61,15 @@ int main(int argc, char** argv)
registerGResource();
GOwnPtr<char> diskCacheTempDirectory(g_dir_make_tmp("WebKit2TestsDiskCache-XXXXXX", 0));
g_assert(diskCacheTempDirectory.get());
webkit_web_context_set_disk_cache_directory(webkit_web_context_get_default(), diskCacheTempDirectory.get());
beforeAll();
int returnValue = g_test_run();
afterAll();
removeNonEmptyDirectory(diskCacheTempDirectory.get());
return returnValue;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment