summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2014-02-09 14:36:34 +0000
committerVincent Sanders <vince@netsurf-browser.org>2014-02-09 14:36:34 +0000
commitbd5499c9a5a2de91bf606cd62927c3f9bb7f258b (patch)
tree5cbe4a127a42ac50f919e6b961611b0e522d9887
parentb351e3146b8a2700e0ca511d7c75a02ab9189912 (diff)
downloadnetsurf-vince/disccache.tar.gz
use llcache operation table and move stub to gtkvince/disccache
-rw-r--r--content/llcache.c20
-rw-r--r--gtk/Makefile.target2
-rw-r--r--gtk/gui.c2
-rw-r--r--gtk/llcache.c43
-rw-r--r--gtk/llcache.h24
5 files changed, 77 insertions, 14 deletions
diff --git a/content/llcache.c b/content/llcache.c
index 3fbe5ec0b..f658380ab 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -23,17 +23,19 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
-
#include <curl/curl.h>
-#include "content/fetch.h"
-#include "content/llcache.h"
-#include "content/urldb.h"
#include "utils/corestrings.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/nsurl.h"
#include "utils/utils.h"
+#include "utils/schedule.h"
+#include "desktop/gui_factory.h"
+
+#include "content/fetch.h"
+#include "content/llcache.h"
+#include "content/urldb.h"
/** Define to enable tracing of llcache operations. */
#undef LLCACHE_TRACE
@@ -1638,14 +1640,6 @@ static nserror llcache_fetch_ssl_error(llcache_object *object)
#define LLCACHE_MIN_DISC_LIFETIME 3600
#define LLCACHE_MAX_DISC_BANDWIDTH (512*1024)
-static nserror write_llcache_file(nsurl *url,
- int remaining,
- const uint8_t *data,
- size_t datalen)
-{
- LOG(("Writing cache file for url:%s", nsurl_access(url)));
- return NSERROR_OK;
-}
/**
* possibly push objects to disc cache.
@@ -1672,7 +1666,7 @@ static void llcache_discwrite(void *p)
(object->store_state == LLCACHE_STORE_RAM) &&
(remaining_lifetime > LLCACHE_MIN_DISC_LIFETIME)) {
/* ok found an object to write */
- ret = write_llcache_file(object->url,
+ ret = guit->llcache->persist(object->url,
remaining_lifetime,
object->source_data,
object->source_len);
diff --git a/gtk/Makefile.target b/gtk/Makefile.target
index ec19d1b36..df9ac73d5 100644
--- a/gtk/Makefile.target
+++ b/gtk/Makefile.target
@@ -110,7 +110,7 @@ S_GTK := font_pango.c bitmap.c gui.c schedule.c thumbnail.c plotters.c \
treeview.c scaffolding.c gdk.c completion.c login.c throbber.c \
selection.c history.c window.c fetch.c download.c menu.c \
print.c search.c tabs.c theme.c toolbar.c gettext.c \
- compat.c cookies.c hotlist.c \
+ compat.c cookies.c hotlist.c llcache.c \
$(addprefix dialogs/,preferences.c about.c source.c)
S_GTK := $(addprefix gtk/,$(S_GTK)) $(addprefix utils/,container.c)
diff --git a/gtk/gui.c b/gtk/gui.c
index 74da73321..1ebef6d7b 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -69,6 +69,7 @@
#include "gtk/window.h"
#include "gtk/schedule.h"
#include "gtk/selection.h"
+#include "gtk/llcache.h"
#include "render/form.h"
#include "utils/filepath.h"
@@ -1015,6 +1016,7 @@ int main(int argc, char** argv)
.clipboard = nsgtk_clipboard_table,
.download = nsgtk_download_table,
.fetch = nsgtk_fetch_table,
+ .llcache = nsgtk_llcache_table,
};
/* check home directory is available */
diff --git a/gtk/llcache.c b/gtk/llcache.c
new file mode 100644
index 000000000..56d6d12ab
--- /dev/null
+++ b/gtk/llcache.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2014 Vincent Sanders <vince@netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "utils/nsurl.h"
+#include "utils/log.h"
+#include "desktop/gui.h"
+
+#include "gtk/llcache.h"
+
+static nserror
+persist(nsurl *url, int remaining, const uint8_t *data, size_t datalen)
+{
+ LOG(("Writing cache file for url:%s", nsurl_access(url)));
+ return NSERROR_OK;
+}
+
+static nserror
+retrieve(nsurl *url, int *remaining_out, const uint8_t **data_out, size_t *datalen_out)
+{
+ return NSERROR_NOT_FOUND;
+}
+
+static struct gui_llcache_table llcache_table = {
+ .persist = persist,
+ .retrieve = retrieve,
+};
+
+struct gui_llcache_table *nsgtk_llcache_table = &llcache_table;
diff --git a/gtk/llcache.h b/gtk/llcache.h
new file mode 100644
index 000000000..6afdfe94a
--- /dev/null
+++ b/gtk/llcache.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2014 Vincent Sanders <vince@netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GTK_LLCACHE_H
+#define GTK_LLCACHE_H
+
+extern struct gui_llcache_table* nsgtk_llcache_table;
+
+#endif