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;
|
2020-01-24 10:59:36 +03:00
|
|
|
class SharedMessageBody;
|
2015-06-17 13:44:27 +03:00
|
|
|
|
|
|
|
class MessagePortService final {
|
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(MessagePortService)
|
|
|
|
|
2019-12-17 02:07:14 +03:00
|
|
|
// Needs to be public for the DECLARE_USE_COPY_CONSTRUCTORS macro.
|
|
|
|
struct NextParent;
|
|
|
|
|
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);
|
|
|
|
|
2020-01-24 10:59:36 +03:00
|
|
|
bool DisentanglePort(MessagePortParent* aParent,
|
|
|
|
FallibleTArray<RefPtr<SharedMessageBody>>& aMessages);
|
2015-06-17 13:44:27 +03:00
|
|
|
|
|
|
|
bool ClosePort(MessagePortParent* aParent);
|
|
|
|
|
2020-01-24 10:59:36 +03:00
|
|
|
bool PostMessages(MessagePortParent* aParent,
|
|
|
|
FallibleTArray<RefPtr<SharedMessageBody>>& 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
|