/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// We keep a weak reference to the chunk to not create a reference cycle. The // buffer is referenced only by chunk and handles. Handles are always // destroyed before the chunk so it is guaranteed that mChunk is a valid // pointer for the whole buffer's lifetime.
CacheFileChunk* mChunk; char* mBuf;
uint32_t mBufSize;
uint32_t mDataSize;
uint32_t mReadHandlesCount; bool mWriteHandleExists;
};
class CacheFileChunkHandle { public:
uint32_t DataSize();
uint32_t Offset();
protected:
RefPtr<CacheFileChunkBuffer> mBuf;
};
class CacheFileChunkReadHandle : public CacheFileChunkHandle { public: explicit CacheFileChunkReadHandle(CacheFileChunkBuffer* aBuf);
~CacheFileChunkReadHandle();
constchar* Buf();
};
class CacheFileChunkWriteHandle : public CacheFileChunkHandle { public: explicit CacheFileChunkWriteHandle(CacheFileChunkBuffer* aBuf);
~CacheFileChunkWriteHandle();
Atomic<bool> mActiveChunk; // Is true iff the chunk is in CacheFile::mChunks. // Adding/removing chunk to/from mChunks as well // as changing this member happens under the // CacheFile's lock. bool mIsDirty : 1; bool mDiscardedChunk : 1;
uint32_t mBuffersSize; boolconst mLimitAllocation : 1; // Whether this chunk respects limit for // disk chunks memory usage. boolconst mIsPriority : 1;
// Buffer containing the chunk data. Multiple read handles can access the same // buffer. When write handle is created and some read handle exists a new copy // of the buffer is created. This prevents invalidating the buffer when // CacheFileInputStream::ReadSegments calls the handler outside the lock.
RefPtr<CacheFileChunkBuffer> mBuf;
// We need to keep pointers of the old buffers for memory reporting.
nsTArray<RefPtr<CacheFileChunkBuffer>> mOldBufs;
// Read handle that is used during writing the chunk to the disk.
UniquePtr<CacheFileChunkReadHandle> mWritingStateHandle;
// Buffer that is used to read the chunk from the disk. It is allowed to write // a new data to chunk while we wait for the data from the disk. In this case // this buffer is merged with mBuf in OnDataRead().
RefPtr<CacheFileChunkBuffer> mReadingStateBuf;
CacheHash::Hash16_t mExpectedHash;
RefPtr<CacheFile> mFile; // is null if chunk is cached to // prevent reference cycles
nsCOMPtr<CacheFileChunkListener> mListener;
nsTArray<ChunkListenerItem*> mUpdateListeners;
CacheFileUtils::ValidityMap mValidityMap;
};
} // namespace net
} // namespace mozilla
#endif
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.