2001-03-13 05:24:12 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2001-09-29 00:14:13 +04:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-19 02:01:16 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2001-03-13 05:24:12 +03:00
|
|
|
*
|
2004-04-19 02:01:16 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
2001-03-13 05:24:12 +03:00
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-19 02:01:16 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2001
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2001-03-13 05:24:12 +03:00
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Darin Fisher <darin@netscape.com> (original author)
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-19 02:01:16 +04:00
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
2001-09-29 00:14:13 +04:00
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-19 02:01:16 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-19 02:01:16 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-03-13 05:24:12 +03:00
|
|
|
|
2010-06-24 10:55:19 +04:00
|
|
|
#include "nsICacheInfoChannel.idl"
|
2001-03-13 05:24:12 +03:00
|
|
|
|
2001-03-13 14:15:06 +03:00
|
|
|
interface nsIFile;
|
|
|
|
|
2001-03-13 05:24:12 +03:00
|
|
|
/**
|
|
|
|
* A channel may optionally implement this interface to allow clients
|
2005-01-09 23:43:35 +03:00
|
|
|
* to affect its behavior with respect to how it uses the cache service.
|
2001-03-13 05:24:12 +03:00
|
|
|
*
|
|
|
|
* This interface provides:
|
|
|
|
* 1) Support for "stream as file" semantics (for JAR and plugins).
|
|
|
|
* 2) Support for "pinning" cached data in the cache (for printing and save-as).
|
2002-10-06 07:20:40 +04:00
|
|
|
* 3) Support for uniquely identifying cached data in cases when the URL
|
|
|
|
* is insufficient (e.g., HTTP form submission).
|
2001-03-13 05:24:12 +03:00
|
|
|
*/
|
2010-10-01 03:55:11 +04:00
|
|
|
[scriptable, uuid(830D4BCB-3E46-4011-9BDA-51A5D1AF891F)]
|
2010-06-24 10:55:19 +04:00
|
|
|
interface nsICachingChannel : nsICacheInfoChannel
|
2001-03-13 05:24:12 +03:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Set/get the cache token... uniquely identifies the data in the cache.
|
2001-03-21 01:42:03 +03:00
|
|
|
* Holding a reference to this token prevents the cached data from being
|
2002-10-06 07:20:40 +04:00
|
|
|
* removed.
|
|
|
|
*
|
|
|
|
* A cache token retrieved from a particular instance of nsICachingChannel
|
|
|
|
* could be set on another instance of nsICachingChannel provided the
|
|
|
|
* underlying implementations are compatible. The implementation of
|
|
|
|
* nsICachingChannel would be expected to only read from the cache entry
|
|
|
|
* identified by the cache token and not try to validate it.
|
2001-03-13 05:24:12 +03:00
|
|
|
*
|
2002-10-06 07:20:40 +04:00
|
|
|
* The cache token can be QI'd to a nsICacheEntryInfo if more detail
|
|
|
|
* about the cache entry is needed (e.g., expiration time).
|
2001-03-13 05:24:12 +03:00
|
|
|
*/
|
|
|
|
attribute nsISupports cacheToken;
|
|
|
|
|
2008-01-29 10:54:54 +03:00
|
|
|
/**
|
|
|
|
* The same as above but accessing the offline app cache token if there
|
|
|
|
* is any.
|
|
|
|
*
|
|
|
|
* @throws
|
|
|
|
* NS_ERROR_NOT_AVAILABLE when there is not offline cache token
|
|
|
|
*/
|
|
|
|
attribute nsISupports offlineCacheToken;
|
|
|
|
|
2001-03-21 01:42:03 +03:00
|
|
|
/**
|
2002-10-06 07:20:40 +04:00
|
|
|
* Set/get the cache key... uniquely identifies the data in the cache
|
|
|
|
* for this channel. Holding a reference to this key does NOT prevent
|
|
|
|
* the cached data from being removed.
|
|
|
|
*
|
|
|
|
* A cache key retrieved from a particular instance of nsICachingChannel
|
|
|
|
* could be set on another instance of nsICachingChannel provided the
|
|
|
|
* underlying implementations are compatible and provided the new
|
|
|
|
* channel instance was created with the same URI. The implementation of
|
|
|
|
* nsICachingChannel would be expected to use the cache entry identified
|
|
|
|
* by the cache token. Depending on the value of nsIRequest::loadFlags,
|
|
|
|
* the cache entry may be validated, overwritten, or simply read.
|
2001-04-02 05:20:43 +04:00
|
|
|
*
|
2002-10-06 07:20:40 +04:00
|
|
|
* The cache key may be NULL indicating that the URI of the channel is
|
|
|
|
* sufficient to locate the same cache entry. Setting a NULL cache key
|
|
|
|
* is likewise valid.
|
2001-03-21 01:42:03 +03:00
|
|
|
*/
|
2002-10-06 07:20:40 +04:00
|
|
|
attribute nsISupports cacheKey;
|
2001-03-21 01:42:03 +03:00
|
|
|
|
2001-03-13 05:24:12 +03:00
|
|
|
/**
|
|
|
|
* Specifies whether or not the data should be cached to a file. This
|
|
|
|
* may fail if the disk cache is not present. The value of this attribute
|
|
|
|
* is usually only settable during the processing of a channel's
|
|
|
|
* OnStartRequest. The default value of this attribute depends on the
|
|
|
|
* particular implementation of nsICachingChannel.
|
|
|
|
*/
|
|
|
|
attribute boolean cacheAsFile;
|
|
|
|
|
2007-03-14 04:52:07 +03:00
|
|
|
/**
|
|
|
|
* Specifies whether or not the data should be placed in the offline cache,
|
|
|
|
* in addition to normal memory/disk caching. This may fail if the offline
|
|
|
|
* cache is not present. The value of this attribute should be set before
|
|
|
|
* opening the channel.
|
|
|
|
*/
|
|
|
|
attribute boolean cacheForOfflineUse;
|
|
|
|
|
2007-07-25 10:31:27 +04:00
|
|
|
/**
|
|
|
|
* The session into which to cache offline data. If not specified,
|
|
|
|
* data will be placed in "HTTP-offline"
|
|
|
|
*/
|
|
|
|
attribute ACString offlineCacheClientID;
|
|
|
|
|
2001-03-13 05:24:12 +03:00
|
|
|
/**
|
|
|
|
* Get the "file" where the cached data can be found. This is valid for
|
|
|
|
* as long as a reference to the cache token is held. This may return
|
|
|
|
* an error if cacheAsFile is false.
|
|
|
|
*/
|
|
|
|
readonly attribute nsIFile cacheFile;
|
2001-12-15 01:53:13 +03:00
|
|
|
|
2002-10-06 07:20:40 +04:00
|
|
|
/**************************************************************************
|
|
|
|
* Caching channel specific load flags:
|
|
|
|
*/
|
|
|
|
|
2007-07-27 06:40:45 +04:00
|
|
|
/**
|
|
|
|
* This load flag inhibits fetching from the net. An error of
|
|
|
|
* NS_ERROR_DOCUMENT_NOT_CACHED will be sent to the listener's
|
|
|
|
* onStopRequest if network IO is necessary to complete the request.
|
|
|
|
*
|
|
|
|
* This flag can be used to find out whether fetching this URL would
|
|
|
|
* cause validation of the cache entry via the network.
|
|
|
|
*
|
|
|
|
* Combining this flag with LOAD_BYPASS_LOCAL_CACHE will cause all
|
|
|
|
* loads to fail. This flag differs from LOAD_ONLY_FROM_CACHE in that
|
|
|
|
* this flag fails the load if validation is required while
|
|
|
|
* LOAD_ONLY_FROM_CACHE skips validation where possible.
|
|
|
|
*/
|
|
|
|
const unsigned long LOAD_NO_NETWORK_IO = 1 << 26;
|
|
|
|
|
2007-07-09 02:15:51 +04:00
|
|
|
/**
|
|
|
|
* This load flag causes the offline cache to be checked when fetching
|
|
|
|
* a request. It will be set automatically if the browser is offline.
|
2008-11-04 13:20:27 +03:00
|
|
|
*
|
|
|
|
* This flag will not be transferred through a redirect.
|
2007-07-09 02:15:51 +04:00
|
|
|
*/
|
|
|
|
const unsigned long LOAD_CHECK_OFFLINE_CACHE = 1 << 27;
|
|
|
|
|
2005-10-20 22:19:24 +04:00
|
|
|
/**
|
|
|
|
* This load flag causes the local cache to be skipped when fetching a
|
|
|
|
* request. Unlike LOAD_BYPASS_CACHE, it does not force an end-to-end load
|
|
|
|
* (i.e., it does not affect proxy caches).
|
|
|
|
*/
|
|
|
|
const unsigned long LOAD_BYPASS_LOCAL_CACHE = 1 << 28;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This load flag causes the local cache to be skipped if the request
|
|
|
|
* would otherwise block waiting to access the cache.
|
|
|
|
*/
|
|
|
|
const unsigned long LOAD_BYPASS_LOCAL_CACHE_IF_BUSY = 1 << 29;
|
|
|
|
|
2002-10-06 07:20:40 +04:00
|
|
|
/**
|
|
|
|
* This load flag inhibits fetching from the net if the data in the cache
|
|
|
|
* has been evicted. An error of NS_ERROR_DOCUMENT_NOT_CACHED will be sent
|
2007-07-09 02:15:51 +04:00
|
|
|
* to the listener's onStopRequest in this case. This flag is set
|
|
|
|
* automatically when the application is offline.
|
2002-10-06 07:20:40 +04:00
|
|
|
*/
|
|
|
|
const unsigned long LOAD_ONLY_FROM_CACHE = 1 << 30;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This load flag controls what happens when a document would be loaded
|
|
|
|
* from the cache to satisfy a call to AsyncOpen. If this attribute is
|
|
|
|
* set to TRUE, then the document will not be loaded from the cache. A
|
|
|
|
* stream listener can check nsICachingChannel::isFromCache to determine
|
|
|
|
* if the AsyncOpen will actually result in data being streamed.
|
|
|
|
*
|
|
|
|
* If this flag has been set, and the request can be satisfied via the
|
|
|
|
* cache, then the OnDataAvailable events will be skipped. The listener
|
|
|
|
* will only see OnStartRequest followed by OnStopRequest.
|
|
|
|
*/
|
|
|
|
const unsigned long LOAD_ONLY_IF_MODIFIED = 1 << 31;
|
|
|
|
};
|