DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (c073e3faa76e)

VCS Links

Line Code
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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
/* 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"

interface nsIDOMBlob;
interface nsIDOMEventTarget;
interface nsIInputStream;
interface nsIPresentationAvailabilityListener;
interface nsIPresentationRespondingListener;
interface nsIPresentationSessionListener;
interface nsIPresentationTransportBuilderConstructor;
interface nsIPrincipal;

%{C++
#define PRESENTATION_SERVICE_CID \
  { 0x1d9bb10c, 0xc0ab, 0x4fe8, \
    { 0x9e, 0x4f, 0x40, 0x58, 0xb8, 0x51, 0x98, 0x32 } }
#define PRESENTATION_SERVICE_CONTRACTID \
  "@mozilla.org/presentation/presentationservice;1"

#include "nsStringFwd.h"
#include "nsTArray.h"

%}

[ref] native URLArrayRef(const nsTArray<nsString>);

[scriptable, uuid(12073206-0065-4b10-9488-a6eb9b23e65b)]
interface nsIPresentationServiceCallback : nsISupports
{
  /*
   * Called when the operation succeeds.
   *
   * @param url: the selected request url used to start or reconnect a session.
   */
  void notifySuccess(in DOMString url);

  /*
   * Called when the operation fails.
   *
   * @param error: error message.
   */
  void notifyError(in nsresult error);
};

[scriptable, uuid(de42b741-5619-4650-b961-c2cebb572c95)]
interface nsIPresentationService : nsISupports
{
  const unsigned short ROLE_CONTROLLER = 0x1;
  const unsigned short ROLE_RECEIVER = 0x2;

  const unsigned short CLOSED_REASON_ERROR = 0x1;
  const unsigned short CLOSED_REASON_CLOSED = 0x2;
  const unsigned short CLOSED_REASON_WENTAWAY = 0x3;

  /*
   * Start a new presentation session and display a prompt box which asks users
   * to select a device.
   *
   * @param urls: The candidate Urls of presenting page. Only one url would be used.
   * @param sessionId: An ID to identify presentation session.
   * @param origin: The url of requesting page.
   * @param deviceId: The specified device of handling this request, null string
   *                  for prompt device selection dialog.
   * @param windowId: The inner window ID associated with the presentation
   *                  session. (0 implies no window ID since no actual window
   *                  uses 0 as its ID. Generally it's the case the window is
   *                  located in different process from this service)
   * @param eventTarget: The chrome event handler, in particular XUL browser
   *                     element in parent process, that the request was
   *                     originated in.
   * @param principal: The principal that initiated the session.
   * @param callback: Invoke the callback when the operation is completed.
   *                  NotifySuccess() is called with |id| if a session is
   *                  established successfully with the selected device.
   *                  Otherwise, NotifyError() is called with a error message.
   * @param constructor: The constructor for creating a transport builder.
   */
  [noscript] void startSession(in URLArrayRef urls,
                               in DOMString sessionId,
                               in DOMString origin,
                               in DOMString deviceId,
                               in unsigned long long windowId,
                               in nsIDOMEventTarget eventTarget,
                               in nsIPrincipal principal,
                               in nsIPresentationServiceCallback callback,
                               in nsIPresentationTransportBuilderConstructor constructor);

  /*
   * Send the message to the session.
   *
   * @param sessionId: An ID to identify presentation session.
   * @param role: Identify the function called by controller or receiver.
   * @param data: the message being sent out.
   */
  void sendSessionMessage(in DOMString sessionId,
							            in uint8_t role,
                          in DOMString data);

  /*
   * Send the binary message to the session.
   *
   * @param sessionId: An ID to identify presentation session.
   * @param role: Identify the function called by controller or receiver.
   * @param data: the message being sent out.
   */
  void sendSessionBinaryMsg(in DOMString sessionId,
                            in uint8_t role,
                            in ACString data);

  /*
   * Send the blob to the session.
   *
   * @param sessionId: An ID to identify presentation session.
   * @param role: Identify the function called by controller or receiver.
   * @param blob: The input blob to be sent.
   */
  void sendSessionBlob(in DOMString sessionId,
                       in uint8_t role,
                       in nsIDOMBlob blob);

  /*
   * Close the session.
   *
   * @param sessionId: An ID to identify presentation session.
   * @param role: Identify the function called by controller or receiver.
   */
  void closeSession(in DOMString sessionId,
                    in uint8_t role,
                    in uint8_t closedReason);

  /*
   * Terminate the session.
   *
   * @param sessionId: An ID to identify presentation session.
   * @param role: Identify the function called by controller or receiver.
   */
  void terminateSession(in DOMString sessionId,
                        in uint8_t role);

  /*
   * Reconnect the session.
   *
   * @param url: The request Urls.
   * @param sessionId: An ID to identify presentation session.
   * @param role: Identify the function called by controller or receiver.
   * @param callback: NotifySuccess() is called when a control channel
   *                  is opened successfully.
   *                  Otherwise, NotifyError() is called with a error message.
   */
  [noscript] void reconnectSession(in URLArrayRef urls,
                                   in DOMString sessionId,
                                   in uint8_t role,
                                   in nsIPresentationServiceCallback callback);

  /*
   * Register an availability listener. Must be called from the main thread.
   *
   * @param availabilityUrls: The Urls that this listener is interested in.
   * @param listener: The listener to register.
   */
  [noscript] void registerAvailabilityListener(
                              in URLArrayRef availabilityUrls,
                              in nsIPresentationAvailabilityListener listener);

  /*
   * Unregister an availability listener. Must be called from the main thread.
   *
   * @param availabilityUrls: The Urls that are registered before.
   * @param listener: The listener to unregister.
   */
  [noscript] void unregisterAvailabilityListener(
                              in URLArrayRef availabilityUrls,
                              in nsIPresentationAvailabilityListener listener);

  /*
   * Register a session listener. Must be called from the main thread.
   *
   * @param sessionId: An ID to identify presentation session.
   * @param role: Identify the function called by controller or receiver.
   * @param listener: The listener to register.
   */
  void registerSessionListener(in DOMString sessionId,
                               in uint8_t role,
                               in nsIPresentationSessionListener listener);

  /*
   * Unregister a session listener. Must be called from the main thread.
   *
   * @param sessionId: An ID to identify presentation session.
   * @param role: Identify the function called by controller or receiver.
   */
  void unregisterSessionListener(in DOMString sessionId,
                                 in uint8_t role);

  /*
   * Register a responding listener. Must be called from the main thread.
   *
   * @param windowId: The window ID associated with the listener.
   * @param listener: The listener to register.
   */
  void registerRespondingListener(in unsigned long long windowId,
                                  in nsIPresentationRespondingListener listener);

  /*
   * Unregister a responding listener. Must be called from the main thread.
   * @param windowId: The window ID associated with the listener.
   */
  void unregisterRespondingListener(in unsigned long long windowId);

  /*
   * Notify the receiver page is ready for presentation use.
   *
   * @param sessionId An ID to identify presentation session.
   * @param windowId  The inner window ID associated with the presentation
   *                  session.
   * @param isLoading true if receiver page is loading successfully.
   * @param constructor: The constructor for creating a transport builder.
   */
  void notifyReceiverReady(in DOMString sessionId,
                           in unsigned long long windowId,
                           in boolean isLoading,
                           in nsIPresentationTransportBuilderConstructor constructor);

  /*
   * Notify the transport is closed
   *
   * @param sessionId: An ID to identify presentation session.
   * @param role: Identify the function called by controller or receiver.
   * @param reason: the error message. NS_OK indicates it is closed normally.
   */
  void NotifyTransportClosed(in DOMString sessionId,
                             in uint8_t role,
                             in nsresult reason);

  /*
   * Untrack the relevant info about the presentation session if there's any.
   *
   * @param sessionId: An ID to identify presentation session.
   * @param role: Identify the function called by controller or receiver.
   */
  void untrackSessionInfo(in DOMString sessionId, in uint8_t role);

  /*
   * The windowId for building RTCDataChannel session transport
   *
   * @param sessionId: An ID to identify presentation session.
   * @param role: Identify the function called by controller or receiver.
   */
  unsigned long long getWindowIdBySessionId(in DOMString sessionId,
                                            in uint8_t role);

  /*
   * Update the mapping of the session ID and window ID.
   *
   * @param sessionId: An ID to identify presentation session.
   * @param role: Identify the function called by controller or receiver.
   * @param windowId: The inner window ID associated with the presentation
   *                  session.
   */
  void updateWindowIdBySessionId(in DOMString sessionId,
                                 in uint8_t role,
                                 in unsigned long long windowId);

  /*
   * To build the session transport.
   * NOTE: This function should be only called at controller side.
   *
   * @param sessionId: An ID to identify presentation session.
   * @param role: Identify the function called by controller or receiver.
   */
  void buildTransport(in DOMString sessionId, in uint8_t role);
};