зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1759569 - Retain nsIInputStreamLength through NS_CloneInputStream, r=asuth
This will help in bug 1754004 as in some cases we will want to clone a DataPipe, which is non-cloneable, and without this change length information would be lost. In the future it might be worth making a more generic mechanism for efficiently cloning wrapper input streams with a fallback rather than hard-coding this interface. Differential Revision: https://phabricator.services.mozilla.com/D141035
This commit is contained in:
Родитель
5bf606fa92
Коммит
7bbc6e365f
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/InputStreamLengthWrapper.h"
|
||||
#include "nsIInputStreamLength.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsICloneableInputStream.h"
|
||||
|
@ -870,6 +872,16 @@ nsresult NS_CloneInputStream(nsIInputStream* aSource,
|
|||
return rv;
|
||||
}
|
||||
|
||||
// Propagate length information provided by nsIInputStreamLength. We don't use
|
||||
// InputStreamLengthHelper::GetSyncLength to avoid the risk of blocking when
|
||||
// called off-main-thread.
|
||||
int64_t length = -1;
|
||||
if (nsCOMPtr<nsIInputStreamLength> streamLength = do_QueryInterface(aSource);
|
||||
streamLength && NS_SUCCEEDED(streamLength->Length(&length)) &&
|
||||
length != -1) {
|
||||
reader = new mozilla::InputStreamLengthWrapper(reader.forget(), length);
|
||||
}
|
||||
|
||||
cloneable = do_QueryInterface(reader);
|
||||
MOZ_ASSERT(cloneable && cloneable->GetCloneable());
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче