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

     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/. */
     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"
    15 namespace mozilla {
    16 namespace net {
    18 ChannelDiverterParent::ChannelDiverterParent()
    19 {
    20 }
    22 ChannelDiverterParent::~ChannelDiverterParent()
    23 {
    24 }
    26 bool
    27 ChannelDiverterParent::Init(const ChannelDiverterArgs& aChannel)
    28 {
    29   switch (aChannel.type()) {
    30   case ChannelDiverterArgs::TPHttpChannelParent:
    31   {
    32     mDivertableChannelParent = static_cast<ADivertableParentChannel*>(
    33       static_cast<HttpChannelParent*>(aChannel.get_PHttpChannelParent()));
    34     break;
    35   }
    36   case ChannelDiverterArgs::TPFTPChannelParent:
    37   {
    38     mDivertableChannelParent = static_cast<ADivertableParentChannel*>(
    39       static_cast<FTPChannelParent*>(aChannel.get_PFTPChannelParent()));
    40     break;
    41   }
    42   default:
    43     NS_NOTREACHED("unknown ChannelDiverterArgs type");
    44     return false;
    45   }
    46   MOZ_ASSERT(mDivertableChannelParent);
    48   nsresult rv = mDivertableChannelParent->SuspendForDiversion();
    49   if (NS_WARN_IF(NS_FAILED(rv))) {
    50     return false;
    51   }
    52   return true;
    53 }
    55 void
    56 ChannelDiverterParent::DivertTo(nsIStreamListener* newListener)
    57 {
    58   MOZ_ASSERT(newListener);
    59   MOZ_ASSERT(mDivertableChannelParent);
    61   mDivertableChannelParent->DivertTo(newListener);
    62 }
    64 } // namespace net
    65 } // namespace mozilla

mercurial