зеркало из https://github.com/mozilla/gecko-dev.git
Bug 868778 - Part b: Move the declaration of nsDOMDataChannel into nsDOMDataChannel.h; r=jesup
--HG-- rename : content/base/src/nsDOMDataChannel.cpp => content/base/src/nsDOMDataChannel.h
This commit is contained in:
Родитель
c065e2417e
Коммит
b924575b48
|
@ -2,6 +2,13 @@
|
|||
|
||||
#include "nsIDOMEventTarget.idl"
|
||||
|
||||
%{C++
|
||||
#ifdef GetBinaryType
|
||||
// Windows apparently has a #define for GetBinaryType...
|
||||
#undef GetBinaryType
|
||||
#endif
|
||||
%}
|
||||
|
||||
interface nsIVariant;
|
||||
|
||||
[scriptable, builtinclass, uuid(1aed816d-1156-414e-8fe2-f01daa6021f0)]
|
||||
|
|
|
@ -36,6 +36,7 @@ EXPORTS += [
|
|||
|
||||
if CONFIG['MOZ_WEBRTC']:
|
||||
EXPORTS += [
|
||||
'nsDOMDataChannel.h',
|
||||
'nsDOMDataChannelDeclarations.h',
|
||||
]
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
* 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"
|
||||
|
||||
#ifdef MOZ_LOGGING
|
||||
#define FORCE_PR_LOG
|
||||
#endif
|
||||
|
@ -39,81 +41,20 @@ extern PRLogModuleInfo* GetDataChannelLog();
|
|||
|
||||
#include "DataChannel.h"
|
||||
|
||||
#ifdef GetBinaryType
|
||||
// Windows apparently has a #define for GetBinaryType...
|
||||
#undef GetBinaryType
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
class nsDOMDataChannel : public nsDOMEventTargetHelper,
|
||||
public nsIDOMDataChannel,
|
||||
public mozilla::DataChannelListener
|
||||
{
|
||||
public:
|
||||
nsDOMDataChannel(already_AddRefed<mozilla::DataChannel> aDataChannel)
|
||||
: mDataChannel(aDataChannel)
|
||||
, mBinaryType(DC_BINARY_TYPE_BLOB)
|
||||
{}
|
||||
|
||||
~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();
|
||||
}
|
||||
|
||||
nsresult Init(nsPIDOMWindow* aDOMWindow);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMDATACHANNEL
|
||||
|
||||
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper)
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMDataChannel,
|
||||
nsDOMEventTargetHelper)
|
||||
|
||||
nsresult
|
||||
DoOnMessageAvailable(const nsACString& aMessage, bool aBinary);
|
||||
|
||||
virtual nsresult
|
||||
OnMessageAvailable(nsISupports* aContext, const nsACString& aMessage);
|
||||
|
||||
virtual nsresult
|
||||
OnBinaryMessageAvailable(nsISupports* aContext, const nsACString& aMessage);
|
||||
|
||||
virtual nsresult OnSimpleEvent(nsISupports* aContext, const nsAString& aName);
|
||||
|
||||
virtual nsresult
|
||||
OnChannelConnected(nsISupports* aContext);
|
||||
|
||||
virtual nsresult
|
||||
OnChannelClosed(nsISupports* aContext);
|
||||
|
||||
virtual void
|
||||
AppReady();
|
||||
|
||||
private:
|
||||
// Get msg info out of JS variable being sent (string, arraybuffer, blob)
|
||||
nsresult GetSendParams(nsIVariant *aData, nsCString &aStringOut,
|
||||
nsCOMPtr<nsIInputStream> &aStreamOut,
|
||||
bool &aIsBinary, uint32_t &aOutgoingLength);
|
||||
|
||||
// Owning reference
|
||||
nsRefPtr<mozilla::DataChannel> mDataChannel;
|
||||
nsString mOrigin;
|
||||
enum
|
||||
{
|
||||
DC_BINARY_TYPE_ARRAYBUFFER,
|
||||
DC_BINARY_TYPE_BLOB,
|
||||
} mBinaryType;
|
||||
};
|
||||
|
||||
DOMCI_DATA(DataChannel, nsDOMDataChannel)
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMDataChannel,
|
||||
nsDOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
/* -*- 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/. */
|
||||
|
||||
#ifndef nsDOMDataChannel_h
|
||||
#define nsDOMDataChannel_h
|
||||
|
||||
#include "mozilla/net/DataChannel.h"
|
||||
#include "nsDOMEventTargetHelper.h"
|
||||
#include "nsIDOMDataChannel.h"
|
||||
|
||||
class nsDOMDataChannel : public nsDOMEventTargetHelper,
|
||||
public nsIDOMDataChannel,
|
||||
public mozilla::DataChannelListener
|
||||
{
|
||||
public:
|
||||
nsDOMDataChannel(already_AddRefed<mozilla::DataChannel> aDataChannel)
|
||||
: mDataChannel(aDataChannel)
|
||||
, mBinaryType(DC_BINARY_TYPE_BLOB)
|
||||
{}
|
||||
|
||||
~nsDOMDataChannel();
|
||||
|
||||
nsresult Init(nsPIDOMWindow* aDOMWindow);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMDATACHANNEL
|
||||
|
||||
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper)
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMDataChannel,
|
||||
nsDOMEventTargetHelper)
|
||||
|
||||
nsresult
|
||||
DoOnMessageAvailable(const nsACString& aMessage, bool aBinary);
|
||||
|
||||
virtual nsresult
|
||||
OnMessageAvailable(nsISupports* aContext, const nsACString& aMessage);
|
||||
|
||||
virtual nsresult
|
||||
OnBinaryMessageAvailable(nsISupports* aContext, const nsACString& aMessage);
|
||||
|
||||
virtual nsresult OnSimpleEvent(nsISupports* aContext, const nsAString& aName);
|
||||
|
||||
virtual nsresult
|
||||
OnChannelConnected(nsISupports* aContext);
|
||||
|
||||
virtual nsresult
|
||||
OnChannelClosed(nsISupports* aContext);
|
||||
|
||||
virtual void
|
||||
AppReady();
|
||||
|
||||
private:
|
||||
// Get msg info out of JS variable being sent (string, arraybuffer, blob)
|
||||
nsresult GetSendParams(nsIVariant *aData, nsCString &aStringOut,
|
||||
nsCOMPtr<nsIInputStream> &aStreamOut,
|
||||
bool &aIsBinary, uint32_t &aOutgoingLength);
|
||||
|
||||
// Owning reference
|
||||
nsRefPtr<mozilla::DataChannel> mDataChannel;
|
||||
nsString mOrigin;
|
||||
enum
|
||||
{
|
||||
DC_BINARY_TYPE_ARRAYBUFFER,
|
||||
DC_BINARY_TYPE_BLOB,
|
||||
} mBinaryType;
|
||||
};
|
||||
|
||||
#endif // nsDOMDataChannel_h
|
Загрузка…
Ссылка в новой задаче