2 * Copyright (C) 2009 Jan Michael Alonzo <jmalonzo@gmail.com>
3 * Copyright (C) 2011 Lukasz Slachciak
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
22 #include "webkitapplicationcache.h"
24 #include "ApplicationCacheStorage.h"
25 #include "FileSystem.h"
26 #include <wtf/UnusedParam.h>
27 #include <wtf/text/CString.h>
29 // web application cache maximum storage size
30 static unsigned long long cacheMaxSize = UINT_MAX;
33 * webkit_application_cache_get_maximum_size:
35 * Returns the maximum size of the cache storage.
36 * By default it is set to UINT_MAX i.e. no quota.
38 * Returns: the current application cache maximum storage size
42 unsigned long long webkit_application_cache_get_maximum_size()
44 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
45 return (cacheMaxSize = WebCore::cacheStorage().maximumSize());
52 * webkit_application_cache_set_maximum_size:
53 * @size: the new web application cache maximum storage size
55 * Sets new application cache maximum storage size.
56 * Changing the application cache storage size will clear the cache
57 * and rebuild cache storage.
61 void webkit_application_cache_set_maximum_size(unsigned long long size)
63 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
64 if (size != cacheMaxSize) {
65 WebCore::cacheStorage().empty();
66 WebCore::cacheStorage().vacuumDatabaseFile();
67 WebCore::cacheStorage().setMaximumSize(size);
76 * webkit_spplication_cache_get_database_directory_path:
78 * Returns the current path to the directory WebKit will write web application
79 * cache databases. By default this path is set to $XDG_DATA_HOME/webkit/databases
80 * with webkit_application_cache_set_database_directory_path
82 * Returns: the current application cache database directory path
86 const gchar* webkit_application_cache_get_database_directory_path()
88 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
89 CString path = WebCore::fileSystemRepresentation(WebCore::cacheStorage().cacheDirectory());