1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #include "mozilla/net/ChannelDiverterParent.h" 8 #include "mozilla/net/NeckoChannelParams.h" 9 #include "mozilla/net/HttpChannelParent.h" 10 #include "mozilla/net/FTPChannelParent.h" 11 #include "mozilla/net/PHttpChannelParent.h" 12 #include "mozilla/net/PFTPChannelParent.h" 13 #include "ADivertableParentChannel.h" 14 15 namespace mozilla { 16 namespace net { 17 ChannelDiverterParent()18ChannelDiverterParent::ChannelDiverterParent() {} 19 ~ChannelDiverterParent()20ChannelDiverterParent::~ChannelDiverterParent() {} 21 Init(const ChannelDiverterArgs & aArgs)22bool ChannelDiverterParent::Init(const ChannelDiverterArgs& aArgs) { 23 switch (aArgs.type()) { 24 case ChannelDiverterArgs::THttpChannelDiverterArgs: { 25 auto httpParent = static_cast<HttpChannelParent*>( 26 aArgs.get_HttpChannelDiverterArgs().mChannelParent()); 27 httpParent->SetApplyConversion( 28 aArgs.get_HttpChannelDiverterArgs().mApplyConversion()); 29 30 mDivertableChannelParent = 31 static_cast<ADivertableParentChannel*>(httpParent); 32 break; 33 } 34 case ChannelDiverterArgs::TPFTPChannelParent: { 35 mDivertableChannelParent = static_cast<ADivertableParentChannel*>( 36 static_cast<FTPChannelParent*>(aArgs.get_PFTPChannelParent())); 37 break; 38 } 39 default: 40 NS_NOTREACHED("unknown ChannelDiverterArgs type"); 41 return false; 42 } 43 MOZ_ASSERT(mDivertableChannelParent); 44 45 nsresult rv = mDivertableChannelParent->SuspendForDiversion(); 46 if (NS_WARN_IF(NS_FAILED(rv))) { 47 return false; 48 } 49 return true; 50 } 51 DivertTo(nsIStreamListener * newListener)52void ChannelDiverterParent::DivertTo(nsIStreamListener* newListener) { 53 MOZ_ASSERT(newListener); 54 MOZ_ASSERT(mDivertableChannelParent); 55 56 mDivertableChannelParent->DivertTo(newListener); 57 } 58 ActorDestroy(ActorDestroyReason aWhy)59void ChannelDiverterParent::ActorDestroy(ActorDestroyReason aWhy) { 60 // Implement me! Bug 1005179 61 } 62 63 } // namespace net 64 } // namespace mozilla 65