content/base/src/nsDOMDataChannel.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set sw=2 ts=8 et tw=80 : */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef nsDOMDataChannel_h
michael@0 8 #define nsDOMDataChannel_h
michael@0 9
michael@0 10 #include "mozilla/Attributes.h"
michael@0 11 #include "mozilla/DOMEventTargetHelper.h"
michael@0 12 #include "mozilla/dom/DataChannelBinding.h"
michael@0 13 #include "mozilla/dom/TypedArray.h"
michael@0 14 #include "mozilla/net/DataChannelListener.h"
michael@0 15 #include "nsIDOMDataChannel.h"
michael@0 16 #include "nsIInputStream.h"
michael@0 17
michael@0 18
michael@0 19 namespace mozilla {
michael@0 20 class DataChannel;
michael@0 21 };
michael@0 22
michael@0 23 class nsDOMDataChannel : public mozilla::DOMEventTargetHelper,
michael@0 24 public nsIDOMDataChannel,
michael@0 25 public mozilla::DataChannelListener
michael@0 26 {
michael@0 27 public:
michael@0 28 nsDOMDataChannel(already_AddRefed<mozilla::DataChannel>& aDataChannel,
michael@0 29 nsPIDOMWindow* aWindow);
michael@0 30 ~nsDOMDataChannel();
michael@0 31
michael@0 32 nsresult Init(nsPIDOMWindow* aDOMWindow);
michael@0 33
michael@0 34 NS_DECL_ISUPPORTS_INHERITED
michael@0 35 NS_DECL_NSIDOMDATACHANNEL
michael@0 36
michael@0 37 NS_REALLY_FORWARD_NSIDOMEVENTTARGET(mozilla::DOMEventTargetHelper)
michael@0 38
michael@0 39 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMDataChannel,
michael@0 40 mozilla::DOMEventTargetHelper)
michael@0 41
michael@0 42 virtual JSObject* WrapObject(JSContext* aCx)
michael@0 43 MOZ_OVERRIDE;
michael@0 44 nsPIDOMWindow* GetParentObject() const
michael@0 45 {
michael@0 46 return GetOwner();
michael@0 47 }
michael@0 48
michael@0 49 // WebIDL
michael@0 50 // Uses XPIDL GetLabel.
michael@0 51 bool Reliable() const;
michael@0 52 mozilla::dom::RTCDataChannelState ReadyState() const;
michael@0 53 uint32_t BufferedAmount() const;
michael@0 54 IMPL_EVENT_HANDLER(open)
michael@0 55 IMPL_EVENT_HANDLER(error)
michael@0 56 IMPL_EVENT_HANDLER(close)
michael@0 57 // Uses XPIDL Close.
michael@0 58 IMPL_EVENT_HANDLER(message)
michael@0 59 mozilla::dom::RTCDataChannelType BinaryType() const
michael@0 60 {
michael@0 61 return static_cast<mozilla::dom::RTCDataChannelType>(
michael@0 62 static_cast<int>(mBinaryType));
michael@0 63 }
michael@0 64 void SetBinaryType(mozilla::dom::RTCDataChannelType aType)
michael@0 65 {
michael@0 66 mBinaryType = static_cast<DataChannelBinaryType>(
michael@0 67 static_cast<int>(aType));
michael@0 68 }
michael@0 69 void Send(const nsAString& aData, mozilla::ErrorResult& aRv);
michael@0 70 void Send(nsIDOMBlob* aData, mozilla::ErrorResult& aRv);
michael@0 71 void Send(const mozilla::dom::ArrayBuffer& aData, mozilla::ErrorResult& aRv);
michael@0 72 void Send(const mozilla::dom::ArrayBufferView& aData,
michael@0 73 mozilla::ErrorResult& aRv);
michael@0 74
michael@0 75 // Uses XPIDL GetProtocol.
michael@0 76 bool Ordered() const;
michael@0 77 uint16_t Id() const;
michael@0 78 uint16_t Stream() const; // deprecated
michael@0 79
michael@0 80 nsresult
michael@0 81 DoOnMessageAvailable(const nsACString& aMessage, bool aBinary);
michael@0 82
michael@0 83 virtual nsresult
michael@0 84 OnMessageAvailable(nsISupports* aContext, const nsACString& aMessage) MOZ_OVERRIDE;
michael@0 85
michael@0 86 virtual nsresult
michael@0 87 OnBinaryMessageAvailable(nsISupports* aContext, const nsACString& aMessage) MOZ_OVERRIDE;
michael@0 88
michael@0 89 virtual nsresult OnSimpleEvent(nsISupports* aContext, const nsAString& aName);
michael@0 90
michael@0 91 virtual nsresult
michael@0 92 OnChannelConnected(nsISupports* aContext) MOZ_OVERRIDE;
michael@0 93
michael@0 94 virtual nsresult
michael@0 95 OnChannelClosed(nsISupports* aContext) MOZ_OVERRIDE;
michael@0 96
michael@0 97 virtual void
michael@0 98 AppReady();
michael@0 99
michael@0 100 private:
michael@0 101 void Send(nsIInputStream* aMsgStream, const nsACString& aMsgString,
michael@0 102 uint32_t aMsgLength, bool aIsBinary, mozilla::ErrorResult& aRv);
michael@0 103
michael@0 104 // Owning reference
michael@0 105 nsRefPtr<mozilla::DataChannel> mDataChannel;
michael@0 106 nsString mOrigin;
michael@0 107 enum DataChannelBinaryType {
michael@0 108 DC_BINARY_TYPE_ARRAYBUFFER,
michael@0 109 DC_BINARY_TYPE_BLOB,
michael@0 110 };
michael@0 111 DataChannelBinaryType mBinaryType;
michael@0 112 };
michael@0 113
michael@0 114 #endif // nsDOMDataChannel_h

mercurial