author Nicolas B. Pierron <>
Wed, 24 Oct 2018 15:07:53 +0200
changeset 443125 1bd322732a6e67a0caab2e0bf26ff0b20f01fc1a
parent 388518 cb123c84818a3c491fb9d63f00891d23f515cf6f
child 448947 6f3709b3878117466168c40affa7bca0b60cf75b
permissions -rw-r--r--
Bug 1502106 - Add a configure option to disable assume_unreachable spew. r=iain

/* -*- 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 */

#ifndef mozilla_dom_MessagePortService_h
#define mozilla_dom_MessagePortService_h

#include "nsClassHashtable.h"
#include "nsHashKeys.h"
#include "nsISupportsImpl.h"

namespace mozilla {
namespace dom {

class MessagePortParent;
class SharedMessagePortMessage;

class MessagePortService final

  static MessagePortService* Get();
  static MessagePortService* GetOrCreate();

  bool RequestEntangling(MessagePortParent* aParent,
                         const nsID& aDestinationUUID,
                         const uint32_t& aSequenceID);

  bool DisentanglePort(
                 MessagePortParent* aParent,
                 FallibleTArray<RefPtr<SharedMessagePortMessage>>& aMessages);

  bool ClosePort(MessagePortParent* aParent);

  bool PostMessages(
                 MessagePortParent* aParent,
                 FallibleTArray<RefPtr<SharedMessagePortMessage>>& aMessages);

  void ParentDestroy(MessagePortParent* aParent);

  bool ForceClose(const nsID& aUUID,
                  const nsID& aDestinationUUID,
                  const uint32_t& aSequenceID);

  ~MessagePortService() {}

  void CloseAll(const nsID& aUUID, bool aForced = false);
  void MaybeShutdown();

  class MessagePortServiceData;

  nsClassHashtable<nsIDHashKey, MessagePortServiceData> mPorts;

} // namespace dom
} // namespace mozilla

#endif // mozilla_dom_MessagePortService_h