tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsIHttpActivityObserver.idl (9587B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #include "nsISupports.idl"
      6 
      7 %{ C++
      8 namespace mozilla {
      9 namespace net {
     10 class HttpActivityArgs;
     11 } // namespace net
     12 } // namespace mozilla
     13 %}
     14 
     15 [ref] native HttpActivityArgs(const mozilla::net::HttpActivityArgs);
     16 
     17 /**
     18 * nsIHttpActivityObserver
     19 *
     20 * This interface provides a way for http activities to be reported
     21 * to observers.
     22 */
     23 [scriptable, uuid(412880C8-6C36-48d8-BF8F-84F91F892503)]
     24 interface nsIHttpActivityObserver : nsISupports
     25 {
     26    /**
     27     * observe activity from the http transport
     28     *
     29     * @param aHttpChannel
     30     *        nsISupports interface for the the http channel that
     31     *        generated this activity
     32     * @param aActivityType
     33     *        The value of this aActivityType will be one of
     34     *          ACTIVITY_TYPE_SOCKET_TRANSPORT or
     35     *          ACTIVITY_TYPE_HTTP_TRANSACTION
     36     * @param aActivitySubtype
     37     *        The value of this aActivitySubtype, will be depend
     38     *        on the value of aActivityType. When aActivityType
     39     *        is ACTIVITY_TYPE_SOCKET_TRANSPORT
     40     *          aActivitySubtype will be one of the
     41     *          nsISocketTransport::STATUS_???? values defined in
     42     *          nsISocketTransport.idl
     43     *        OR when aActivityType
     44     *        is ACTIVITY_TYPE_HTTP_TRANSACTION
     45     *          aActivitySubtype will be one of the
     46     *          nsIHttpActivityObserver::ACTIVITY_SUBTYPE_???? values
     47     *          defined below
     48     * @param aTimestamp
     49     *        microseconds past the epoch of Jan 1, 1970
     50     * @param aExtraSizeData
     51     *        Any extra size data optionally available with
     52     *        this activity
     53     * @param aExtraStringData
     54     *        Any extra string data optionally available with
     55     *        this activity
     56     */
     57    [must_use]
     58    void observeActivity(in nsISupports  aHttpChannel,
     59                         in uint32_t     aActivityType,
     60                         in uint32_t     aActivitySubtype,
     61                         in PRTime       aTimestamp,
     62                         in uint64_t     aExtraSizeData,
     63                         in ACString     aExtraStringData);
     64 
     65    /**
     66     * This attribute is true when this interface is active and should
     67     * observe http activities. When false, observeActivity() should not
     68     * be called. It is present for compatibility reasons and should be
     69     * implemented only by nsHttpActivityDistributor.
     70     */
     71    [must_use] readonly attribute boolean isActive;
     72 
     73    /**
     74     * This function is for internal use only. Every time a http transaction
     75     * is created in socket process, we use this function to set the value of
     76     * |isActive|. We need this since the real value of |isActive| is
     77     * only available in parent process.
     78     */
     79    [noscript] void setIsActive(in boolean aActived);
     80 
     81    /**
     82     * This function is used when the real http channel is not available.
     83     * We use the information in |HttpActivityArgs| to get the http channel or
     84     * create a |NullHttpChannel|.
     85     *
     86     * @param aArgs
     87     *        See the definition of |HttpActivityArgs| in PSocketProcess.ipdl.
     88     */
     89    [noscript, must_use]
     90    void observeActivityWithArgs(in HttpActivityArgs aArgs,
     91                                 in uint32_t aActivityType,
     92                                 in uint32_t aActivitySubtype,
     93                                 in PRTime   aTimestamp,
     94                                 in uint64_t aExtraSizeData,
     95                                 in ACString aExtraStringData);
     96 
     97    /**
     98     * This function is for testing only. We use this function to observe the
     99     * activities of HTTP connections. To receive this notification,
    100     * observeConnection should be set to true.
    101     */
    102    [must_use]
    103    void observeConnectionActivity(in ACString     aHost,
    104                                   in int32_t      aPort,
    105                                   in boolean      aSSL,
    106                                   in boolean      aHasECH,
    107                                   in boolean      aIsHttp3,
    108                                   in uint32_t     aActivityType,
    109                                   in uint32_t     aActivitySubtype,
    110                                   in PRTime       aTimestamp,
    111                                   in ACString     aExtraStringData);
    112 
    113    const unsigned long ACTIVITY_TYPE_SOCKET_TRANSPORT                      = 0x0001;
    114    const unsigned long ACTIVITY_TYPE_HTTP_TRANSACTION                      = 0x0002;
    115    const unsigned long ACTIVITY_TYPE_HTTP_CONNECTION                       = 0x0003;
    116 
    117    const unsigned long ACTIVITY_SUBTYPE_REQUEST_HEADER                     = 0x5001;
    118    const unsigned long ACTIVITY_SUBTYPE_REQUEST_BODY_SENT                  = 0x5002;
    119    const unsigned long ACTIVITY_SUBTYPE_RESPONSE_START                     = 0x5003;
    120    const unsigned long ACTIVITY_SUBTYPE_RESPONSE_HEADER                    = 0x5004;
    121    const unsigned long ACTIVITY_SUBTYPE_RESPONSE_COMPLETE                  = 0x5005;
    122    const unsigned long ACTIVITY_SUBTYPE_TRANSACTION_CLOSE                  = 0x5006;
    123    const unsigned long ACTIVITY_SUBTYPE_PROXY_RESPONSE_HEADER              = 0x5007;
    124    const unsigned long ACTIVITY_SUBTYPE_DNSANDSOCKET_CREATED               = 0x5008;
    125    const unsigned long ACTIVITY_SUBTYPE_SPECULATIVE_DNSANDSOCKET_CREATED   = 0x5009;
    126    const unsigned long ACTIVITY_SUBTYPE_ECH_SET                            = 0x500A;
    127    const unsigned long ACTIVITY_SUBTYPE_CONNECTION_CREATED                 = 0x500B;
    128    const unsigned long ACTIVITY_SUBTYPE_EARLYHINT_RESPONSE_HEADER          = 0x500C;
    129 
    130    /**
    131     *  When aActivityType is ACTIVITY_TYPE_SOCKET_TRANSPORT
    132     *  and aActivitySubtype is STATUS_SENDING_TO
    133     *  aExtraSizeData will contain the count of bytes sent
    134     *  There may be more than one of these activities reported
    135     *  for a single http transaction, each aExtraSizeData
    136     *  represents only that portion of the total bytes sent
    137     *
    138     *  When aActivityType is ACTIVITY_TYPE_HTTP_TRANSACTION
    139     *  and aActivitySubtype is ACTIVITY_SUBTYPE_REQUEST_HEADER
    140     *  aExtraStringData will contain the text of the header
    141     *
    142     *  When aActivityType is ACTIVITY_TYPE_HTTP_TRANSACTION
    143     *  and aActivitySubtype is ACTIVITY_SUBTYPE_RESPONSE_HEADER
    144     *  aExtraStringData will contain the text of the header
    145     *
    146     *  When aActivityType is ACTIVITY_TYPE_HTTP_TRANSACTION
    147     *  and aActivitySubtype is ACTIVITY_SUBTYPE_RESPONSE_COMPLETE
    148     *  aExtraSizeData will contain the count of total bytes received
    149     */
    150 };
    151 
    152 %{C++
    153 
    154 #define NS_HTTP_ACTIVITY_TYPE_SOCKET_TRANSPORT    \
    155            nsIHttpActivityObserver::ACTIVITY_TYPE_SOCKET_TRANSPORT
    156 #define NS_HTTP_ACTIVITY_TYPE_HTTP_TRANSACTION    \
    157            nsIHttpActivityObserver::ACTIVITY_TYPE_HTTP_TRANSACTION
    158 #define NS_ACTIVITY_TYPE_HTTP_CONNECTION          \
    159            nsIHttpActivityObserver::ACTIVITY_TYPE_HTTP_CONNECTION
    160 
    161 #define NS_HTTP_ACTIVITY_SUBTYPE_REQUEST_HEADER    \
    162            nsIHttpActivityObserver::ACTIVITY_SUBTYPE_REQUEST_HEADER
    163 #define NS_HTTP_ACTIVITY_SUBTYPE_REQUEST_BODY_SENT \
    164            nsIHttpActivityObserver::ACTIVITY_SUBTYPE_REQUEST_BODY_SENT
    165 #define NS_HTTP_ACTIVITY_SUBTYPE_RESPONSE_START    \
    166            nsIHttpActivityObserver::ACTIVITY_SUBTYPE_RESPONSE_START
    167 #define NS_HTTP_ACTIVITY_SUBTYPE_RESPONSE_HEADER   \
    168            nsIHttpActivityObserver::ACTIVITY_SUBTYPE_RESPONSE_HEADER
    169 #define NS_HTTP_ACTIVITY_SUBTYPE_RESPONSE_COMPLETE \
    170            nsIHttpActivityObserver::ACTIVITY_SUBTYPE_RESPONSE_COMPLETE
    171 #define NS_HTTP_ACTIVITY_SUBTYPE_TRANSACTION_CLOSE \
    172            nsIHttpActivityObserver::ACTIVITY_SUBTYPE_TRANSACTION_CLOSE
    173 #define NS_HTTP_ACTIVITY_SUBTYPE_PROXY_RESPONSE_HEADER \
    174            nsIHttpActivityObserver::ACTIVITY_SUBTYPE_PROXY_RESPONSE_HEADER
    175 #define NS_HTTP_ACTIVITY_SUBTYPE_DNSANDSOCKET_CREATED \
    176            nsIHttpActivityObserver::ACTIVITY_SUBTYPE_DNSANDSOCKET_CREATED
    177 #define NS_HTTP_ACTIVITY_SUBTYPE_SPECULATIVE_DNSANDSOCKET_CREATED \
    178            nsIHttpActivityObserver::ACTIVITY_SUBTYPE_SPECULATIVE_DNSANDSOCKET_CREATED
    179 #define NS_HTTP_ACTIVITY_SUBTYPE_ECH_SET \
    180            nsIHttpActivityObserver::ACTIVITY_SUBTYPE_ECH_SET
    181 #define NS_HTTP_ACTIVITY_SUBTYPE_CONNECTION_CREATED \
    182            nsIHttpActivityObserver::ACTIVITY_SUBTYPE_CONNECTION_CREATED
    183 #define NS_HTTP_ACTIVITY_SUBTYPE_EARLYHINT_RESPONSE_HEADER \
    184            nsIHttpActivityObserver::ACTIVITY_SUBTYPE_EARLYHINT_RESPONSE_HEADER
    185 %}
    186 
    187 /**
    188 * nsIHttpActivityDistributor
    189 *
    190 * This interface provides a way to register and unregister observers to the
    191 * http activities.
    192 */
    193 [scriptable, builtinclass, uuid(7C512CB8-582A-4625-B5B6-8639755271B5)]
    194 interface nsIHttpActivityDistributor : nsIHttpActivityObserver
    195 {
    196    void addObserver(in nsIHttpActivityObserver aObserver);
    197    void removeObserver(in nsIHttpActivityObserver aObserver);
    198 
    199    /**
    200     * C++ friendly getter
    201     */
    202    [noscript, notxpcom] boolean Activated();
    203    [noscript, notxpcom] boolean ObserveProxyResponseEnabled();
    204    [noscript, notxpcom] boolean ObserveConnectionEnabled();
    205 
    206    /**
    207     * When true, the ACTIVITY_SUBTYPE_PROXY_RESPONSE_HEADER will be sent to
    208     * the observers.
    209     */
    210    [must_use] attribute boolean observeProxyResponse;
    211 
    212    /**
    213     * When true, the ACTIVITY_TYPE_HTTP_CONNECTION will be sent to
    214     * the observers.
    215     */
    216    [must_use] attribute boolean observeConnection;
    217 };