зеркало из https://github.com/mozilla/gecko-dev.git
[not part of the build] Added code to update the entry's data size as data is streamed
to the memory cache.
This commit is contained in:
Родитель
f032da92f0
Коммит
986ab2ead9
|
@ -129,7 +129,10 @@ nsMemoryCacheDevice::GetTransportForEntry( nsCacheEntry * entry,
|
|||
if (!*transport)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(*transport);
|
||||
return entry->SetData(*transport);
|
||||
rv = entry->SetData(*transport);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
NS_STATIC_CAST(nsMemoryCacheTransport *, *transport)->SetCacheEntry(entry);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
|
||||
#include "nsMemoryCacheTransport.h"
|
||||
#include "nsCacheEntry.h"
|
||||
#include "nsIProxyObjectManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsCRT.h"
|
||||
|
@ -81,7 +82,8 @@ nsReadFromInputStream(nsIOutputStream *aOutput,
|
|||
//----------------------------------------------------------------------------
|
||||
|
||||
nsMemoryCacheTransport::nsMemoryCacheTransport()
|
||||
: mOutputStream(nsnull)
|
||||
: mCacheEntry(nsnull)
|
||||
, mOutputStream(nsnull)
|
||||
, mSegmentSize(NS_MEMORY_CACHE_SEGMENT_SIZE)
|
||||
, mMaxSize(NS_MEMORY_CACHE_BUFFER_SIZE)
|
||||
, mSegments(nsnull)
|
||||
|
@ -166,6 +168,10 @@ nsMemoryCacheTransport::AddToBytesWritten(PRUint32 aCount)
|
|||
req->Process();
|
||||
}
|
||||
|
||||
// update the data size recorded in the cache entry
|
||||
if (mCacheEntry)
|
||||
mCacheEntry->SetDataSize(mWriteCursor);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -185,7 +191,7 @@ nsresult
|
|||
nsMemoryCacheTransport::ReadRequestCompleted(nsMemoryCacheReadRequest *aReader)
|
||||
{
|
||||
// remove the reader from the list of readers
|
||||
PR_REMOVE_LINK(aReader);
|
||||
PR_REMOVE_AND_INIT_LINK(aReader);
|
||||
aReader->SetTransport(nsnull);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#define NS_MEMORY_CACHE_SEGMENT_SIZE 1024
|
||||
#define NS_MEMORY_CACHE_BUFFER_SIZE 1024 * 1024
|
||||
|
||||
class nsCacheEntry;
|
||||
class nsMemoryCacheReadRequest;
|
||||
class nsMemoryCacheIS; // non-blocking input stream
|
||||
class nsMemoryCacheBS; // blocking stream base class
|
||||
|
@ -59,6 +60,8 @@ public:
|
|||
|
||||
nsresult Init(PRUint32 aBufSegmentSize, PRUint32 aBufMaxSize);
|
||||
|
||||
void SetCacheEntry(nsCacheEntry *e) { mCacheEntry = e; }
|
||||
|
||||
/* private */
|
||||
|
||||
nsresult GetReadSegment(PRUint32 aOffset, char **aPtr, PRUint32 *aCount);
|
||||
|
@ -93,6 +96,8 @@ private:
|
|||
nsSegment *GetNthSegment(PRUint32 aIndex);
|
||||
|
||||
private:
|
||||
nsCacheEntry *mCacheEntry;
|
||||
|
||||
nsMemoryCacheBOS *mOutputStream; // weak ref
|
||||
PRCList mInputStreams; // weak ref to objects
|
||||
PRCList mReadRequests; // weak ref to objects
|
||||
|
|
Загрузка…
Ссылка в новой задаче