NetSurf
backing_store.h
Go to the documentation of this file.
1/*
2 * Copyright 2014 Vincent Sanders <vince@netsurf-browser.org>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf 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
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/**
20 * \file
21 * Low-level source data cache backing store interface.
22 */
23
24#ifndef NETSURF_CONTENT_LLCACHE_PRIVATE_H_
25#define NETSURF_CONTENT_LLCACHE_PRIVATE_H_
26
27#include "content/llcache.h"
28
29/** storage control flags */
31 /** no special processing */
33 /** data is metadata */
35};
36
37/**
38 * low level cache backing store operation table
39 *
40 * The low level cache (source objects) has the capability to make
41 * objects and their metadata (headers etc) persistent by writing to a
42 * backing store using these operations.
43 */
45 /**
46 * Initialise the backing store.
47 *
48 * @param parameters to configure backing store.
49 * @return NSERROR_OK on success or error code on failure.
50 */
51 nserror (*initialise)(const struct llcache_store_parameters *parameters);
52
53 /**
54 * Finalise the backing store.
55 *
56 * @return NSERROR_OK on success or error code on failure.
57 */
58 nserror (*finalise)(void);
59
60 /**
61 * Place an object in the backing store.
62 *
63 * The object is placed in the persistent store and may be
64 * retrieved with the fetch method.
65 *
66 * The backing store will take a reference to the
67 * passed data, subsequently the caller should explicitly
68 * release the allocation using the release method and not
69 * free the data itself.
70 *
71 * The caller may not assume that the persistent storage has
72 * been completely written on return.
73 *
74 * @param[in] url The url is used as the unique primary key for the data.
75 * @param[in] flags The flags to control how the object is stored.
76 * @param[in] data The objects data.
77 * @param[in] datalen The length of the \a data.
78 * @return NSERROR_OK on success or error code on failure.
79 */
80 nserror (*store)(struct nsurl *url, enum backing_store_flags flags,
81 uint8_t *data, const size_t datalen);
82
83 /**
84 * Retrieve an object from the backing store.
85 *
86 * The backing store will manage its own memory and the
87 * allocations returned in \a data *must* not be altered.
88 *
89 * The caller must assume nothing about the backing store
90 * allocated buffers and the storage and *must* be freed by
91 * calling the release method.
92 *
93 * @param[in] url The url is used as the unique primary key for the data.
94 * @param[in] flags The flags to control how the object is retrieved.
95 * @param[out] data The retrieved objects data.
96 * @param[out] datalen The length of the \a data retrieved.
97 * @return NSERROR_OK on success or error code on failure.
98 */
99 nserror (*fetch)(struct nsurl *url, enum backing_store_flags flags,
100 uint8_t **data, size_t *datalen);
101
102 /**
103 * release a previously fetched or stored memory object.
104 *
105 * @param url The url is used as the unique primary key to invalidate.
106 * @param[in] flags The flags to control how the object data is released.
107 * @return NSERROR_OK on success or error code on failure.
108 */
109 nserror (*release)(struct nsurl *url, enum backing_store_flags flags);
110
111 /**
112 * Invalidate a source object from the backing store.
113 *
114 * The entry (if present in the backing store) must no longer
115 * be returned as a result to the fetch or meta operations.
116 *
117 * If the entry had data allocated it will be released.
118 *
119 * @param url The url is used as the unique primary key to invalidate.
120 * @return NSERROR_OK on success or error code on failure.
121 */
122 nserror (*invalidate)(struct nsurl *url);
123
124};
125
128
129#endif
backing_store_flags
storage control flags
Definition: backing_store.h:30
@ BACKING_STORE_NONE
no special processing
Definition: backing_store.h:32
@ BACKING_STORE_META
data is metadata
Definition: backing_store.h:34
struct gui_llcache_table * null_llcache_table
struct gui_llcache_table * filesystem_llcache_table
nserror
Enumeration of error codes.
Definition: errors.h:29
Low-level resource cache (interface)
struct nsurl nsurl
NetSurf URL object.
Definition: nsurl.h:31
Information for a single fetch.
Definition: fetch.c:89
low level cache backing store operation table
Definition: backing_store.h:44
nserror(* initialise)(const struct llcache_store_parameters *parameters)
Initialise the backing store.
Definition: backing_store.h:51
nserror(* store)(struct nsurl *url, enum backing_store_flags flags, uint8_t *data, const size_t datalen)
Place an object in the backing store.
Definition: backing_store.h:80
nserror(* finalise)(void)
Finalise the backing store.
Definition: backing_store.h:58
nserror(* invalidate)(struct nsurl *url)
Invalidate a source object from the backing store.
nserror(* release)(struct nsurl *url, enum backing_store_flags flags)
release a previously fetched or stored memory object.
Parameters to configure the low level cache backing store.
Definition: llcache.h:119