nsIDivertableChannel.idl 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 "nsISupports.idl"
  6. %{C++
  7. namespace mozilla {
  8. namespace net {
  9. class ChannelDiverterChild;
  10. }
  11. }
  12. %}
  13. [ptr] native ChannelDiverterChild(mozilla::net::ChannelDiverterChild);
  14. interface nsIStreamListener;
  15. /**
  16. * A channel implementing this interface allows diverting from an
  17. * nsIStreamListener in the child process to one in the parent.
  18. */
  19. [uuid(7a9bf52d-f828-4b31-b8df-b40fdd37d007)]
  20. interface nsIDivertableChannel : nsISupports
  21. {
  22. /**
  23. * CHILD ONLY.
  24. * Called by Necko client in child process during OnStartRequest to divert
  25. * nsIStreamListener and nsIRequest callbacks to the parent process.
  26. *
  27. * The process should look like the following:
  28. *
  29. * 1) divertToParent is called in the child process. It can only be called
  30. * during OnStartRequest().
  31. *
  32. * 2) The ChannelDiverterChild that is returned is an IPDL object. It should
  33. * be passed via some other IPDL method of the client's choosing to the
  34. * parent. On the parent the ChannelDiverterParent's divertTo() function
  35. * should be called with an nsIStreamListener that will then receive the
  36. * OnStartRequest/OnDataAvailable/OnStopRequest for the channel. The
  37. * ChannelDiverterParent can then be deleted (which will also destroy the
  38. * ChannelDiverterChild in the child).
  39. *
  40. * After divertToParent() has been called, NO further function calls
  41. * should be made on the channel. It is a dead object for all purposes.
  42. * The reference that the channel holds to the listener in the child is
  43. * released is once OnStartRequest completes, and no other
  44. * nsIStreamListener calls (OnDataAvailable, OnStopRequest) will be made
  45. * to it.
  46. *
  47. * @return ChannelDiverterChild IPDL actor to be passed to parent process by
  48. * client IPDL message, e.g. PClient.DivertUsing(PDiverterChild).
  49. *
  50. * @throws exception if the channel was canceled early. Throws status code of
  51. * canceled channel.
  52. */
  53. ChannelDiverterChild divertToParent();
  54. /**
  55. * nsUnknownDecoder delays calling OnStartRequest until it gets enough data
  56. * to decide about the content type (until OnDataAvaiable is called). In a
  57. * OnStartRequest DivertToParent can be called but some OnDataAvailables are
  58. * already called and therefore can not be diverted to parent.
  59. *
  60. * nsUnknownDecoder will call UnknownDecoderInvolvedKeepData in its
  61. * OnStartRequest function and when it calls OnStartRequest of the next
  62. * listener it will call UnknownDecoderInvolvedOnStartRequestCalled. In this
  63. * function Child process will decide to discarge data if it is not diverting
  64. * to parent or keep them if it is diverting to parent.
  65. */
  66. void unknownDecoderInvolvedKeepData();
  67. void unknownDecoderInvolvedOnStartRequestCalled();
  68. readonly attribute bool divertingToParent;
  69. };