netwerk/cache/nsICacheEntryDescriptor.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/cache/nsICacheEntryDescriptor.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,164 @@
     1.4 +/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + *
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#include "nsICacheVisitor.idl"
    1.11 +#include "nsICache.idl"
    1.12 +
    1.13 +interface nsISimpleEnumerator;
    1.14 +interface nsICacheListener;
    1.15 +interface nsIInputStream;
    1.16 +interface nsIOutputStream;
    1.17 +interface nsIFile;
    1.18 +interface nsICacheMetaDataVisitor;
    1.19 +
    1.20 +
    1.21 +[scriptable, uuid(90b17d31-46aa-4fb1-a206-473c966cbc18)]
    1.22 +interface nsICacheEntryDescriptor : nsICacheEntryInfo
    1.23 +{
    1.24 +    /**
    1.25 +     * Set the time at which the cache entry should be considered invalid (in
    1.26 +     * seconds since the Epoch).
    1.27 +     */
    1.28 +    void setExpirationTime(in uint32_t expirationTime);
    1.29 +
    1.30 +    /**
    1.31 +     * Set the cache entry data size.  This will fail if the cache entry
    1.32 +     * IS stream based.
    1.33 +     */
    1.34 +    void setDataSize(in unsigned long size);
    1.35 +
    1.36 +    /**
    1.37 +     * Open blocking input stream to cache data.  This will fail if the cache
    1.38 +     * entry IS NOT stream based.  Use the stream transport service to
    1.39 +     * asynchronously read this stream on a background thread.  The returned
    1.40 +     * stream MAY implement nsISeekableStream.
    1.41 +     *
    1.42 +     * @param offset
    1.43 +     *        read starting from this offset into the cached data.  an offset
    1.44 +     *        beyond the end of the stream has undefined consequences.
    1.45 +     *
    1.46 +     * @return blocking, unbuffered input stream.
    1.47 +     */
    1.48 +    nsIInputStream openInputStream(in unsigned long offset);
    1.49 +
    1.50 +    /**
    1.51 +     * Open blocking output stream to cache data.  This will fail if the cache
    1.52 +     * entry IS NOT stream based.  Use the stream transport service to
    1.53 +     * asynchronously write to this stream on a background thread.  The returned
    1.54 +     * stream MAY implement nsISeekableStream.
    1.55 +     *
    1.56 +     * If opening an output stream to existing cached data, the data will be
    1.57 +     * truncated to the specified offset.
    1.58 +     *
    1.59 +     * @param offset
    1.60 +     *        write starting from this offset into the cached data.  an offset
    1.61 +     *        beyond the end of the stream has undefined consequences.
    1.62 +     *
    1.63 +     * @return blocking, unbuffered output stream.
    1.64 +     */
    1.65 +    nsIOutputStream openOutputStream(in unsigned long offset);
    1.66 +
    1.67 +    /**
    1.68 +     * Get/set the cache data element.  This will fail if the cache entry
    1.69 +     * IS stream based.  The cache entry holds a strong reference to this
    1.70 +     * object.  The object will be released when the cache entry is destroyed.
    1.71 +     */
    1.72 +    attribute nsISupports cacheElement;
    1.73 +    
    1.74 +    /**
    1.75 +      * Stores the Content-Length specified in the HTTP header for this
    1.76 +      * entry. Checked before we write to the cache entry, to prevent ever
    1.77 +      * taking up space in the cache for an entry that we know up front 
    1.78 +      * is going to have to be evicted anyway. See bug 588507.
    1.79 +      */
    1.80 +    attribute int64_t    predictedDataSize;
    1.81 +
    1.82 +    /**
    1.83 +     * Get the access granted to this descriptor.  See nsICache.idl for the
    1.84 +     * definitions of the access modes and a thorough description of their
    1.85 +     * corresponding meanings.
    1.86 +     */
    1.87 +    readonly attribute nsCacheAccessMode accessGranted;
    1.88 +    
    1.89 +    /**
    1.90 +     * Get/set the storage policy of the cache entry.  See nsICache.idl for
    1.91 +     * the definitions of the storage policies.
    1.92 +     */
    1.93 +    attribute nsCacheStoragePolicy storagePolicy;
    1.94 +
    1.95 +    /**
    1.96 +     * Get the disk file associated with the cache entry.
    1.97 +     */
    1.98 +    readonly attribute nsIFile file;
    1.99 +
   1.100 +    /**
   1.101 +     * Get/set security info on the cache entry for this descriptor.  This fails
   1.102 +     * if the storage policy is not STORE_IN_MEMORY.
   1.103 +     */
   1.104 +    attribute nsISupports securityInfo;
   1.105 +    
   1.106 +    /**
   1.107 +     * Get the size of the cache entry data, as stored. This may differ
   1.108 +     * from the entry's dataSize, if the entry is compressed.
   1.109 +     */
   1.110 +    readonly attribute unsigned long storageDataSize;
   1.111 +
   1.112 +    /**
   1.113 +     * Doom the cache entry this descriptor references in order to slate it for 
   1.114 +     * removal.  Once doomed a cache entry cannot be undoomed.
   1.115 +     *
   1.116 +     * A descriptor with WRITE access can doom the cache entry and choose to
   1.117 +     * fail pending requests.  This means that pending requests will not get
   1.118 +     * a cache descriptor.  This is meant as a tool for clients that wish to
   1.119 +     * instruct pending requests to skip the cache.
   1.120 +     */
   1.121 +    void doom();
   1.122 +    void doomAndFailPendingRequests(in nsresult status);
   1.123 +
   1.124 +    /**
   1.125 +     * Asynchronously doom an entry. Listener will be notified about the status
   1.126 +     * of the operation. Null may be passed if caller doesn't care about the
   1.127 +     * result.
   1.128 +     */
   1.129 +    void asyncDoom(in nsICacheListener listener);
   1.130 +
   1.131 +    /**
   1.132 +     * A writer must validate this cache object before any readers are given
   1.133 +     * a descriptor to the object.
   1.134 +     */
   1.135 +    void markValid();
   1.136 +
   1.137 +    /**
   1.138 +     *  Explicitly close the descriptor (optional).
   1.139 +     */
   1.140 +    
   1.141 +    void close();
   1.142 +
   1.143 +    /**
   1.144 +     * Methods for accessing meta data.  Meta data is a table of key/value
   1.145 +     * string pairs.  The strings do not have to conform to any particular
   1.146 +     * charset, but they must be null terminated.
   1.147 +     */
   1.148 +    string getMetaDataElement(in string key);
   1.149 +    void   setMetaDataElement(in string key, in string value);
   1.150 +    
   1.151 +    /**
   1.152 +     * Visitor will be called with key/value pair for each meta data element.
   1.153 +     */
   1.154 +    void   visitMetaData(in nsICacheMetaDataVisitor  visitor);
   1.155 +};
   1.156 +
   1.157 +
   1.158 +
   1.159 +[scriptable, uuid(22f9a49c-3cf8-4c23-8006-54efb11ac562)]
   1.160 +interface nsICacheMetaDataVisitor : nsISupports
   1.161 +{
   1.162 +    /**
   1.163 +     * Called for each key/value pair in the meta data for a cache entry
   1.164 +     */
   1.165 +    boolean visitMetaDataElement(in string  key,
   1.166 +                                 in string  value);
   1.167 +};

mercurial