Changeset 148887 in webkit


Ignore:
Timestamp:
Apr 22, 2013 9:03:21 AM (11 years ago)
Author:
Carlos Garcia Campos
Message:

[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.

Location:
trunk/Source/WebKit2
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r148886 r148887  
     12013-04-22  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Add webkit_web_context_set_disk_cache_directory to WebKit2 GTK+ API
     4        https://bugs.webkit.org/show_bug.cgi?id=111848
     5
     6        Reviewed by Anders Carlsson.
     7
     8        This allow applications to set a custom directory for the disk
     9        cache.
     10
     11        * UIProcess/API/gtk/WebKitWebContext.cpp:
     12        (webkit_web_context_set_disk_cache_directory):
     13        * UIProcess/API/gtk/WebKitWebContext.h:
     14        * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbol.
     15        * UIProcess/API/gtk/tests/TestMain.cpp:
     16        (removeNonEmptyDirectory):
     17        (main): Use a different temporary disk cache directory for every
     18        test.
     19
    1202013-04-22  Carlos Garcia Campos  <cgarcia@igalia.com>
    221
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp

    r145951 r148887  
    774774
    775775/**
     776 * webkit_web_context_set_disk_cache_directory:
     777 * @context: a #WebKitWebContext
     778 * @directory: the directory to set
     779 *
     780 * Set the directory where disk cache files will be stored
     781 * This method must be called before loading anything in this context, otherwise
     782 * it will not have any effect.
     783 */
     784void webkit_web_context_set_disk_cache_directory(WebKitWebContext* context, const char* directory)
     785{
     786    g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
     787    g_return_if_fail(directory);
     788
     789    context->priv->context->setDiskCacheDirectory(WebCore::filenameToString(directory));
     790}
     791
     792/**
    776793 * webkit_web_context_prefetch_dns:
    777794 * @context: a #WebKitWebContext
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h

    r141102 r148887  
    193193                                                     const gchar                   *hostname);
    194194
     195WEBKIT_API void
     196webkit_web_context_set_disk_cache_directory         (WebKitWebContext              *context,
     197                                                     const gchar                   *directory);
     198
    195199G_END_DECLS
    196200
  • trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt

    r148679 r148887  
    4848webkit_web_context_set_web_extensions_directory
    4949webkit_web_context_prefetch_dns
     50webkit_web_context_set_disk_cache_directory
    5051
    5152<SUBSECTION URI Scheme>
  • trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp

    r145508 r148887  
    2121#include "TestMain.h"
    2222
     23#include <glib/gstdio.h>
    2324#include <gtk/gtk.h>
     25#include <webkit2/webkit2.h>
     26#include <wtf/gobject/GOwnPtr.h>
    2427
    2528void beforeAll();
     
    3639}
    3740
     41static void removeNonEmptyDirectory(const char* directoryPath)
     42{
     43    GDir* directory = g_dir_open(directoryPath, 0, 0);
     44    g_assert(directory);
     45    const char* fileName;
     46    while ((fileName = g_dir_read_name(directory))) {
     47        GOwnPtr<char> filePath(g_build_filename(directoryPath, fileName, NULL));
     48        g_unlink(filePath.get());
     49    }
     50    g_dir_close(directory);
     51    g_rmdir(directoryPath);
     52}
     53
    3854int main(int argc, char** argv)
    3955{
     
    4662    registerGResource();
    4763
     64    GOwnPtr<char> diskCacheTempDirectory(g_dir_make_tmp("WebKit2TestsDiskCache-XXXXXX", 0));
     65    g_assert(diskCacheTempDirectory.get());
     66    webkit_web_context_set_disk_cache_directory(webkit_web_context_get_default(), diskCacheTempDirectory.get());
     67
    4868    beforeAll();
    4969    int returnValue = g_test_run();
    5070    afterAll();
    5171
     72    removeNonEmptyDirectory(diskCacheTempDirectory.get());
     73
    5274    return returnValue;
    5375}
Note: See TracChangeset for help on using the changeset viewer.