ChannelDiverterParent.cpp 2.0 KB

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