AltDataOutputStreamChild.h (1715B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set sw=2 ts=8 et tw=80 : */ 3 4 /* This Source Code Form is subject to the terms of the Mozilla Public 5 * License, v. 2.0. If a copy of the MPL was not distributed with this 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 7 8 #ifndef mozilla_net_AltDataOutputStreamChild_h 9 #define mozilla_net_AltDataOutputStreamChild_h 10 11 #include "mozilla/net/PAltDataOutputStreamChild.h" 12 #include "nsIAsyncOutputStream.h" 13 14 namespace mozilla { 15 namespace net { 16 17 class AltDataOutputStreamChild : public PAltDataOutputStreamChild, 18 public nsIAsyncOutputStream { 19 public: 20 NS_DECL_ISUPPORTS 21 NS_DECL_NSIASYNCOUTPUTSTREAM 22 NS_DECL_NSIOUTPUTSTREAM 23 explicit AltDataOutputStreamChild(); 24 25 void AddIPDLReference(); 26 void ReleaseIPDLReference(); 27 // Saves an error code which will be reported to the writer on the next call. 28 virtual mozilla::ipc::IPCResult RecvError(const nsresult& err); 29 virtual mozilla::ipc::IPCResult RecvDeleteSelf(); 30 31 private: 32 virtual ~AltDataOutputStreamChild() = default; 33 // Sends data to the parent process in 256k chunks. 34 bool WriteDataInChunks(const nsDependentCSubstring& data); 35 void NotifyListener(); 36 37 bool mIPCOpen; 38 // If there was an error opening the output stream or writing to it on the 39 // parent side, this will be set to the error code. We check it before we 40 // write so we can report an error to the consumer. 41 nsresult mError; 42 43 nsCOMPtr<nsIOutputStreamCallback> mCallback; 44 uint32_t mCallbackFlags; 45 nsCOMPtr<nsIEventTarget> mCallbackTarget; 46 }; 47 48 } // namespace net 49 } // namespace mozilla 50 51 #endif // mozilla_net_AltDataOutputStreamChild_h