2014-03-08 18:40:09 +04:00
|
|
|
/*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2014-11-23 18:43:03 +03:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* Low-level source data cache backing store interface.
|
2014-03-08 18:40:09 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NETSURF_CONTENT_LLCACHE_PRIVATE_H_
|
|
|
|
#define NETSURF_CONTENT_LLCACHE_PRIVATE_H_
|
|
|
|
|
|
|
|
#include "content/llcache.h"
|
|
|
|
|
|
|
|
/** storage control flags */
|
|
|
|
enum backing_store_flags {
|
2014-11-21 01:28:19 +03:00
|
|
|
/** no special processing */
|
|
|
|
BACKING_STORE_NONE = 0,
|
|
|
|
/** data is metadata */
|
|
|
|
BACKING_STORE_META = 1,
|
2014-03-08 18:40:09 +04:00
|
|
|
};
|
|
|
|
|
2014-11-23 18:43:03 +03:00
|
|
|
/**
|
|
|
|
* low level cache backing store operation table
|
2014-03-08 18:40:09 +04:00
|
|
|
*
|
|
|
|
* The low level cache (source objects) has the capability to make
|
|
|
|
* objects and their metadata (headers etc) persistant by writing to a
|
|
|
|
* backing store using these operations.
|
|
|
|
*/
|
|
|
|
struct gui_llcache_table {
|
|
|
|
/**
|
|
|
|
* Initialise the backing store.
|
|
|
|
*
|
|
|
|
* @param parameters to configure backing store.
|
|
|
|
* @return NSERROR_OK on success or error code on faliure.
|
|
|
|
*/
|
|
|
|
nserror (*initialise)(const struct llcache_store_parameters *parameters);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Finalise the backing store.
|
|
|
|
*
|
|
|
|
* @return NSERROR_OK on success or error code on faliure.
|
|
|
|
*/
|
|
|
|
nserror (*finalise)(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Place an object in the backing store.
|
|
|
|
*
|
2014-11-21 01:28:19 +03:00
|
|
|
* The object is placed in the persistent store and may be
|
2014-11-23 02:56:13 +03:00
|
|
|
* retrieved with the fetch method.
|
2014-11-23 18:43:03 +03:00
|
|
|
*
|
2014-11-23 02:56:13 +03:00
|
|
|
* The backing store will take a reference to the
|
|
|
|
* passed data, subsequently the caller should explicitly
|
|
|
|
* release the allocation using the release method and not
|
|
|
|
* free the data itself.
|
2014-11-23 18:43:03 +03:00
|
|
|
*
|
2014-11-23 02:56:13 +03:00
|
|
|
* The caller may not assume that the persistent storage has
|
|
|
|
* been completely written on return.
|
2014-11-21 01:28:19 +03:00
|
|
|
*
|
|
|
|
* @param[in] url The url is used as the unique primary key for the data.
|
|
|
|
* @param[in] flags The flags to control how the obejct is stored.
|
|
|
|
* @param[in] data The objects data.
|
|
|
|
* @param[in] datalen The length of the \a data.
|
2014-03-08 18:40:09 +04:00
|
|
|
* @return NSERROR_OK on success or error code on faliure.
|
|
|
|
*/
|
|
|
|
nserror (*store)(struct nsurl *url, enum backing_store_flags flags,
|
2014-11-23 04:37:24 +03:00
|
|
|
uint8_t *data, const size_t datalen);
|
2014-03-08 18:40:09 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrive an object from the backing store.
|
|
|
|
*
|
2015-03-27 12:29:49 +03:00
|
|
|
* The backing store will manage its own memory and the
|
|
|
|
* allocations returned in \a data *must* not be altered.
|
2014-11-23 18:43:03 +03:00
|
|
|
*
|
2014-11-23 02:56:13 +03:00
|
|
|
* The caller must assume nothing about the backing store
|
|
|
|
* allocated buffers and the storage and *must* be freed by
|
|
|
|
* calling the release method.
|
2014-11-21 01:28:19 +03:00
|
|
|
*
|
|
|
|
* @param[in] url The url is used as the unique primary key for the data.
|
|
|
|
* @param[in] flags The flags to control how the object is retrived.
|
2015-03-27 12:29:49 +03:00
|
|
|
* @param[out] data The retrived objects data.
|
|
|
|
* @param[out] datalen The length of the \a data retrieved.
|
2014-03-08 18:40:09 +04:00
|
|
|
* @return NSERROR_OK on success or error code on faliure.
|
|
|
|
*/
|
2014-11-23 02:56:13 +03:00
|
|
|
nserror (*fetch)(struct nsurl *url, enum backing_store_flags flags,
|
2014-03-08 18:40:09 +04:00
|
|
|
uint8_t **data, size_t *datalen);
|
|
|
|
|
2014-11-23 02:56:13 +03:00
|
|
|
/**
|
|
|
|
* release a previously fetched or stored memory object.
|
|
|
|
*
|
|
|
|
* @param url The url is used as the unique primary key to invalidate.
|
|
|
|
* @param[in] flags The flags to control how the object data is released.
|
|
|
|
* @return NSERROR_OK on success or error code on faliure.
|
|
|
|
*/
|
|
|
|
nserror (*release)(struct nsurl *url, enum backing_store_flags flags);
|
|
|
|
|
2014-03-08 18:40:09 +04:00
|
|
|
/**
|
|
|
|
* Invalidate a source object from the backing store.
|
|
|
|
*
|
|
|
|
* The entry (if present in the backing store) must no longer
|
|
|
|
* be returned as a result to the fetch or meta operations.
|
|
|
|
*
|
2014-11-21 01:28:19 +03:00
|
|
|
* If the entry had data allocated it will be released.
|
|
|
|
*
|
2014-03-08 18:40:09 +04:00
|
|
|
* @param url The url is used as the unique primary key to invalidate.
|
|
|
|
* @return NSERROR_OK on success or error code on faliure.
|
|
|
|
*/
|
|
|
|
nserror (*invalidate)(struct nsurl *url);
|
2014-11-21 01:28:19 +03:00
|
|
|
|
2014-03-08 18:40:09 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
extern struct gui_llcache_table* null_llcache_table;
|
|
|
|
extern struct gui_llcache_table* filesystem_llcache_table;
|
|
|
|
|
|
|
|
#endif
|