Files
palemoon27/dom/base/nsDOMDataChannel.cpp
T
roytam1 b6f6aa65fb import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1165518 - Part 2: Replace prlog.h with Logging.h. rs=froydnj (342dfd711)
- Bug 1085567 - Fixup synth events within pointer lock implementation for e10s. r=billm (45c50a0e6)
- Bug 1128238 - Ajust NPP_SetWindow and synth native event coords to account for the chrome offset of remote tabs. Prior to this the content process always assumed the tab was the window origin. r=aklotz (202ffc006)
- Bug 1128934 - Avoid calling GetClientBounds from BasicComposior. r=roc, karlt (5e98232bd)
- Bug 1149041 - Make nsIWidget::SizeConstraints use LayoutDeviceIntSize instead of unit-less nsIntSize. r=roc (d0b345926)
- shuffle around (fcdc51510)
- Bug 1142852 P1 Fix NS_NewNonOwningRunnableMethodWithArgs() so that it compiles. r=froydnj (394d2b200)
- Bug 1142852 P2 Make Cache Action use non-threadsafe ref-counting. r=ehsan (0b2b91d86)
- Bug 1146349 - Allow NS_NewRunnableMethodWithArgs to take up to 8 arguments. r=froydnj (7207e74d0)
- Bug 1146349 - Make the native event synthesization functions in DOMWindowUtils async. r=smaug (e43579a1d)
- Bug 949614 - Use === for SimpleTest.is; r=Waldo (9f54faca4)
- Bug 1146349 - Update some widget tests to deal with async native key event synthesization. r=smaug,masayuki (f1e82df79)
- Bug 920013 - Rewrite test_cocoa_focus.html to use SpecialPowers. r=smichaud (8708d6a71)
- Bug 1146349 - Update DOM mochitests to deal with async native event synthesization. r=smaug (a4eceb9f6)
- Bug 1146349 - Update browser-chrome mochitests to deal with async native event synthesization. r=Gijs (c864ad939)
- Bug 1146349 - Wire up native event synthesization in child processes.  r=smaug (e8574457e)
- Bug 1146349 - Mark SynthesizedEventObserver::Observe() as override (9063f04b5)
- Bug 1149613 - Remove unneded field. r=botond (9aa7155e2)
- Bug 1153613 - [e10s], ensure the buffer for the drag image is large enough for SourceSurfaceRawData::GuaranteePersistance() to succeed, r=mattwoodrow (aa885dae7)
- remove spurious file (ff199d3ae)
- Bug 1043013 - Generalize nsIntRegion into a BaseIntRegion template. r=jrmuizel (9d3e02820)
- Bug 1043013 - Introduce IntRegionTyped. r=jrmuizel (f73902921)
- Bug 1043013 - Use strongly-typed regions in HitTestingTreeNode. r=kats (7b8c8ae44)
- Bug 913443 - Remove mention of the word ThebesLayer in a comment. r=roc (e9706e025)
- Bug 913443 - Remove some #ifdefs. r=roc (da76f831b)
- Bug 913443 - Break up CreateOrRecyclePaintedLayer into more parts. r=roc (dd94560fe)
- Bug 913443 - Extract layer hint calculation. r=roc (5c7806a95)
- Bug 913443 - Break CreateOrRecyclePaintedLayer up even more. r=roc (9e5edab17)
- Bug 913443 - Remove unused aItemVisibleRect argument. r=roc (f3d1a5195)
- Bug 913443 - Move IsWidgetLayerManager() check out of UpdateCommonClipCount. r=roc (3be7b19a6)
- Bug 913443 - Change the order of these calls. r=roc (c7bc59fee)
- Bug 913443 - Add a display item buffer for PaintedLayerData so that we can assign items without needing to know the actual Layer. r=roc (674df6aa8)
- Bug 913443 - Delay PaintedLayer recycling until PopPaintedLayerData() r=roc (9d6de961a)
- Bug 913443 - When determining the layer to recycle, only consider layers that have display items in common with the layer we need. r=roc (3327c31c5)
- Bug 913443 - Recycle PaintedLayers as soon as possible. r=roc (37ef6d530)
- Bug 913443 - Remove duplicated argument variables. r=roc (19c5af270)
- Bug 1141408 - Don't include the display item's memory address in the profile label. r=BenWa (5bb1d73c1)
- Bug 1141281 - Don't put empty Info: lines into the layers dump. r=BenWa (85f4b28be)
- Bug 1035611 - Part 1: Updated Matrix4x4::ProjectRectBounds to properly handle infinite values when untransformed rects cross the w=0 plane. r=mattwoodrow (f47ed4383)
- Bug 1035611 - Part 2: Test to ensure that transformed rects crossing the w=0 plane are clipped correctly. r=mattwoodrow (5701b435f)
- Bug 1141089 - Add some release assertions to gather more data. r=roc (805c2994d)
- Bug 1141595 - Make scroll info display item hoisting work after bug 913443. r=tn (1efcaf164)
- Bug 1144307 - Destroy scroll info layer items when we're done with them. r=tn (3ffd3b1f2)
- Bug 1148855 - Mark some ContainerState methods as const. r=roc (791585baf)
- Bug 1144820 - Use rvalue reference in AddProfileTimelineMarker. r=smaug (12316b65f)
- Bug 1148855 - Set overflow:hidden on scrollbar tracks so that layerization knows that the scrollbar thumb won't leave the scrollbar. r=roc (082ec87bf)
- Bug 1148855 - Intermediate state that unifies APZ and non-APZ layerization behavior somewhat. (3da45ab96)
- Bug 1148855 - Rework how display items are assigned to PaintedLayers and make it work the same way with and without APZ. r=roc (7258f9c90)
- Bug 913443 - Add some tests. r=roc (9977682da)
- Bug 1039926 - Add a test for not invalidating stuff inside mask layers. (1f8aef65e)
- Bug 1148855 - Add some tests. r=roc (2ba1f7f18)
- Bug 1148855 - Tweak reftest fuzziness. (a600be7d5)
- Bug 1151306 - Add a missing check during background color pulling. r=roc (b3a6c886b)
- Bug 1150774 (Part 1) - Add helpers to simplify using typed units in ConfigureLayer. r=botond (baecb2c2e)
- Bug 1150774 (Part 2) - Use the correct units in nsDisplayImageContainer::ConfigureLayer and related code. r=botond (a79beb1fb)
- Bug 1141089 - Initialize DisplayItemData with a non-null mLayer, so that mLayer is non-null throughout the object's whole lifetime. r=roc (7c2f9eb09)
- Bug 1141089 - Remove unused DisplayItemData copy constructor. r=roc (ba5c46c45)
- Bug 1141089 - Add a few more MOZ_RELEASE_ASSERT(mLayer) checks, just for fun. r=roc (50a8f2db7)
- Bug 1141089 - Use const nsTArray* in all the places where we don't change the array's contents. r=roc (cd07a5bbd)
- Bug 1141089 - Turn these two assertions into release assertions. r=roc (71daf5ef3)
- Bug 1141089 - Check that we're unsetting sDestroyedFrame correctly. r=roc (6c7da67e7)
- Bug 1143522 - Convert Layer::mClipRect to ParentLayerIntRect. r=botond (ddab1c0ff)
- Bug 1144951. Warn if the result of ConvertAppUnits is unused. r=mats (e1d79c6ca)
- Bug 1144951. Rename ConvertAppUnits to ScaleToOtherAppUnits. r=mats (675c918c3)
- Bug 1149035 - Make nsXULPopupManager::PopupResized take a LayoutDeviceIntSize param instead of a unit-less nsIntSize. r=roc (eb9529af7)
- missing bit of Bug 1156110 - Make nsView::mWindow an nsCOMPtr; r=roc (972255b4f)
- Bug 1147706 - Warn if we don't use the result of const methods on BaseRect and its subclasses. r=tn (9e91deada)
- Bug 1152838 - Fix BaseRect::InflateToMultiple and move it to nsIntRect. r=mattwoodrow, r=jrmuizel (5a942df29)
- Bug 1125055 - Sync decode layerized images if necessary. r=roc,tn (1379db5c7)
- Bug 1145167 - make imgIContainer::type getter infallible; r=seth (7b7091b89)
- Bug 1148213 - Implement image locking for VectorImage. r=dholbert (240e14cb3)
- Bug 1143653 - Crash in CompositorD3D9 rather than TextureD3D9 if device reset fails, after a few attemps. r=jrmuizel (76607ddc3)
- Bug 1147894 - Only use non-null compositors with TextureHost::SetCompositor. r=sotaro (605bf34f6)
- Bug 1146912 - Finish replacing TextureHost::GetTextureSource by BindTextureSource. r=sotaro (cf3763879)
- Bug 1132854 - Remove useless ThebesIntSize conversion helper. r=Bas (78cdfee14)
- Bug 1068881 - Inflate the dest rect to at least one device pixel when computing the optimal image size for drawing. r=roc (3d5644913)
2020-05-30 12:49:08 +08:00

509 lines
13 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et 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 http://mozilla.org/MPL/2.0/. */
#include "nsDOMDataChannel.h"
#include "base/basictypes.h"
#include "mozilla/Logging.h"
extern PRLogModuleInfo* GetDataChannelLog();
#undef LOG
#define LOG(args) PR_LOG(GetDataChannelLog(), PR_LOG_DEBUG, args)
#include "nsDOMDataChannelDeclarations.h"
#include "nsDOMDataChannel.h"
#include "nsIDOMDataChannel.h"
#include "nsIDOMMessageEvent.h"
#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/dom/File.h"
#include "mozilla/dom/ScriptSettings.h"
#include "nsError.h"
#include "nsAutoPtr.h"
#include "nsContentUtils.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsNetUtil.h"
#include "DataChannel.h"
// Since we've moved the windows.h include down here, we have to explicitly
// undef GetBinaryType, otherwise we'll get really odd conflicts
#ifdef GetBinaryType
#undef GetBinaryType
#endif
using namespace mozilla;
using namespace mozilla::dom;
nsDOMDataChannel::~nsDOMDataChannel()
{
// Don't call us anymore! Likely isn't an issue (or maybe just less of
// one) once we block GC until all the (appropriate) onXxxx handlers
// are dropped. (See WebRTC spec)
LOG(("Close()ing %p", mDataChannel.get()));
mDataChannel->SetListener(nullptr, nullptr);
mDataChannel->Close();
}
/* virtual */ JSObject*
nsDOMDataChannel::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return DataChannelBinding::Wrap(aCx, this, aGivenProto);
}
NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMDataChannel)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMDataChannel,
DOMEventTargetHelper)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMDataChannel,
DOMEventTargetHelper)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_ADDREF_INHERITED(nsDOMDataChannel, DOMEventTargetHelper)
NS_IMPL_RELEASE_INHERITED(nsDOMDataChannel, DOMEventTargetHelper)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMDataChannel)
NS_INTERFACE_MAP_ENTRY(nsIDOMDataChannel)
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
nsDOMDataChannel::nsDOMDataChannel(already_AddRefed<mozilla::DataChannel>& aDataChannel,
nsPIDOMWindow* aWindow)
: DOMEventTargetHelper(aWindow && aWindow->IsOuterWindow() ?
aWindow->GetCurrentInnerWindow() : aWindow)
, mDataChannel(aDataChannel)
, mBinaryType(DC_BINARY_TYPE_BLOB)
{
}
nsresult
nsDOMDataChannel::Init(nsPIDOMWindow* aDOMWindow)
{
nsresult rv;
nsAutoString urlParam;
MOZ_ASSERT(mDataChannel);
mDataChannel->SetListener(this, nullptr);
// Now grovel through the objects to get a usable origin for onMessage
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aDOMWindow);
NS_ENSURE_STATE(sgo);
nsCOMPtr<nsIScriptContext> scriptContext = sgo->GetContext();
NS_ENSURE_STATE(scriptContext);
nsCOMPtr<nsIScriptObjectPrincipal> scriptPrincipal(do_QueryInterface(aDOMWindow));
NS_ENSURE_STATE(scriptPrincipal);
nsCOMPtr<nsIPrincipal> principal = scriptPrincipal->GetPrincipal();
NS_ENSURE_STATE(principal);
// Attempt to kill "ghost" DataChannel (if one can happen): but usually too early for check to fail
rv = CheckInnerWindowCorrectness();
NS_ENSURE_SUCCESS(rv,rv);
rv = nsContentUtils::GetUTFOrigin(principal,mOrigin);
LOG(("%s: origin = %s\n",__FUNCTION__,NS_LossyConvertUTF16toASCII(mOrigin).get()));
return rv;
}
NS_IMPL_EVENT_HANDLER(nsDOMDataChannel, open)
NS_IMPL_EVENT_HANDLER(nsDOMDataChannel, error)
NS_IMPL_EVENT_HANDLER(nsDOMDataChannel, close)
NS_IMPL_EVENT_HANDLER(nsDOMDataChannel, message)
NS_IMETHODIMP
nsDOMDataChannel::GetLabel(nsAString& aLabel)
{
mDataChannel->GetLabel(aLabel);
return NS_OK;
}
NS_IMETHODIMP
nsDOMDataChannel::GetProtocol(nsAString& aProtocol)
{
mDataChannel->GetProtocol(aProtocol);
return NS_OK;
}
uint16_t
nsDOMDataChannel::Id() const
{
return mDataChannel->GetStream();
}
NS_IMETHODIMP
nsDOMDataChannel::GetId(uint16_t *aId)
{
*aId = Id();
return NS_OK;
}
uint16_t
nsDOMDataChannel::Stream() const
{
return mDataChannel->GetStream();
}
NS_IMETHODIMP
nsDOMDataChannel::GetStream(uint16_t *aStream)
{
*aStream = Stream();
return NS_OK;
}
// XXX should be GetType()? Open question for the spec
bool
nsDOMDataChannel::Reliable() const
{
return mDataChannel->GetType() == mozilla::DataChannelConnection::RELIABLE;
}
NS_IMETHODIMP
nsDOMDataChannel::GetReliable(bool* aReliable)
{
*aReliable = Reliable();
return NS_OK;
}
bool
nsDOMDataChannel::Ordered() const
{
return mDataChannel->GetOrdered();
}
NS_IMETHODIMP
nsDOMDataChannel::GetOrdered(bool* aOrdered)
{
*aOrdered = Ordered();
return NS_OK;
}
RTCDataChannelState
nsDOMDataChannel::ReadyState() const
{
return static_cast<RTCDataChannelState>(mDataChannel->GetReadyState());
}
NS_IMETHODIMP
nsDOMDataChannel::GetReadyState(nsAString& aReadyState)
{
uint16_t readyState = mDataChannel->GetReadyState();
// From the WebRTC spec
const char * stateName[] = {
"connecting",
"open",
"closing",
"closed"
};
MOZ_ASSERT(/*readyState >= mozilla::DataChannel::CONNECTING && */ // Always true due to datatypes
readyState <= mozilla::DataChannel::CLOSED);
aReadyState.AssignASCII(stateName[readyState]);
return NS_OK;
}
uint32_t
nsDOMDataChannel::BufferedAmount() const
{
return mDataChannel->GetBufferedAmount();
}
NS_IMETHODIMP
nsDOMDataChannel::GetBufferedAmount(uint32_t* aBufferedAmount)
{
*aBufferedAmount = BufferedAmount();
return NS_OK;
}
NS_IMETHODIMP nsDOMDataChannel::GetBinaryType(nsAString & aBinaryType)
{
switch (mBinaryType) {
case DC_BINARY_TYPE_ARRAYBUFFER:
aBinaryType.AssignLiteral("arraybuffer");
break;
case DC_BINARY_TYPE_BLOB:
aBinaryType.AssignLiteral("blob");
break;
default:
NS_ERROR("Should not happen");
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMDataChannel::SetBinaryType(const nsAString& aBinaryType)
{
if (aBinaryType.EqualsLiteral("arraybuffer")) {
mBinaryType = DC_BINARY_TYPE_ARRAYBUFFER;
} else if (aBinaryType.EqualsLiteral("blob")) {
mBinaryType = DC_BINARY_TYPE_BLOB;
} else {
return NS_ERROR_INVALID_ARG;
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMDataChannel::Close()
{
mDataChannel->Close();
return NS_OK;
}
// All of the following is copy/pasted from WebSocket.cpp.
void
nsDOMDataChannel::Send(const nsAString& aData, ErrorResult& aRv)
{
NS_ConvertUTF16toUTF8 msgString(aData);
Send(nullptr, msgString, msgString.Length(), false, aRv);
}
void
nsDOMDataChannel::Send(File& aData, ErrorResult& aRv)
{
MOZ_ASSERT(NS_IsMainThread(), "Not running on main thread");
nsCOMPtr<nsIInputStream> msgStream;
nsresult rv = aData.GetInternalStream(getter_AddRefs(msgStream));
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return;
}
uint64_t msgLength;
rv = aData.GetSize(&msgLength);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return;
}
if (msgLength > UINT32_MAX) {
aRv.Throw(NS_ERROR_FILE_TOO_BIG);
return;
}
Send(msgStream, EmptyCString(), msgLength, true, aRv);
}
void
nsDOMDataChannel::Send(const ArrayBuffer& aData, ErrorResult& aRv)
{
MOZ_ASSERT(NS_IsMainThread(), "Not running on main thread");
aData.ComputeLengthAndData();
static_assert(sizeof(*aData.Data()) == 1, "byte-sized data required");
uint32_t len = aData.Length();
char* data = reinterpret_cast<char*>(aData.Data());
nsDependentCSubstring msgString(data, len);
Send(nullptr, msgString, len, true, aRv);
}
void
nsDOMDataChannel::Send(const ArrayBufferView& aData, ErrorResult& aRv)
{
MOZ_ASSERT(NS_IsMainThread(), "Not running on main thread");
aData.ComputeLengthAndData();
static_assert(sizeof(*aData.Data()) == 1, "byte-sized data required");
uint32_t len = aData.Length();
char* data = reinterpret_cast<char*>(aData.Data());
nsDependentCSubstring msgString(data, len);
Send(nullptr, msgString, len, true, aRv);
}
void
nsDOMDataChannel::Send(nsIInputStream* aMsgStream,
const nsACString& aMsgString,
uint32_t aMsgLength,
bool aIsBinary,
ErrorResult& aRv)
{
MOZ_ASSERT(NS_IsMainThread());
uint16_t state = mDataChannel->GetReadyState();
// In reality, the DataChannel protocol allows this, but we want it to
// look like WebSockets
if (state == mozilla::DataChannel::CONNECTING) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
if (state == mozilla::DataChannel::CLOSING ||
state == mozilla::DataChannel::CLOSED) {
return;
}
MOZ_ASSERT(state == mozilla::DataChannel::OPEN,
"Unknown state in nsDOMDataChannel::Send");
int32_t sent;
if (aMsgStream) {
sent = mDataChannel->SendBinaryStream(aMsgStream, aMsgLength);
} else {
if (aIsBinary) {
sent = mDataChannel->SendBinaryMsg(aMsgString);
} else {
sent = mDataChannel->SendMsg(aMsgString);
}
}
if (sent < 0) {
aRv.Throw(NS_ERROR_FAILURE);
}
}
nsresult
nsDOMDataChannel::DoOnMessageAvailable(const nsACString& aData,
bool aBinary)
{
MOZ_ASSERT(NS_IsMainThread());
LOG(("DoOnMessageAvailable%s\n",aBinary ? ((mBinaryType == DC_BINARY_TYPE_BLOB) ? " (blob)" : " (binary)") : ""));
nsresult rv = CheckInnerWindowCorrectness();
if (NS_FAILED(rv)) {
return NS_OK;
}
AutoJSAPI jsapi;
if (NS_WARN_IF(!jsapi.Init(GetOwner()))) {
return NS_ERROR_FAILURE;
}
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> jsData(cx);
if (aBinary) {
if (mBinaryType == DC_BINARY_TYPE_BLOB) {
rv = nsContentUtils::CreateBlobBuffer(cx, GetOwner(), aData, &jsData);
NS_ENSURE_SUCCESS(rv, rv);
} else if (mBinaryType == DC_BINARY_TYPE_ARRAYBUFFER) {
JS::Rooted<JSObject*> arrayBuf(cx);
rv = nsContentUtils::CreateArrayBuffer(cx, aData, arrayBuf.address());
NS_ENSURE_SUCCESS(rv, rv);
jsData = OBJECT_TO_JSVAL(arrayBuf);
} else {
NS_RUNTIMEABORT("Unknown binary type!");
return NS_ERROR_UNEXPECTED;
}
} else {
NS_ConvertUTF8toUTF16 utf16data(aData);
JSString* jsString = JS_NewUCStringCopyN(cx, utf16data.get(), utf16data.Length());
NS_ENSURE_TRUE(jsString, NS_ERROR_FAILURE);
jsData = STRING_TO_JSVAL(jsString);
}
nsCOMPtr<nsIDOMEvent> event;
rv = NS_NewDOMMessageEvent(getter_AddRefs(event), this, nullptr, nullptr);
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIDOMMessageEvent> messageEvent = do_QueryInterface(event);
rv = messageEvent->InitMessageEvent(NS_LITERAL_STRING("message"),
false, false,
jsData, mOrigin, EmptyString(),
nullptr);
NS_ENSURE_SUCCESS(rv,rv);
event->SetTrusted(true);
LOG(("%p(%p): %s - Dispatching\n",this,(void*)mDataChannel,__FUNCTION__));
rv = DispatchDOMEvent(nullptr, event, nullptr, nullptr);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch the message event!!!");
}
return rv;
}
nsresult
nsDOMDataChannel::OnMessageAvailable(nsISupports* aContext,
const nsACString& aMessage)
{
MOZ_ASSERT(NS_IsMainThread());
return DoOnMessageAvailable(aMessage, false);
}
nsresult
nsDOMDataChannel::OnBinaryMessageAvailable(nsISupports* aContext,
const nsACString& aMessage)
{
MOZ_ASSERT(NS_IsMainThread());
return DoOnMessageAvailable(aMessage, true);
}
nsresult
nsDOMDataChannel::OnSimpleEvent(nsISupports* aContext, const nsAString& aName)
{
MOZ_ASSERT(NS_IsMainThread());
nsresult rv = CheckInnerWindowCorrectness();
if (NS_FAILED(rv)) {
return NS_OK;
}
nsCOMPtr<nsIDOMEvent> event;
rv = NS_NewDOMEvent(getter_AddRefs(event), this, nullptr, nullptr);
NS_ENSURE_SUCCESS(rv,rv);
rv = event->InitEvent(aName, false, false);
NS_ENSURE_SUCCESS(rv,rv);
event->SetTrusted(true);
return DispatchDOMEvent(nullptr, event, nullptr, nullptr);
}
nsresult
nsDOMDataChannel::OnChannelConnected(nsISupports* aContext)
{
LOG(("%p(%p): %s - Dispatching\n",this,(void*)mDataChannel,__FUNCTION__));
return OnSimpleEvent(aContext, NS_LITERAL_STRING("open"));
}
nsresult
nsDOMDataChannel::OnChannelClosed(nsISupports* aContext)
{
LOG(("%p(%p): %s - Dispatching\n",this,(void*)mDataChannel,__FUNCTION__));
return OnSimpleEvent(aContext, NS_LITERAL_STRING("close"));
}
void
nsDOMDataChannel::AppReady()
{
mDataChannel->AppReady();
}
/* static */
nsresult
NS_NewDOMDataChannel(already_AddRefed<mozilla::DataChannel>&& aDataChannel,
nsPIDOMWindow* aWindow,
nsIDOMDataChannel** aDomDataChannel)
{
nsRefPtr<nsDOMDataChannel> domdc =
new nsDOMDataChannel(aDataChannel, aWindow);
nsresult rv = domdc->Init(aWindow);
NS_ENSURE_SUCCESS(rv,rv);
return CallQueryInterface(domdc, aDomDataChannel);
}
/* static */
void
NS_DataChannelAppReady(nsIDOMDataChannel* aDomDataChannel)
{
((nsDOMDataChannel *)aDomDataChannel)->AppReady();
}