netwerk/protocol/websocket/nsIWebSocketEventService.idl
author Nika Layzell <nika@thelayzells.com>
Thu, 06 Aug 2020 14:04:13 +0000
changeset 544125 ee09cb88af177571304759bc05c760e3d82fd1ed
parent 543059 d3b13849daab356b3a0213120529ae865ed26da1
permissions -rw-r--r--
Bug 1656854 - Part 2: Add a BrowsingContextGroup keepalive to BrowserParent shutdown, r=farre In bug 1652085, I added BrowsingContextGroup keepalives while waiting for replies to the discard message, however that message isn't actually sent to the current owner process. Instead, the BrowsingContext is discarded by the PBrowser being destroyed. This should help ensure we also keep the group alive during normal BrowserParent destruction. Differential Revision: https://phabricator.services.mozilla.com/D85897

/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 "domstubs.idl"
#include "nsISupports.idl"

interface nsIWeakReference;

[scriptable, builtinclass, uuid(6714a6be-2265-4f73-a988-d78a12416037)]
interface nsIWebSocketFrame : nsISupports
{
  [must_use] readonly attribute DOMHighResTimeStamp timeStamp;

  [must_use] readonly attribute boolean finBit;

  [must_use] readonly attribute boolean rsvBit1;
  [must_use] readonly attribute boolean rsvBit2;
  [must_use] readonly attribute boolean rsvBit3;

  [must_use] readonly attribute unsigned short opCode;

  [must_use] readonly attribute boolean maskBit;

  [must_use] readonly attribute unsigned long mask;

  [must_use] readonly attribute ACString payload;

  // Non-Control opCode values:
  const unsigned short OPCODE_CONTINUATION = 0x0;
  const unsigned short OPCODE_TEXT         = 0x1;
  const unsigned short OPCODE_BINARY       = 0x2;

  // Control opCode values:
  const unsigned short OPCODE_CLOSE        = 0x8;
  const unsigned short OPCODE_PING         = 0x9;
  const unsigned short OPCODE_PONG         = 0xA;
};

[scriptable, uuid(e7c005ab-e694-489b-b741-96db43ffb16f)]
interface nsIWebSocketEventListener : nsISupports
{
  [must_use] void webSocketCreated(in unsigned long aWebSocketSerialID,
                                   in AString aURI,
                                   in ACString aProtocols);

  [must_use] void webSocketOpened(in unsigned long aWebSocketSerialID,
                                  in AString aEffectiveURI,
                                  in ACString aProtocols,
                                  in ACString aExtensions,
                                  in uint64_t aHttpChannelId);

  const unsigned short TYPE_STRING      = 0x0;
  const unsigned short TYPE_BLOB        = 0x1;
  const unsigned short TYPE_ARRAYBUFFER = 0x2;

  [must_use] void webSocketMessageAvailable(in unsigned long aWebSocketSerialID,
                                            in ACString aMessage,
                                            in unsigned short aType);

  [must_use] void webSocketClosed(in unsigned long aWebSocketSerialID,
                                  in boolean aWasClean,
                                  in unsigned short aCode,
                                  in AString aReason);

  [must_use] void frameReceived(in unsigned long aWebSocketSerialID,
                                in nsIWebSocketFrame aFrame);

  [must_use] void frameSent(in unsigned long aWebSocketSerialID,
                            in nsIWebSocketFrame aFrame);
};

[scriptable, builtinclass, uuid(b89d1b90-2cf3-4d8f-ac21-5aedfb25c760)]
interface nsIWebSocketEventService : nsISupports
{
  [must_use] void sendMessage(in unsigned long aWebSocketSerialID,
                              in AString aMessage);

  [must_use] void addListener(in unsigned long long aInnerWindowID,
                              in nsIWebSocketEventListener aListener);

  [must_use] void removeListener(in unsigned long long aInnerWindowID,
                                 in nsIWebSocketEventListener aListener);

  [must_use] bool hasListenerFor(in unsigned long long aInnerWindowID);
};