summaryrefslogtreecommitdiffstats
path: root/netwerk/base/nsIDivertableChannel.idl
blob: 4c28ca7dcabea60c737fdad206e149cbaa7372fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

%{C++
namespace mozilla {
namespace net {
class ChannelDiverterChild;
}
}
%}

[ptr] native ChannelDiverterChild(mozilla::net::ChannelDiverterChild);

interface nsIStreamListener;

/**
 * A channel implementing this interface allows diverting from an
 * nsIStreamListener in the child process to one in the parent.
 */
[uuid(7a9bf52d-f828-4b31-b8df-b40fdd37d007)]
interface nsIDivertableChannel : nsISupports
{
  /**
   * CHILD ONLY.
   * Called by Necko client in child process during OnStartRequest to divert
   * nsIStreamListener and nsIRequest callbacks to the parent process.
   *
   * The process should look like the following:
   *
   * 1) divertToParent is called in the child process.  It can only be called
   *    during OnStartRequest().
   *
   * 2) The ChannelDiverterChild that is returned is an IPDL object. It should
   *    be passed via some other IPDL method of the client's choosing to the
   *    parent.  On the parent the ChannelDiverterParent's divertTo() function
   *    should be called with an nsIStreamListener that will then receive the
   *    OnStartRequest/OnDataAvailable/OnStopRequest for the channel.  The
   *    ChannelDiverterParent can then be deleted (which will also destroy the
   *    ChannelDiverterChild in the child).
   *
   *    After divertToParent() has been called, NO further function calls
   *    should be made on the channel.  It is a dead object for all purposes.
   *    The reference that the channel holds to the listener in the child is
   *    released is once OnStartRequest completes, and no other
   *    nsIStreamListener calls (OnDataAvailable, OnStopRequest) will be made
   *    to it.
   *
   * @return ChannelDiverterChild IPDL actor to be passed to parent process by
   *         client IPDL message, e.g. PClient.DivertUsing(PDiverterChild).
   *
   * @throws exception if the channel was canceled early. Throws status code of
   *         canceled channel.
   */
  ChannelDiverterChild divertToParent();

  /**
   * nsUnknownDecoder delays calling OnStartRequest until it gets enough data
   * to decide about the content type (until OnDataAvaiable is called). In a
   * OnStartRequest DivertToParent can be called but some OnDataAvailables are
   * already called and therefore can not be diverted to parent.
   *
   * nsUnknownDecoder will call UnknownDecoderInvolvedKeepData in its
   * OnStartRequest function and when it calls OnStartRequest of the next
   * listener it will call UnknownDecoderInvolvedOnStartRequestCalled. In this
   * function Child process will decide to discarge data if it is not diverting
   * to parent or keep them if it is diverting to parent.
   */
  void unknownDecoderInvolvedKeepData();

  void unknownDecoderInvolvedOnStartRequestCalled();

  readonly attribute bool divertingToParent;
};