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/. */ 4 5 #ifndef _mozilla_dom_fetch_FetchStreamUtils_h 6 #define _mozilla_dom_fetch_FetchStreamUtils_h 7 8 #include "mozilla/AlreadyAddRefed.h" 9 #include "mozilla/NotNull.h" 10 #include "mozilla/dom/FetchTypes.h" 11 12 #include "nsIInputStream.h" 13 14 #include <cstdint> 15 16 namespace mozilla { 17 18 namespace ipc { 19 class PBackgroundParent; 20 } 21 22 namespace dom { 23 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); 28 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); 33 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); 38 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 45 // Convert a ParentToParentStream to a ParentToChildStream. Can only be called 46 // in the parent process. 47 ParentToChildStream ToParentToChildStream( 48 const ParentToParentStream& aStream, int64_t aStreamSize, 49 NotNull<mozilla::ipc::PBackgroundParent*> aBackgroundParent); 50 51 } // namespace dom 52 53 } // namespace mozilla 54 55 #endif // _mozilla_dom_fetch_FetchStreamUtils_h 56