1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef _mozilla_dom_fetch_FetchStreamUtils_h
6 #define _mozilla_dom_fetch_FetchStreamUtils_h
8 #include "mozilla/AlreadyAddRefed.h"
9 #include "mozilla/NotNull.h"
10 #include "mozilla/dom/FetchTypes.h"
12 #include "nsIInputStream.h"
19 class PBackgroundParent
;
24 // Convert a ParentToParentStream received over IPC to an nsIInputStream. Can
25 // only be called in the parent process.
26 NotNull
<nsCOMPtr
<nsIInputStream
>> ToInputStream(
27 const ParentToParentStream
& aStream
);
29 // Convert a ParentToChildStream received over IPC to an nsIInputStream. Can
30 // only be called in a content process.
31 NotNull
<nsCOMPtr
<nsIInputStream
>> ToInputStream(
32 const ParentToChildStream
& aStream
);
34 // Serialize an nsIInputStream for IPC inside the parent process. Can only be
35 // called in the parent process.
36 ParentToParentStream
ToParentToParentStream(
37 const NotNull
<nsCOMPtr
<nsIInputStream
>>& aStream
, int64_t aStreamSize
);
39 // Serialize an nsIInputStream for IPC from the parent process to a content
40 // process. Can only be called in the parent process.
41 ParentToChildStream
ToParentToChildStream(
42 const NotNull
<nsCOMPtr
<nsIInputStream
>>& aStream
, int64_t aStreamSize
,
43 NotNull
<mozilla::ipc::PBackgroundParent
*> aBackgroundParent
,
44 bool aSerializeAsLazy
= true);
46 // Convert a ParentToParentStream to a ParentToChildStream. Can only be called
47 // in the parent process.
48 ParentToChildStream
ToParentToChildStream(
49 const ParentToParentStream
& aStream
, int64_t aStreamSize
,
50 NotNull
<mozilla::ipc::PBackgroundParent
*> aBackgroundParent
);
54 } // namespace mozilla
56 #endif // _mozilla_dom_fetch_FetchStreamUtils_h