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_AltDataOutputStreamParent_h 9 #define mozilla_net_AltDataOutputStreamParent_h 10 11 #include "mozilla/net/PAltDataOutputStreamParent.h" 12 #include "nsIOutputStream.h" 13 NS_IMPL_ISUPPORTS0(AltDataOutputStreamParent)14namespace mozilla { 15 namespace net { 16 17 // Forwards data received from the content process to an output stream. 18 class AltDataOutputStreamParent : public PAltDataOutputStreamParent, 19 public nsISupports { 20 public: 21 NS_DECL_ISUPPORTS 22 23 // Called from NeckoParent::AllocPAltDataOutputStreamParent which also opens 24 // the output stream. 25 // aStream may be null 26 explicit AltDataOutputStreamParent(nsIOutputStream* aStream); 27 28 // Called when data is received from the content process. 29 // We proceed to write that data to the output stream. 30 mozilla::ipc::IPCResult RecvWriteData(const nsCString& data); 31 // Called when AltDataOutputStreamChild::Close() is 32 // Closes and nulls the output stream. 33 mozilla::ipc::IPCResult RecvClose(const nsresult& aStatus); 34 virtual void ActorDestroy(ActorDestroyReason aWhy) override; 35 36 // Sets an error that will be reported to the content process. 37 void SetError(nsresult status) { mStatus = status; } 38 mozilla::ipc::IPCResult RecvDeleteSelf(); 39 40 private: 41 virtual ~AltDataOutputStreamParent(); 42 nsCOMPtr<nsIOutputStream> mOutputStream; 43 // In case any error occurs mStatus will be != NS_OK, and this status code 44 // will be sent to the content process asynchronously. 45 nsresult mStatus; 46 bool mIPCOpen; 47 }; 48 49 } // namespace net 50 } // namespace mozilla 51 52 #endif // mozilla_net_AltDataOutputStreamParent_h 53