2017-10-27 01:08:41 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2015-06-17 13:44:27 +03:00
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#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 {
|
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(MessagePortService)
|
|
|
|
|
2015-06-24 01:50:00 +03:00
|
|
|
static MessagePortService* Get();
|
2015-06-17 13:44:27 +03:00
|
|
|
static MessagePortService* GetOrCreate();
|
|
|
|
|
|
|
|
bool RequestEntangling(MessagePortParent* aParent,
|
|
|
|
const nsID& aDestinationUUID,
|
|
|
|
const uint32_t& aSequenceID);
|
|
|
|
|
|
|
|
bool DisentanglePort(
|
|
|
|
MessagePortParent* aParent,
|
2015-10-18 08:24:48 +03:00
|
|
|
FallibleTArray<RefPtr<SharedMessagePortMessage>>& aMessages);
|
2015-06-17 13:44:27 +03:00
|
|
|
|
|
|
|
bool ClosePort(MessagePortParent* aParent);
|
|
|
|
|
|
|
|
bool PostMessages(
|
|
|
|
MessagePortParent* aParent,
|
2015-10-18 08:24:48 +03:00
|
|
|
FallibleTArray<RefPtr<SharedMessagePortMessage>>& aMessages);
|
2015-06-17 13:44:27 +03:00
|
|
|
|
|
|
|
void ParentDestroy(MessagePortParent* aParent);
|
|
|
|
|
2015-06-24 01:50:00 +03:00
|
|
|
bool ForceClose(const nsID& aUUID, const nsID& aDestinationUUID,
|
|
|
|
const uint32_t& aSequenceID);
|
|
|
|
|
2015-06-17 13:44:27 +03:00
|
|
|
private:
|
|
|
|
~MessagePortService() {}
|
|
|
|
|
2015-11-18 02:38:13 +03:00
|
|
|
void CloseAll(const nsID& aUUID, bool aForced = false);
|
2015-06-17 13:44:27 +03:00
|
|
|
void MaybeShutdown();
|
|
|
|
|
|
|
|
class MessagePortServiceData;
|
|
|
|
|
|
|
|
nsClassHashtable<nsIDHashKey, MessagePortServiceData> mPorts;
|
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2015-06-17 13:44:27 +03:00
|
|
|
|
|
|
|
#endif // mozilla_dom_MessagePortService_h
|