2015-05-03 22:32:37 +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: */
|
2013-09-03 16:38:49 +04: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_MessageChannel_h
|
|
|
|
#define mozilla_dom_MessageChannel_h
|
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/ErrorResult.h"
|
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
2016-03-01 17:21:11 +03:00
|
|
|
class nsIGlobalObject;
|
2013-09-03 16:38:49 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class MessagePort;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class MessageChannel final : public nsISupports
|
2015-03-27 21:52:19 +03:00
|
|
|
, public nsWrapperCache
|
2013-09-03 16:38:49 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MessageChannel)
|
|
|
|
|
2016-03-01 17:21:11 +03:00
|
|
|
nsIGlobalObject*
|
2013-09-03 16:38:49 +04:00
|
|
|
GetParentObject() const
|
|
|
|
{
|
2016-03-01 17:21:11 +03:00
|
|
|
return mGlobal;
|
2013-09-03 16:38:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual JSObject*
|
2015-03-21 19:28:04 +03:00
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-09-03 16:38:49 +04:00
|
|
|
|
|
|
|
static already_AddRefed<MessageChannel>
|
|
|
|
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
|
|
|
|
|
2015-09-16 06:27:56 +03:00
|
|
|
static already_AddRefed<MessageChannel>
|
2016-03-01 17:21:11 +03:00
|
|
|
Constructor(nsIGlobalObject* aGlobal, ErrorResult& aRv);
|
2015-09-16 06:27:56 +03:00
|
|
|
|
2013-09-03 16:38:49 +04:00
|
|
|
MessagePort*
|
|
|
|
Port1() const
|
|
|
|
{
|
|
|
|
return mPort1;
|
|
|
|
}
|
|
|
|
|
|
|
|
MessagePort*
|
|
|
|
Port2() const
|
|
|
|
{
|
|
|
|
return mPort2;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2016-03-01 17:21:11 +03:00
|
|
|
explicit MessageChannel(nsIGlobalObject* aGlobal);
|
2014-06-23 23:56:07 +04:00
|
|
|
~MessageChannel();
|
|
|
|
|
2016-03-01 17:21:11 +03:00
|
|
|
nsCOMPtr<nsIGlobalObject> mGlobal;
|
2013-09-03 16:38:49 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<MessagePort> mPort1;
|
|
|
|
RefPtr<MessagePort> mPort2;
|
2013-09-03 16:38:49 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_MessageChannel_h
|