2001-02-23 13:18:01 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*
|
2004-04-18 22:01:16 +00:00
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* 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 nsCacheEntryDescriptor.cpp, released
|
|
|
|
* February 22, 2001.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2001
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Gordon Sheridan, 22-February-2001
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* 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
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* 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
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2001-03-01 02:25:07 +00:00
|
|
|
#include "nsICache.h"
|
2001-03-20 22:42:03 +00:00
|
|
|
#include "nsCache.h"
|
2001-02-26 14:45:45 +00:00
|
|
|
#include "nsCacheService.h"
|
2001-02-23 13:18:01 +00:00
|
|
|
#include "nsCacheEntryDescriptor.h"
|
|
|
|
#include "nsCacheEntry.h"
|
|
|
|
#include "nsReadableUtils.h"
|
2001-03-01 08:29:43 +00:00
|
|
|
#include "nsIOutputStream.h"
|
2002-05-15 18:55:21 +00:00
|
|
|
#include "nsCRT.h"
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2002-05-13 03:21:07 +00:00
|
|
|
NS_IMPL_THREADSAFE_ISUPPORTS2(nsCacheEntryDescriptor,
|
|
|
|
nsICacheEntryDescriptor,
|
|
|
|
nsICacheEntryInfo)
|
2001-02-28 04:10:43 +00:00
|
|
|
|
2001-02-23 13:18:01 +00:00
|
|
|
nsCacheEntryDescriptor::nsCacheEntryDescriptor(nsCacheEntry * entry,
|
2001-02-24 01:36:11 +00:00
|
|
|
nsCacheAccessMode accessGranted)
|
2001-03-07 09:27:36 +00:00
|
|
|
: mCacheEntry(entry),
|
2010-12-29 01:25:14 +00:00
|
|
|
mAccessGranted(accessGranted),
|
|
|
|
mOutput(nsnull)
|
2001-02-23 13:18:01 +00:00
|
|
|
{
|
2004-10-31 21:58:51 +00:00
|
|
|
PR_INIT_CLIST(this);
|
|
|
|
NS_ADDREF(nsCacheService::GlobalInstance()); // ensure it lives for the lifetime of the descriptor
|
2001-02-23 13:18:01 +00:00
|
|
|
}
|
|
|
|
|
2001-02-28 04:10:43 +00:00
|
|
|
|
2001-02-23 13:18:01 +00:00
|
|
|
nsCacheEntryDescriptor::~nsCacheEntryDescriptor()
|
|
|
|
{
|
2005-03-18 08:46:54 +00:00
|
|
|
// No need to close if the cache entry has already been severed. This
|
|
|
|
// helps avoid a shutdown assertion (bug 285519) that is caused when
|
|
|
|
// consumers end up holding onto these objects past xpcom-shutdown. It's
|
|
|
|
// okay for them to do that because the cache service calls our Close
|
|
|
|
// method during xpcom-shutdown, so we don't need to complain about it.
|
|
|
|
if (mCacheEntry)
|
|
|
|
Close();
|
|
|
|
|
2002-08-07 01:13:29 +00:00
|
|
|
nsCacheService * service = nsCacheService::GlobalInstance();
|
|
|
|
NS_RELEASE(service);
|
2001-02-23 13:18:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-14 01:11:14 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCacheEntryDescriptor::GetClientID(char ** result)
|
|
|
|
{
|
2001-03-20 22:42:03 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
2006-06-27 23:13:48 +00:00
|
|
|
|
|
|
|
nsCacheServiceAutoLock lock;
|
2001-03-20 22:42:03 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
|
|
|
return ClientIDFromCacheKey(*(mCacheEntry->Key()), result);
|
2001-03-14 01:11:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-30 01:18:34 +00:00
|
|
|
NS_IMETHODIMP
|
2010-02-21 14:53:13 +00:00
|
|
|
nsCacheEntryDescriptor::GetDeviceID(char ** aDeviceID)
|
2001-04-30 01:18:34 +00:00
|
|
|
{
|
2010-02-21 14:53:13 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aDeviceID);
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-04-30 01:18:34 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2010-02-21 14:53:13 +00:00
|
|
|
const char* deviceID = mCacheEntry->GetDeviceID();
|
|
|
|
if (!deviceID) {
|
|
|
|
*aDeviceID = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aDeviceID = NS_strdup(deviceID);
|
|
|
|
return *aDeviceID ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
2001-04-30 01:18:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-23 13:18:01 +00:00
|
|
|
NS_IMETHODIMP
|
2005-01-13 03:25:28 +00:00
|
|
|
nsCacheEntryDescriptor::GetKey(nsACString &result)
|
2001-02-23 13:18:01 +00:00
|
|
|
{
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-02-28 00:06:13 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2001-03-20 22:42:03 +00:00
|
|
|
return ClientKeyFromCacheKey(*(mCacheEntry->Key()), result);
|
2001-02-23 13:18:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-03-01 02:25:07 +00:00
|
|
|
nsCacheEntryDescriptor::GetFetchCount(PRInt32 *result)
|
2001-02-23 13:18:01 +00:00
|
|
|
{
|
2001-03-01 02:25:07 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-02-28 00:06:13 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2001-03-01 02:25:07 +00:00
|
|
|
*result = mCacheEntry->FetchCount();
|
2001-02-23 13:18:01 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-02-28 04:10:43 +00:00
|
|
|
|
2001-02-23 13:18:01 +00:00
|
|
|
NS_IMETHODIMP
|
2001-03-14 03:54:05 +00:00
|
|
|
nsCacheEntryDescriptor::GetLastFetched(PRUint32 *result)
|
2001-02-23 13:18:01 +00:00
|
|
|
{
|
2001-03-01 02:25:07 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-02-28 00:06:13 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2001-03-14 03:54:05 +00:00
|
|
|
*result = mCacheEntry->LastFetched();
|
2001-02-23 13:18:01 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-02-28 04:10:43 +00:00
|
|
|
|
2001-03-08 05:37:00 +00:00
|
|
|
NS_IMETHODIMP
|
2001-03-14 03:54:05 +00:00
|
|
|
nsCacheEntryDescriptor::GetLastModified(PRUint32 *result)
|
2001-03-08 05:37:00 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-03-08 05:37:00 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2001-03-14 03:54:05 +00:00
|
|
|
*result = mCacheEntry->LastModified();
|
2001-03-08 05:37:00 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-23 13:18:01 +00:00
|
|
|
NS_IMETHODIMP
|
2001-03-14 03:54:05 +00:00
|
|
|
nsCacheEntryDescriptor::GetExpirationTime(PRUint32 *result)
|
2001-02-23 13:18:01 +00:00
|
|
|
{
|
2001-03-01 02:25:07 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-02-28 00:06:13 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2001-03-14 03:54:05 +00:00
|
|
|
*result = mCacheEntry->ExpirationTime();
|
2001-02-23 13:18:01 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-02-28 04:10:43 +00:00
|
|
|
|
2001-02-23 13:18:01 +00:00
|
|
|
NS_IMETHODIMP
|
2001-03-14 03:54:05 +00:00
|
|
|
nsCacheEntryDescriptor::SetExpirationTime(PRUint32 expirationTime)
|
2001-02-23 13:18:01 +00:00
|
|
|
{
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-02-28 00:06:13 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2001-03-14 03:54:05 +00:00
|
|
|
mCacheEntry->SetExpirationTime(expirationTime);
|
2001-03-29 05:54:58 +00:00
|
|
|
mCacheEntry->MarkEntryDirty();
|
2001-02-23 13:18:01 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-01 02:25:07 +00:00
|
|
|
NS_IMETHODIMP nsCacheEntryDescriptor::IsStreamBased(PRBool *result)
|
2001-02-23 13:18:01 +00:00
|
|
|
{
|
2001-03-01 02:25:07 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-02-28 00:06:13 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2002-08-07 01:13:29 +00:00
|
|
|
*result = mCacheEntry->IsStreamData();
|
2001-02-23 13:18:01 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-09-07 22:39:28 +00:00
|
|
|
NS_IMETHODIMP nsCacheEntryDescriptor::GetPredictedDataSize(PRInt64 *result)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
|
|
|
nsCacheServiceAutoLock lock;
|
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
|
|
|
*result = mCacheEntry->PredictedDataSize();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsCacheEntryDescriptor::SetPredictedDataSize(PRInt64
|
|
|
|
predictedSize)
|
|
|
|
{
|
|
|
|
nsCacheServiceAutoLock lock;
|
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
|
|
|
mCacheEntry->SetPredictedDataSize(predictedSize);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-02-26 14:45:45 +00:00
|
|
|
|
2001-03-01 02:25:07 +00:00
|
|
|
NS_IMETHODIMP nsCacheEntryDescriptor::GetDataSize(PRUint32 *result)
|
2001-02-26 14:45:45 +00:00
|
|
|
{
|
2001-03-01 02:25:07 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-02-28 00:06:13 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2001-03-01 02:25:07 +00:00
|
|
|
*result = mCacheEntry->DataSize();
|
2001-02-28 00:06:13 +00:00
|
|
|
return NS_OK;
|
2001-02-26 14:45:45 +00:00
|
|
|
}
|
2001-02-28 04:10:43 +00:00
|
|
|
|
|
|
|
|
2001-03-01 19:52:06 +00:00
|
|
|
nsresult
|
|
|
|
nsCacheEntryDescriptor::RequestDataSizeChange(PRInt32 deltaSize)
|
|
|
|
{
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-09-20 01:09:01 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2001-03-01 19:52:06 +00:00
|
|
|
nsresult rv;
|
2002-08-07 01:13:29 +00:00
|
|
|
rv = nsCacheService::OnDataSizeChange(mCacheEntry, deltaSize);
|
2001-03-01 19:52:06 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2001-03-04 00:11:30 +00:00
|
|
|
// XXX review for signed/unsigned math errors
|
2001-03-01 19:52:06 +00:00
|
|
|
PRUint32 newDataSize = mCacheEntry->DataSize() + deltaSize;
|
|
|
|
mCacheEntry->SetDataSize(newDataSize);
|
2001-03-29 05:54:58 +00:00
|
|
|
mCacheEntry->TouchData();
|
2001-03-01 19:52:06 +00:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCacheEntryDescriptor::SetDataSize(PRUint32 dataSize)
|
2001-02-26 14:45:45 +00:00
|
|
|
{
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-02-28 00:06:13 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2001-03-04 00:11:30 +00:00
|
|
|
// XXX review for signed/unsigned math errors
|
2001-03-01 05:01:43 +00:00
|
|
|
PRInt32 deltaSize = dataSize - mCacheEntry->DataSize();
|
|
|
|
|
2002-08-07 01:13:29 +00:00
|
|
|
nsresult rv;
|
|
|
|
rv = nsCacheService::OnDataSizeChange(mCacheEntry, deltaSize);
|
|
|
|
// this had better be NS_OK, this call instance is advisory for memory cache objects
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
// XXX review for signed/unsigned math errors
|
|
|
|
PRUint32 newDataSize = mCacheEntry->DataSize() + deltaSize;
|
|
|
|
mCacheEntry->SetDataSize(newDataSize);
|
|
|
|
mCacheEntry->TouchData();
|
|
|
|
} else {
|
|
|
|
NS_WARNING("failed SetDataSize() on memory cache object!");
|
|
|
|
}
|
|
|
|
|
2001-03-01 19:52:06 +00:00
|
|
|
return rv;
|
2001-02-26 14:45:45 +00:00
|
|
|
}
|
|
|
|
|
2001-02-28 04:10:43 +00:00
|
|
|
|
2001-03-01 19:52:06 +00:00
|
|
|
NS_IMETHODIMP
|
2003-01-18 02:15:14 +00:00
|
|
|
nsCacheEntryDescriptor::OpenInputStream(PRUint32 offset, nsIInputStream ** result)
|
2001-02-26 14:45:45 +00:00
|
|
|
{
|
2001-03-01 02:25:07 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
2001-02-28 00:06:13 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
{
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2003-01-18 02:15:14 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
if (!mCacheEntry->IsStreamData()) return NS_ERROR_CACHE_DATA_IS_NOT_STREAM;
|
|
|
|
|
|
|
|
// ensure valid permissions
|
|
|
|
if (!(mAccessGranted & nsICache::ACCESS_READ))
|
|
|
|
return NS_ERROR_CACHE_READ_ACCESS_DENIED;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsInputStreamWrapper* cacheInput =
|
|
|
|
new nsInputStreamWrapper(this, offset);
|
|
|
|
if (!cacheInput) return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
NS_ADDREF(*result = cacheInput);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCacheEntryDescriptor::OpenOutputStream(PRUint32 offset, nsIOutputStream ** result)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
|
|
|
|
|
|
|
{
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2003-01-18 02:15:14 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
if (!mCacheEntry->IsStreamData()) return NS_ERROR_CACHE_DATA_IS_NOT_STREAM;
|
|
|
|
|
|
|
|
// ensure valid permissions
|
|
|
|
if (!(mAccessGranted & nsICache::ACCESS_WRITE))
|
|
|
|
return NS_ERROR_CACHE_WRITE_ACCESS_DENIED;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsOutputStreamWrapper* cacheOutput =
|
|
|
|
new nsOutputStreamWrapper(this, offset);
|
|
|
|
if (!cacheOutput) return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
NS_ADDREF(*result = cacheOutput);
|
2001-03-01 02:25:07 +00:00
|
|
|
return NS_OK;
|
2001-02-26 14:45:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-23 13:18:01 +00:00
|
|
|
NS_IMETHODIMP
|
2001-03-01 02:25:07 +00:00
|
|
|
nsCacheEntryDescriptor::GetCacheElement(nsISupports ** result)
|
2001-02-23 13:18:01 +00:00
|
|
|
{
|
2001-03-01 02:25:07 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-02-28 00:06:13 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
if (mCacheEntry->IsStreamData()) return NS_ERROR_CACHE_DATA_IS_STREAM;
|
|
|
|
|
2004-10-20 05:00:23 +00:00
|
|
|
NS_IF_ADDREF(*result = mCacheEntry->Data());
|
|
|
|
return NS_OK;
|
2001-02-23 13:18:01 +00:00
|
|
|
}
|
|
|
|
|
2001-02-28 04:10:43 +00:00
|
|
|
|
2001-02-23 13:18:01 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCacheEntryDescriptor::SetCacheElement(nsISupports * cacheElement)
|
|
|
|
{
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-02-28 00:06:13 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
if (mCacheEntry->IsStreamData()) return NS_ERROR_CACHE_DATA_IS_STREAM;
|
|
|
|
|
2002-08-07 01:13:29 +00:00
|
|
|
return nsCacheService::SetCacheElement(mCacheEntry, cacheElement);
|
2001-02-23 13:18:01 +00:00
|
|
|
}
|
|
|
|
|
2001-02-28 04:10:43 +00:00
|
|
|
|
2001-02-23 13:18:01 +00:00
|
|
|
NS_IMETHODIMP
|
2001-03-01 02:25:07 +00:00
|
|
|
nsCacheEntryDescriptor::GetAccessGranted(nsCacheAccessMode *result)
|
2001-02-23 13:18:01 +00:00
|
|
|
{
|
2001-03-01 02:25:07 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
|
|
|
*result = mAccessGranted;
|
2001-02-23 13:18:01 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-02-28 04:10:43 +00:00
|
|
|
|
2001-02-23 13:18:01 +00:00
|
|
|
NS_IMETHODIMP
|
2001-03-01 02:25:07 +00:00
|
|
|
nsCacheEntryDescriptor::GetStoragePolicy(nsCacheStoragePolicy *result)
|
2001-02-23 13:18:01 +00:00
|
|
|
{
|
2001-03-01 02:25:07 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-02-28 00:06:13 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2007-12-07 22:07:03 +00:00
|
|
|
*result = mCacheEntry->StoragePolicy();
|
|
|
|
return NS_OK;
|
2001-02-23 13:18:01 +00:00
|
|
|
}
|
|
|
|
|
2001-02-28 04:10:43 +00:00
|
|
|
|
2001-02-23 13:18:01 +00:00
|
|
|
NS_IMETHODIMP
|
2001-02-24 01:02:37 +00:00
|
|
|
nsCacheEntryDescriptor::SetStoragePolicy(nsCacheStoragePolicy policy)
|
2001-02-23 13:18:01 +00:00
|
|
|
{
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-02-28 00:06:13 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
2001-03-20 22:42:03 +00:00
|
|
|
// XXX validate policy against session?
|
2002-02-19 05:29:49 +00:00
|
|
|
|
|
|
|
PRBool storageEnabled = PR_FALSE;
|
2002-08-07 01:13:29 +00:00
|
|
|
storageEnabled = nsCacheService::IsStorageEnabledForPolicy_Locked(policy);
|
2002-02-19 05:29:49 +00:00
|
|
|
if (!storageEnabled) return NS_ERROR_FAILURE;
|
2007-12-07 22:07:03 +00:00
|
|
|
|
|
|
|
// Don't change the storage policy of entries we can't write
|
2007-12-07 22:18:13 +00:00
|
|
|
if (!(mAccessGranted & nsICache::ACCESS_WRITE))
|
2007-12-07 22:07:03 +00:00
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
2002-02-19 05:29:49 +00:00
|
|
|
|
2007-12-07 22:07:03 +00:00
|
|
|
// Don't allow a cache entry to move from memory-only to anything else
|
|
|
|
if (mCacheEntry->StoragePolicy() == nsICache::STORE_IN_MEMORY &&
|
|
|
|
policy != nsICache::STORE_IN_MEMORY)
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2001-03-20 22:42:03 +00:00
|
|
|
mCacheEntry->SetStoragePolicy(policy);
|
2001-03-29 05:54:58 +00:00
|
|
|
mCacheEntry->MarkEntryDirty();
|
2001-03-20 22:42:03 +00:00
|
|
|
return NS_OK;
|
2001-02-23 13:18:01 +00:00
|
|
|
}
|
|
|
|
|
2001-03-07 09:27:36 +00:00
|
|
|
|
2001-03-07 01:40:41 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCacheEntryDescriptor::GetFile(nsIFile ** result)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-03-07 01:40:41 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
2002-08-07 01:13:29 +00:00
|
|
|
|
|
|
|
return nsCacheService::GetFileForEntry(mCacheEntry, result);
|
2001-03-07 01:40:41 +00:00
|
|
|
}
|
2001-02-28 04:10:43 +00:00
|
|
|
|
2001-03-07 09:27:36 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCacheEntryDescriptor::GetSecurityInfo(nsISupports ** result)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-03-07 09:27:36 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2007-11-30 18:05:54 +00:00
|
|
|
*result = mCacheEntry->SecurityInfo();
|
|
|
|
NS_IF_ADDREF(*result);
|
|
|
|
return NS_OK;
|
2001-03-07 09:27:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCacheEntryDescriptor::SetSecurityInfo(nsISupports * securityInfo)
|
|
|
|
{
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-03-07 09:27:36 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
|
|
|
mCacheEntry->SetSecurityInfo(securityInfo);
|
2001-03-29 05:54:58 +00:00
|
|
|
mCacheEntry->MarkEntryDirty();
|
2001-03-07 09:27:36 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-23 13:18:01 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCacheEntryDescriptor::Doom()
|
|
|
|
{
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-02-28 00:06:13 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2002-08-07 01:13:29 +00:00
|
|
|
return nsCacheService::DoomEntry(mCacheEntry);
|
2001-02-23 13:18:01 +00:00
|
|
|
}
|
|
|
|
|
2001-02-28 04:10:43 +00:00
|
|
|
|
2001-02-23 13:18:01 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCacheEntryDescriptor::DoomAndFailPendingRequests(nsresult status)
|
|
|
|
{
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-02-28 00:06:13 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2001-02-23 13:18:01 +00:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCacheEntryDescriptor::MarkValid()
|
|
|
|
{
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-03-06 04:01:00 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2002-08-07 01:13:29 +00:00
|
|
|
nsresult rv = nsCacheService::ValidateEntry(mCacheEntry);
|
2001-03-06 04:01:00 +00:00
|
|
|
return rv;
|
2001-02-23 13:18:01 +00:00
|
|
|
}
|
|
|
|
|
2001-02-28 04:10:43 +00:00
|
|
|
|
2001-02-27 05:35:53 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsCacheEntryDescriptor::Close()
|
|
|
|
{
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-02-28 00:06:13 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2005-03-18 08:46:54 +00:00
|
|
|
// XXX perhaps closing descriptors should clear/sever transports
|
2002-08-07 01:13:29 +00:00
|
|
|
|
2001-02-28 00:06:13 +00:00
|
|
|
// tell nsCacheService we're going away
|
2002-08-07 01:13:29 +00:00
|
|
|
nsCacheService::CloseDescriptor(this);
|
|
|
|
NS_ASSERTION(mCacheEntry == nsnull, "mCacheEntry not null");
|
2001-02-28 00:06:13 +00:00
|
|
|
|
2001-02-27 05:35:53 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-23 13:18:01 +00:00
|
|
|
NS_IMETHODIMP
|
2006-03-09 20:02:54 +00:00
|
|
|
nsCacheEntryDescriptor::GetMetaDataElement(const char *key, char **result)
|
2001-02-23 13:18:01 +00:00
|
|
|
{
|
2006-03-09 20:02:54 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(key);
|
2003-03-25 15:20:10 +00:00
|
|
|
*result = nsnull;
|
|
|
|
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2006-03-09 20:02:54 +00:00
|
|
|
NS_ENSURE_TRUE(mCacheEntry, NS_ERROR_NOT_AVAILABLE);
|
2001-02-28 00:06:13 +00:00
|
|
|
|
2003-03-25 15:20:10 +00:00
|
|
|
const char *value;
|
2001-03-20 22:42:03 +00:00
|
|
|
|
2003-03-25 15:20:10 +00:00
|
|
|
value = mCacheEntry->GetMetaDataElement(key);
|
2001-03-20 22:42:03 +00:00
|
|
|
if (!value) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2007-05-14 20:09:20 +00:00
|
|
|
*result = NS_strdup(value);
|
2001-03-20 22:42:03 +00:00
|
|
|
if (!*result) return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
return NS_OK;
|
2001-02-23 13:18:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-03-02 01:51:41 +00:00
|
|
|
nsCacheEntryDescriptor::SetMetaDataElement(const char *key, const char *value)
|
2001-02-23 13:18:01 +00:00
|
|
|
{
|
2006-03-09 20:02:54 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(key);
|
2001-02-28 00:06:13 +00:00
|
|
|
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2006-03-09 20:02:54 +00:00
|
|
|
NS_ENSURE_TRUE(mCacheEntry, NS_ERROR_NOT_AVAILABLE);
|
2003-03-25 15:20:10 +00:00
|
|
|
|
2001-03-04 00:11:30 +00:00
|
|
|
// XXX allow null value, for clearing key?
|
2003-03-25 15:20:10 +00:00
|
|
|
|
|
|
|
nsresult rv = mCacheEntry->SetMetaDataElement(key, value);
|
2001-03-29 05:54:58 +00:00
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
mCacheEntry->TouchMetaData();
|
2001-02-23 13:18:01 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-04-04 03:30:45 +00:00
|
|
|
nsCacheEntryDescriptor::VisitMetaData(nsICacheMetaDataVisitor * visitor)
|
2001-02-23 13:18:01 +00:00
|
|
|
{
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock; // XXX check callers, we're calling out of module
|
2001-04-04 03:30:45 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(visitor);
|
2001-02-28 00:06:13 +00:00
|
|
|
if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2001-04-04 03:30:45 +00:00
|
|
|
return mCacheEntry->VisitMetaDataElements(visitor);
|
2001-02-23 13:18:01 +00:00
|
|
|
}
|
|
|
|
|
2001-02-28 04:10:43 +00:00
|
|
|
|
2001-03-07 09:27:36 +00:00
|
|
|
/******************************************************************************
|
2003-01-18 02:15:14 +00:00
|
|
|
* nsCacheInputStream - a wrapper for nsIInputstream keeps the cache entry
|
|
|
|
* open while referenced.
|
2001-03-07 09:27:36 +00:00
|
|
|
******************************************************************************/
|
2001-02-28 00:06:13 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
NS_IMPL_THREADSAFE_ISUPPORTS1(nsCacheEntryDescriptor::nsInputStreamWrapper,
|
|
|
|
nsIInputStream)
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
nsresult nsCacheEntryDescriptor::
|
|
|
|
nsInputStreamWrapper::LazyInit()
|
|
|
|
{
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-02-28 04:10:43 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
nsCacheAccessMode mode;
|
|
|
|
nsresult rv = mDescriptor->GetAccessGranted(&mode);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
2001-02-28 00:06:13 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
NS_ENSURE_TRUE(mode & nsICache::ACCESS_READ, NS_ERROR_UNEXPECTED);
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
nsCacheEntry* cacheEntry = mDescriptor->CacheEntry();
|
|
|
|
if (!cacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
rv = nsCacheService::OpenInputStreamForEntry(cacheEntry, mode,
|
|
|
|
mStartOffset,
|
|
|
|
getter_AddRefs(mInput));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
mInitialized = PR_TRUE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2001-03-07 09:27:36 +00:00
|
|
|
nsresult nsCacheEntryDescriptor::
|
2003-01-18 02:15:14 +00:00
|
|
|
nsInputStreamWrapper::Close()
|
2001-02-23 13:18:01 +00:00
|
|
|
{
|
2003-01-18 02:15:14 +00:00
|
|
|
nsresult rv = EnsureInit();
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
2001-03-07 09:27:36 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
return mInput->Close();
|
|
|
|
}
|
2001-03-07 09:27:36 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
nsresult nsCacheEntryDescriptor::
|
|
|
|
nsInputStreamWrapper::Available(PRUint32 *avail)
|
|
|
|
{
|
|
|
|
nsresult rv = EnsureInit();
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
2001-06-25 06:22:44 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
return mInput->Available(avail);
|
2001-02-23 13:18:01 +00:00
|
|
|
}
|
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
nsresult nsCacheEntryDescriptor::
|
|
|
|
nsInputStreamWrapper::Read(char *buf, PRUint32 count, PRUint32 *countRead)
|
2001-03-01 19:24:10 +00:00
|
|
|
{
|
2003-01-18 02:15:14 +00:00
|
|
|
nsresult rv = EnsureInit();
|
2001-03-01 08:29:43 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2001-03-07 09:27:36 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
return mInput->Read(buf, count, countRead);
|
2001-03-01 08:29:43 +00:00
|
|
|
}
|
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
nsresult nsCacheEntryDescriptor::
|
|
|
|
nsInputStreamWrapper::ReadSegments(nsWriteSegmentFun writer, void *closure,
|
|
|
|
PRUint32 count, PRUint32 *countRead)
|
2001-03-01 08:29:43 +00:00
|
|
|
{
|
2005-02-18 18:39:53 +00:00
|
|
|
// cache stream not buffered
|
2001-03-07 09:27:36 +00:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2001-03-01 08:29:43 +00:00
|
|
|
}
|
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
nsresult nsCacheEntryDescriptor::
|
|
|
|
nsInputStreamWrapper::IsNonBlocking(PRBool *result)
|
2001-03-01 08:29:43 +00:00
|
|
|
{
|
2003-01-18 02:15:14 +00:00
|
|
|
// cache streams will never return NS_BASE_STREAM_WOULD_BLOCK
|
|
|
|
*result = PR_FALSE;
|
2001-06-25 06:22:44 +00:00
|
|
|
return NS_OK;
|
2001-03-01 08:29:43 +00:00
|
|
|
}
|
|
|
|
|
2001-03-07 09:27:36 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* nsCacheOutputStream - a wrapper for nsIOutputstream to track the amount of
|
|
|
|
* data written to a cache entry.
|
|
|
|
* - also keeps the cache entry open while referenced.
|
|
|
|
******************************************************************************/
|
2001-03-01 08:29:43 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
NS_IMPL_THREADSAFE_ISUPPORTS1(nsCacheEntryDescriptor::nsOutputStreamWrapper,
|
|
|
|
nsIOutputStream)
|
2001-03-01 19:52:06 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
nsresult nsCacheEntryDescriptor::
|
|
|
|
nsOutputStreamWrapper::LazyInit()
|
2001-03-01 19:24:10 +00:00
|
|
|
{
|
2006-06-27 23:13:48 +00:00
|
|
|
nsCacheServiceAutoLock lock;
|
2001-03-07 09:27:36 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
nsCacheAccessMode mode;
|
|
|
|
nsresult rv = mDescriptor->GetAccessGranted(&mode);
|
2001-03-01 19:24:10 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
NS_ENSURE_TRUE(mode & nsICache::ACCESS_WRITE, NS_ERROR_UNEXPECTED);
|
2001-03-01 19:52:06 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
nsCacheEntry* cacheEntry = mDescriptor->CacheEntry();
|
|
|
|
if (!cacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
2001-03-01 08:29:43 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
rv = nsCacheService::OpenOutputStreamForEntry(cacheEntry, mode, mStartOffset,
|
|
|
|
getter_AddRefs(mOutput));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
2001-03-01 08:29:43 +00:00
|
|
|
|
2010-12-29 01:25:14 +00:00
|
|
|
mDescriptor->mOutput = mOutput;
|
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
nsCacheDevice* device = cacheEntry->CacheDevice();
|
|
|
|
if (!device) return NS_ERROR_NOT_AVAILABLE;
|
2001-03-01 19:24:10 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
// the entry has been truncated to mStartOffset bytes, inform the device.
|
|
|
|
PRInt32 size = cacheEntry->DataSize();
|
|
|
|
rv = device->OnDataSizeChange(cacheEntry, mStartOffset - size);
|
2001-05-08 00:07:44 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2001-03-07 09:27:36 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
cacheEntry->SetDataSize(mStartOffset);
|
2001-03-07 09:27:36 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
mInitialized = PR_TRUE;
|
|
|
|
return NS_OK;
|
2001-02-23 13:18:01 +00:00
|
|
|
}
|
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
nsresult nsCacheEntryDescriptor::
|
|
|
|
nsOutputStreamWrapper::OnWrite(PRUint32 count)
|
|
|
|
{
|
2003-10-09 01:54:07 +00:00
|
|
|
if (count > PR_INT32_MAX) return NS_ERROR_UNEXPECTED;
|
2003-01-18 02:15:14 +00:00
|
|
|
return mDescriptor->RequestDataSizeChange((PRInt32)count);
|
|
|
|
}
|
2001-02-23 13:18:01 +00:00
|
|
|
|
2001-03-07 09:27:36 +00:00
|
|
|
NS_IMETHODIMP nsCacheEntryDescriptor::
|
2003-01-18 02:15:14 +00:00
|
|
|
nsOutputStreamWrapper::Close()
|
|
|
|
{
|
|
|
|
nsresult rv = EnsureInit();
|
2001-03-07 09:27:36 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
return mOutput->Close();
|
|
|
|
}
|
2001-03-07 09:27:36 +00:00
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
NS_IMETHODIMP nsCacheEntryDescriptor::
|
|
|
|
nsOutputStreamWrapper::Flush()
|
2001-03-07 09:27:36 +00:00
|
|
|
{
|
2003-01-18 02:15:14 +00:00
|
|
|
nsresult rv = EnsureInit();
|
2001-03-07 09:27:36 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
return mOutput->Flush();
|
2001-03-07 09:27:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsCacheEntryDescriptor::
|
|
|
|
nsOutputStreamWrapper::Write(const char * buf,
|
|
|
|
PRUint32 count,
|
|
|
|
PRUint32 * result)
|
|
|
|
{
|
2003-01-18 02:15:14 +00:00
|
|
|
nsresult rv = EnsureInit();
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
rv = OnWrite(count);
|
2001-03-07 09:27:36 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2003-01-18 02:15:14 +00:00
|
|
|
|
2001-03-07 09:27:36 +00:00
|
|
|
return mOutput->Write(buf, count, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsCacheEntryDescriptor::
|
|
|
|
nsOutputStreamWrapper::WriteFrom(nsIInputStream * inStr,
|
|
|
|
PRUint32 count,
|
|
|
|
PRUint32 * result)
|
|
|
|
{
|
2003-01-18 02:15:14 +00:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2001-03-07 09:27:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsCacheEntryDescriptor::
|
|
|
|
nsOutputStreamWrapper::WriteSegments(nsReadSegmentFun reader,
|
2003-01-18 02:15:14 +00:00
|
|
|
void * closure,
|
|
|
|
PRUint32 count,
|
|
|
|
PRUint32 * result)
|
2001-03-07 09:27:36 +00:00
|
|
|
{
|
2003-01-18 02:15:14 +00:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2001-03-07 09:27:36 +00:00
|
|
|
}
|
|
|
|
|
2003-01-18 02:15:14 +00:00
|
|
|
NS_IMETHODIMP nsCacheEntryDescriptor::
|
|
|
|
nsOutputStreamWrapper::IsNonBlocking(PRBool *result)
|
2001-03-07 09:27:36 +00:00
|
|
|
{
|
2003-01-18 02:15:14 +00:00
|
|
|
// cache streams will never return NS_BASE_STREAM_WOULD_BLOCK
|
|
|
|
*result = PR_FALSE;
|
|
|
|
return NS_OK;
|
2001-03-07 09:27:36 +00:00
|
|
|
}
|