diff --git a/xpcom/io/nsStreamUtils.cpp b/xpcom/io/nsStreamUtils.cpp index bd3691650003..5f43ce761c11 100644 --- a/xpcom/io/nsStreamUtils.cpp +++ b/xpcom/io/nsStreamUtils.cpp @@ -857,6 +857,17 @@ NS_FillArray(FallibleTArray& aDest, nsIInputStream* aInput, return rv; } +bool +NS_InputStreamIsCloneable(nsIInputStream* aSource) +{ + if (!aSource) { + return false; + } + + nsCOMPtr cloneable = do_QueryInterface(aSource); + return cloneable && cloneable->GetCloneable(); +} + nsresult NS_CloneInputStream(nsIInputStream* aSource, nsIInputStream** aCloneOut, nsIInputStream** aReplacementOut) diff --git a/xpcom/io/nsStreamUtils.h b/xpcom/io/nsStreamUtils.h index fca9978dce92..0faebdfa85c0 100644 --- a/xpcom/io/nsStreamUtils.h +++ b/xpcom/io/nsStreamUtils.h @@ -264,6 +264,12 @@ extern NS_METHOD NS_FillArray(FallibleTArray& aDest, nsIInputStream* aInput, uint32_t aKeep, uint32_t* aNewBytes); +/** + * Return true if the given stream can be directly cloned. + */ +extern bool +NS_InputStreamIsCloneable(nsIInputStream* aSource); + /** * Clone the provided source stream in the most efficient way possible. This * first attempts to QI to nsICloneableInputStream to use Clone(). If that is