netwerk/base/src/ChannelDiverterParent.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial