Adding interface files for new cache service.

This commit is contained in:
gordon%netscape.com 2001-02-23 00:11:10 +00:00
Родитель 16dd48a05c
Коммит e47ae228f9
3 изменённых файлов: 238 добавлений и 0 удалений

110
netwerk/cache/public/nsICacheEntryDescriptor.idl поставляемый Normal file
Просмотреть файл

@ -0,0 +1,110 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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/
*
* 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.
*
* The Original Code is nsICacheEntryDescriptor.idl, released
* February 10, 2001.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Gordon Sheridan, 10-February-2001
*/
#include "nsITransport.idl"
interface nsISimpleEnumerator;
interface nsICacheListener;
[scriptable, uuid(49c1a11d-f5d2-4f09-8262-551e64908ada)]
interface nsICacheEntryDescriptor : nsITransport
{
/**
* attributes from cache entry
*/
readonly attribute string clientID;
readonly attribute string key;
readonly attribute PRTime lastValidated;
readonly attribute PRTime lastFetch;
readonly attribute unsigned long fetchCount;
attribute PRTime expiresDate;
attribute boolean streamBased;
/**
* For accessing non-persistent cached objects
*/
attribute nsISupports cacheElement;
/**
* Access granted to this descriptor. (see nsICacheService.idl)
*/
readonly attribute unsigned long accessGranted;
/**
* Storage flags
*/
const unsigned long DONT_CACHE = 0;
const unsigned long ALLOW_IN_MEMORY = 1;
const unsigned long ALLOW_ON_DISK = 2;
const unsigned long ALLOW_IN_MEMORY_OR_ON_DISK = 3;
attribute unsigned long storageFlags;
/* and/or */
attribute boolean allowInMemory;
attribute boolean allowOnDisk;
/**
* Doom the cache entry this descriptor references in order to slate it for
* removal. Once doomed a cache entry cannot be undoomed.
*/
void doom();
void doomAndFailPendingRequests(in nsresult status);
/**
* Data in an existing cache object may only be appended to. Therefore,
* a writer wishing to replace existing cache data should first truncate
* the existing data to the appropriate length.
*/
void truncateExistingData(in unsigned long newLength);
/**
* Set internal flag so we know more data is expected than what is there currently.
*
*/
void appendToExistingData();
/**
* A writer must validate this cache object before any readers are given
* a descriptor to the object.
*/
void markValid();
/**
* Methods for accessing MetaData.
*/
string getMetaDataElement(in string key);
void setMetadataElement(in string key, in string value);
nsISimpleEnumerator getMetaDataEnumerator();
};

40
netwerk/cache/public/nsICacheListener.idl поставляемый Normal file
Просмотреть файл

@ -0,0 +1,40 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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/
*
* 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.
*
* The Original Code is nsICacheListener.idl, released January 19, 2001.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Gordon Sheridan, 19-January-2001
*/
#include "nsISupports.idl"
interface nsICacheEntryDescriptor;
[scriptable, uuid(638c3848-778b-4851-8ff3-9400f65b8773)]
interface nsICacheListener : nsISupports
{
/**
* Called when the requested access (or appropriate subset) is
* acquired. The status parameter equals NS_OK on success.
* See nsICacheService.idl for accessGranted values.
*/
void onDescriptorAvailable(in nsICacheEntryDescriptor descriptor,
in unsigned long accessGranted,
in nsresult status);
};

88
netwerk/cache/public/nsICacheService.idl поставляемый Normal file
Просмотреть файл

@ -0,0 +1,88 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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/
*
* 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.
*
* The Original Code is nsICacheService.idl, released February 10, 2001.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Gordon Sheridan, 10-February-2001
*/
#include "nsISupports.idl"
#include "nsICacheEntryDescriptor.idl"
interface nsISimpleEnumerator;
interface nsICacheListener;
[scriptable, uuid(0ebec4c7-742f-4f27-8e7b-7c8a0cc76348)]
interface nsICacheService : nsISupports
{
void init();
void shutdown();
/**
* Access flags.
*/
const unsigned long NO_ACCESS = 0;
const unsigned long READ = 1;
const unsigned long WRITE = 2;
const unsigned long READ_WRITE = 3;
/*
* Synchronous cache access. This returns a unique descriptor each
* time it is called, even if the same key is specified. When
* called by multiple threads for write access, only one writeable
* descriptor will be granted.
*/
nsICacheEntryDescriptor openCacheEntry(in string clientID,
in string key,
in unsigned long accessFlagsRequested,
in boolean streamBased);
/*
* Asynchronous cache access. Does not block the calling thread.
*/
void asyncOpenCacheEntry(in string clientID,
in string key,
in unsigned long accessFlagsRequested,
in boolean streamBased,
in nsICacheListener listener);
/*
* methods for implementing about:cache
*/
nsISimpleEnumerator enumerateDeviceIDs();
nsISimpleEnumerator enumerateClientIDs();
nsISimpleEnumerator enumerateEntries(in string deviceID,
in string clientID);
};
%{C++
#define NS_ERROR_CACHE_KEY_NOT_FOUND NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 60)
#define NS_ERROR_CACHE_DATA_IS_STREAM NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 61)
#define NS_ERROR_CACHE_DATA_IS_NOT_STREAM NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 62)
#define NS_ERROR_CACHE_WAIT_FOR_VALIDATION NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 63)
#define NS_ERROR_CACHE_ENTRY_DOOMED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 64)
%}