1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/cache2/nsICacheEntryOpenCallback.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,91 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#include "nsISupports.idl" 1.9 + 1.10 +interface nsICacheEntry; 1.11 +interface nsIApplicationCache; 1.12 + 1.13 +[scriptable, uuid(1fc9fe11-c6ac-4748-94bd-8555a5a12b94)] 1.14 +interface nsICacheEntryOpenCallback : nsISupports 1.15 +{ 1.16 + /** 1.17 + * State of the entry determined by onCacheEntryCheck. 1.18 + * 1.19 + * ENTRY_WANTED - the consumer is interested in the entry, we will pass it. 1.20 + * RECHECK_AFTER_WRITE_FINISHED - the consumer cannot use the entry while data is 1.21 + * still being written and wants to check it again after the current write is 1.22 + * finished. This actually prevents concurrent read/write and is used with 1.23 + * non-resumable HTTP responses. 1.24 + * ENTRY_NEEDS_REVALIDATION - entry needs to be revalidated first with origin server, 1.25 + * this means the loading channel will decide whether to use the entry content 1.26 + * as is after it gets a positive response from the server about validity of the 1.27 + * content ; when a new content needs to be loaded from the server, the loading 1.28 + * channel opens a new entry with OPEN_TRUNCATE flag which dooms the one 1.29 + * this check has been made for. 1.30 + * ENTRY_NOT_WANTED - the consumer is not interested in the entry, we will not pass it. 1.31 + */ 1.32 + const unsigned long ENTRY_WANTED = 0; 1.33 + const unsigned long RECHECK_AFTER_WRITE_FINISHED = 1; 1.34 + const unsigned long ENTRY_NEEDS_REVALIDATION = 2; 1.35 + const unsigned long ENTRY_NOT_WANTED = 3; 1.36 + 1.37 + /** 1.38 + * Callback to perform any validity checks before the entry should be used. 1.39 + * Called before onCacheEntryAvailable callback, depending on the result it 1.40 + * may be called more then one time. 1.41 + * 1.42 + * This callback is ensured to be called on the same thread on which asyncOpenURI 1.43 + * has been called, unless nsICacheStorage.CHECK_MULTITHREADED flag has been specified. 1.44 + * In that case this callback can be invoked on any thread, usually it is the cache I/O 1.45 + * or cache management thread. 1.46 + * 1.47 + * IMPORTANT NOTE: 1.48 + * This callback may be invoked sooner then respective asyncOpenURI call exits. 1.49 + * 1.50 + * @param aEntry 1.51 + * An entry to examine. Consumer has a chance to decide whether the 1.52 + * entry is valid or not. 1.53 + * @param aApplicationCache 1.54 + * Optional, application cache the entry has been found in, if any. 1.55 + * @return 1.56 + * State of the entry, see the constants just above. 1.57 + */ 1.58 + unsigned long onCacheEntryCheck(in nsICacheEntry aEntry, 1.59 + in nsIApplicationCache aApplicationCache); 1.60 + 1.61 + /** 1.62 + * Callback giving actual result of asyncOpenURI. It may give consumer the cache 1.63 + * entry or a failure result when it's not possible to open it from some reason. 1.64 + * This callback is ensured to be called on the same thread on which asyncOpenURI 1.65 + * has been called. 1.66 + * 1.67 + * IMPORTANT NOTE: 1.68 + * This callback may be invoked sooner then respective asyncOpenURI call exits. 1.69 + * 1.70 + * @param aEntry 1.71 + * The entry bound to the originally requested URI. May be null when 1.72 + * loading from a particular application cache and the URI has not 1.73 + * been found in that application cache. 1.74 + * @param aNew 1.75 + * Whether no data so far has been stored for this entry, i.e. reading 1.76 + * it will just fail. When aNew is true, a server request should be 1.77 + * made and data stored to this new entry. 1.78 + * @param aApplicationCache 1.79 + * When an entry had been found in an application cache, this is the 1.80 + * given application cache. It should be associated with the loading 1.81 + * channel. 1.82 + * @param aResult 1.83 + * Result of the request. This may be a failure only when one of these 1.84 + * issues occur: 1.85 + * - the cache storage service could not be started due to some unexpected 1.86 + * faulure 1.87 + * - there is not enough disk space to create new entries 1.88 + * - cache entry was not found in a given application cache 1.89 + */ 1.90 + void onCacheEntryAvailable(in nsICacheEntry aEntry, 1.91 + in boolean aNew, 1.92 + in nsIApplicationCache aApplicationCache, 1.93 + in nsresult aResult); 1.94 +};