Source code

Revision control

Other Tools

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