зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1754004 - Part 5: Only implement nsISeekableStream on nsBufferedStreams if it's implemented by the underlying stream, r=asuth,necko-reviewers,dragana
Previously, nsBufferedStreams would always implement nsISeekableStream, whether or not the underlying stream did, and would only fail when trying to seek. This makes it much more difficult to compensate and correctly transform streams when they need to be seekable. Differential Revision: https://phabricator.services.mozilla.com/D141042
This commit is contained in:
Родитель
edd5cb883a
Коммит
0532988459
|
@ -50,7 +50,14 @@ using mozilla::Some;
|
|||
|
||||
nsBufferedStream::~nsBufferedStream() { Close(); }
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsBufferedStream, nsITellableStream, nsISeekableStream)
|
||||
NS_IMPL_ADDREF(nsBufferedStream)
|
||||
NS_IMPL_RELEASE(nsBufferedStream)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsBufferedStream)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRY(nsITellableStream)
|
||||
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsISeekableStream, mSeekable)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
nsresult nsBufferedStream::Init(nsISupports* aStream, uint32_t bufferSize) {
|
||||
NS_ASSERTION(aStream, "need to supply a stream");
|
||||
|
@ -59,6 +66,8 @@ nsresult nsBufferedStream::Init(nsISupports* aStream, uint32_t bufferSize) {
|
|||
mBufferSize = bufferSize;
|
||||
mBufferStartOffset = 0;
|
||||
mCursor = 0;
|
||||
nsCOMPtr<nsISeekableStream> seekable = do_QueryInterface(mStream);
|
||||
mSeekable = seekable;
|
||||
mBuffer = new (mozilla::fallible) char[bufferSize];
|
||||
if (mBuffer == nullptr) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
|
|
@ -58,6 +58,7 @@ class nsBufferedStream : public nsISeekableStream {
|
|||
|
||||
bool mBufferDisabled{false};
|
||||
bool mEOF{false}; // True if mStream is at EOF
|
||||
bool mSeekable{true};
|
||||
uint8_t mGetBufferCount{0};
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче