Line data Source code
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 :
18 0 : ChannelDiverterParent::ChannelDiverterParent()
19 : {
20 0 : }
21 :
22 0 : ChannelDiverterParent::~ChannelDiverterParent()
23 : {
24 0 : }
25 :
26 : bool
27 0 : ChannelDiverterParent::Init(const ChannelDiverterArgs& aArgs)
28 : {
29 0 : switch (aArgs.type()) {
30 : case ChannelDiverterArgs::THttpChannelDiverterArgs:
31 : {
32 0 : auto httpParent = static_cast<HttpChannelParent*>(
33 0 : aArgs.get_HttpChannelDiverterArgs().mChannelParent());
34 0 : httpParent->SetApplyConversion(aArgs.get_HttpChannelDiverterArgs().mApplyConversion());
35 :
36 : mDivertableChannelParent =
37 0 : static_cast<ADivertableParentChannel*>(httpParent);
38 0 : break;
39 : }
40 : case ChannelDiverterArgs::TPFTPChannelParent:
41 : {
42 : mDivertableChannelParent = static_cast<ADivertableParentChannel*>(
43 0 : static_cast<FTPChannelParent*>(aArgs.get_PFTPChannelParent()));
44 0 : break;
45 : }
46 : default:
47 0 : NS_NOTREACHED("unknown ChannelDiverterArgs type");
48 0 : return false;
49 : }
50 0 : MOZ_ASSERT(mDivertableChannelParent);
51 :
52 0 : nsresult rv = mDivertableChannelParent->SuspendForDiversion();
53 0 : if (NS_WARN_IF(NS_FAILED(rv))) {
54 0 : return false;
55 : }
56 0 : return true;
57 : }
58 :
59 : void
60 0 : ChannelDiverterParent::DivertTo(nsIStreamListener* newListener)
61 : {
62 0 : MOZ_ASSERT(newListener);
63 0 : MOZ_ASSERT(mDivertableChannelParent);
64 :
65 0 : mDivertableChannelParent->DivertTo(newListener);
66 0 : }
67 :
68 : void
69 0 : ChannelDiverterParent::ActorDestroy(ActorDestroyReason aWhy)
70 : {
71 : // Implement me! Bug 1005179
72 0 : }
73 :
74 : } // namespace net
75 : } // namespace mozilla
|