2001-02-23 00:11:10 +00:00
|
|
|
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*
|
2012-05-21 11:12:37 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-02-23 00:11:10 +00:00
|
|
|
|
2001-03-14 01:11:14 +00:00
|
|
|
#include "nsICacheVisitor.idl"
|
2001-02-23 23:20:15 +00:00
|
|
|
#include "nsICache.idl"
|
2001-02-23 00:11:10 +00:00
|
|
|
|
|
|
|
interface nsISimpleEnumerator;
|
|
|
|
interface nsICacheListener;
|
2003-01-18 02:15:14 +00:00
|
|
|
interface nsIInputStream;
|
|
|
|
interface nsIOutputStream;
|
2001-03-07 01:37:42 +00:00
|
|
|
interface nsIFile;
|
2001-04-04 03:30:45 +00:00
|
|
|
interface nsICacheMetaDataVisitor;
|
|
|
|
|
2001-02-23 00:11:10 +00:00
|
|
|
|
2012-08-21 03:28:19 +00:00
|
|
|
[scriptable, uuid(49c1a11d-f5d2-4f09-8262-551e64908ada)]
|
2001-03-14 01:11:14 +00:00
|
|
|
interface nsICacheEntryDescriptor : nsICacheEntryInfo
|
2001-02-23 00:11:10 +00:00
|
|
|
{
|
|
|
|
/**
|
2001-03-14 03:54:05 +00:00
|
|
|
* Set the time at which the cache entry should be considered invalid (in
|
|
|
|
* seconds since the Epoch).
|
2001-02-23 00:11:10 +00:00
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
void setExpirationTime(in uint32_t expirationTime);
|
2001-02-24 01:27:49 +00:00
|
|
|
|
|
|
|
/**
|
2001-03-14 01:11:14 +00:00
|
|
|
* Set the cache entry data size. This will fail if the cache entry
|
|
|
|
* IS stream based.
|
2001-02-24 01:27:49 +00:00
|
|
|
*/
|
2001-03-14 01:11:14 +00:00
|
|
|
void setDataSize(in unsigned long size);
|
2001-02-23 00:11:10 +00:00
|
|
|
|
|
|
|
/**
|
2003-01-18 02:15:14 +00:00
|
|
|
* Open blocking input stream to cache data. This will fail if the cache
|
|
|
|
* entry IS NOT stream based. Use the stream transport service to
|
|
|
|
* asynchronously read this stream on a background thread. The returned
|
|
|
|
* stream MAY implement nsISeekableStream.
|
|
|
|
*
|
|
|
|
* @param offset
|
2003-10-09 01:54:07 +00:00
|
|
|
* read starting from this offset into the cached data. an offset
|
|
|
|
* beyond the end of the stream has undefined consequences.
|
2003-01-18 02:15:14 +00:00
|
|
|
*
|
|
|
|
* @return blocking, unbuffered input stream.
|
2001-02-23 23:55:42 +00:00
|
|
|
*/
|
2003-01-18 02:15:14 +00:00
|
|
|
nsIInputStream openInputStream(in unsigned long offset);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open blocking output stream to cache data. This will fail if the cache
|
|
|
|
* entry IS NOT stream based. Use the stream transport service to
|
|
|
|
* asynchronously write to this stream on a background thread. The returned
|
|
|
|
* stream MAY implement nsISeekableStream.
|
|
|
|
*
|
|
|
|
* If opening an output stream to existing cached data, the data will be
|
|
|
|
* truncated to the specified offset.
|
|
|
|
*
|
|
|
|
* @param offset
|
2003-10-09 01:54:07 +00:00
|
|
|
* write starting from this offset into the cached data. an offset
|
|
|
|
* beyond the end of the stream has undefined consequences.
|
2003-01-18 02:15:14 +00:00
|
|
|
*
|
|
|
|
* @return blocking, unbuffered output stream.
|
|
|
|
*/
|
|
|
|
nsIOutputStream openOutputStream(in unsigned long offset);
|
2001-02-23 23:55:42 +00:00
|
|
|
|
|
|
|
/**
|
2001-02-24 01:27:49 +00:00
|
|
|
* Get/set the cache data element. This will fail if the cache entry
|
|
|
|
* IS stream based. The cache entry holds a strong reference to this
|
|
|
|
* object. The object will be released when the cache entry is destroyed.
|
2001-02-23 00:11:10 +00:00
|
|
|
*/
|
2001-02-24 01:27:49 +00:00
|
|
|
attribute nsISupports cacheElement;
|
2010-09-07 22:39:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Stores the Content-Length specified in the HTTP header for this
|
|
|
|
* entry. Checked before we write to the cache entry, to prevent ever
|
|
|
|
* taking up space in the cache for an entry that we know up front
|
|
|
|
* is going to have to be evicted anyway. See bug 588507.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
attribute int64_t predictedDataSize;
|
2010-09-07 22:39:28 +00:00
|
|
|
|
2001-02-23 00:11:10 +00:00
|
|
|
/**
|
2001-02-24 01:27:49 +00:00
|
|
|
* Get the access granted to this descriptor. See nsICache.idl for the
|
|
|
|
* definitions of the access modes and a thorough description of their
|
|
|
|
* corresponding meanings.
|
2001-02-23 00:11:10 +00:00
|
|
|
*/
|
2001-02-24 01:27:49 +00:00
|
|
|
readonly attribute nsCacheAccessMode accessGranted;
|
2001-02-23 00:11:10 +00:00
|
|
|
|
|
|
|
/**
|
2001-02-24 01:27:49 +00:00
|
|
|
* Get/set the storage policy of the cache entry. See nsICache.idl for
|
|
|
|
* the definitions of the storage policies.
|
2001-02-23 00:11:10 +00:00
|
|
|
*/
|
2001-02-23 23:20:15 +00:00
|
|
|
attribute nsCacheStoragePolicy storagePolicy;
|
2001-03-07 01:37:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the disk file associated with the cache entry.
|
|
|
|
*/
|
|
|
|
readonly attribute nsIFile file;
|
2001-03-07 02:47:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get/set security info on the cache entry for this descriptor. This fails
|
|
|
|
* if the storage policy is not STORE_IN_MEMORY.
|
|
|
|
*/
|
|
|
|
attribute nsISupports securityInfo;
|
2001-02-23 00:11:10 +00:00
|
|
|
|
2011-12-17 10:30:29 +00:00
|
|
|
/**
|
|
|
|
* Get the size of the cache entry data, as stored. This may differ
|
|
|
|
* from the entry's dataSize, if the entry is compressed.
|
|
|
|
*/
|
|
|
|
readonly attribute unsigned long storageDataSize;
|
|
|
|
|
2001-02-23 00:11:10 +00:00
|
|
|
/**
|
|
|
|
* Doom the cache entry this descriptor references in order to slate it for
|
|
|
|
* removal. Once doomed a cache entry cannot be undoomed.
|
2001-02-24 01:27:49 +00:00
|
|
|
*
|
|
|
|
* A descriptor with WRITE access can doom the cache entry and choose to
|
|
|
|
* fail pending requests. This means that pending requests will not get
|
|
|
|
* a cache descriptor. This is meant as a tool for clients that wish to
|
|
|
|
* instruct pending requests to skip the cache.
|
2001-02-23 00:11:10 +00:00
|
|
|
*/
|
|
|
|
void doom();
|
|
|
|
void doomAndFailPendingRequests(in nsresult status);
|
2012-08-21 03:28:19 +00:00
|
|
|
|
2001-02-23 00:11:10 +00:00
|
|
|
/**
|
|
|
|
* A writer must validate this cache object before any readers are given
|
|
|
|
* a descriptor to the object.
|
|
|
|
*/
|
|
|
|
void markValid();
|
2001-02-27 05:29:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Explicitly close the descriptor (optional).
|
|
|
|
*/
|
2001-02-23 00:11:10 +00:00
|
|
|
|
2001-03-14 01:11:14 +00:00
|
|
|
void close();
|
2001-02-27 05:29:25 +00:00
|
|
|
|
2001-02-23 00:11:10 +00:00
|
|
|
/**
|
2001-02-24 01:27:49 +00:00
|
|
|
* Methods for accessing meta data. Meta data is a table of key/value
|
|
|
|
* string pairs. The strings do not have to conform to any particular
|
|
|
|
* charset, but they must be null terminated.
|
2001-02-23 00:11:10 +00:00
|
|
|
*/
|
2001-02-24 01:27:49 +00:00
|
|
|
string getMetaDataElement(in string key);
|
2001-03-02 01:52:29 +00:00
|
|
|
void setMetaDataElement(in string key, in string value);
|
2001-02-23 00:11:10 +00:00
|
|
|
|
2001-04-04 03:30:45 +00:00
|
|
|
/**
|
|
|
|
* Visitor will be called with key/value pair for each meta data element.
|
|
|
|
*/
|
|
|
|
void visitMetaData(in nsICacheMetaDataVisitor visitor);
|
2001-02-23 00:11:10 +00:00
|
|
|
};
|
|
|
|
|
2001-04-04 03:30:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
[scriptable, uuid(22f9a49c-3cf8-4c23-8006-54efb11ac562)]
|
|
|
|
interface nsICacheMetaDataVisitor : nsISupports
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Called for each key/value pair in the meta data for a cache entry
|
|
|
|
*/
|
|
|
|
boolean visitMetaDataElement(in string key,
|
|
|
|
in string value);
|
|
|
|
};
|