LCOV - code coverage report
Current view: top level - dom/base - nsDOMDataChannel.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 14 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 31 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef nsDOMDataChannel_h
       8             : #define nsDOMDataChannel_h
       9             : 
      10             : #include "mozilla/Attributes.h"
      11             : #include "mozilla/DOMEventTargetHelper.h"
      12             : #include "mozilla/dom/DataChannelBinding.h"
      13             : #include "mozilla/dom/TypedArray.h"
      14             : #include "mozilla/net/DataChannelListener.h"
      15             : #include "nsIDOMDataChannel.h"
      16             : #include "nsIInputStream.h"
      17             : 
      18             : 
      19             : namespace mozilla {
      20             : namespace dom {
      21             : class Blob;
      22             : }
      23             : 
      24             : class DataChannel;
      25             : };
      26             : 
      27             : class nsDOMDataChannel final : public mozilla::DOMEventTargetHelper,
      28             :                                public nsIDOMDataChannel,
      29             :                                public mozilla::DataChannelListener
      30             : {
      31             : public:
      32             :   nsDOMDataChannel(already_AddRefed<mozilla::DataChannel>& aDataChannel,
      33             :                    nsPIDOMWindowInner* aWindow);
      34             : 
      35             :   nsresult Init(nsPIDOMWindowInner* aDOMWindow);
      36             : 
      37             :   NS_DECL_ISUPPORTS_INHERITED
      38             :   NS_DECL_NSIDOMDATACHANNEL
      39             : 
      40           0 :   NS_REALLY_FORWARD_NSIDOMEVENTTARGET(mozilla::DOMEventTargetHelper)
      41             : 
      42           0 :   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMDataChannel,
      43             :                                            mozilla::DOMEventTargetHelper)
      44             : 
      45             :   // EventTarget
      46             :   using EventTarget::EventListenerAdded;
      47             :   virtual void EventListenerAdded(nsIAtom* aType) override;
      48             : 
      49             :   using EventTarget::EventListenerRemoved;
      50             :   virtual void EventListenerRemoved(nsIAtom* aType) override;
      51             : 
      52             :   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
      53             :     override;
      54           0 :   nsPIDOMWindowInner* GetParentObject() const
      55             :   {
      56           0 :     return GetOwner();
      57             :   }
      58             : 
      59             :   // WebIDL
      60             :   // Uses XPIDL GetLabel.
      61             :   bool Reliable() const;
      62             :   mozilla::dom::RTCDataChannelState ReadyState() const;
      63             :   uint32_t BufferedAmount() const;
      64             :   uint32_t BufferedAmountLowThreshold() const;
      65             :   void SetBufferedAmountLowThreshold(uint32_t aThreshold);
      66           0 :   IMPL_EVENT_HANDLER(open)
      67           0 :   IMPL_EVENT_HANDLER(error)
      68           0 :   IMPL_EVENT_HANDLER(close)
      69             :   // Uses XPIDL Close.
      70           0 :   IMPL_EVENT_HANDLER(message)
      71           0 :   IMPL_EVENT_HANDLER(bufferedamountlow)
      72           0 :   mozilla::dom::RTCDataChannelType BinaryType() const
      73             :   {
      74             :     return static_cast<mozilla::dom::RTCDataChannelType>(
      75           0 :       static_cast<int>(mBinaryType));
      76             :   }
      77           0 :   void SetBinaryType(mozilla::dom::RTCDataChannelType aType)
      78             :   {
      79           0 :     mBinaryType = static_cast<DataChannelBinaryType>(
      80             :       static_cast<int>(aType));
      81           0 :   }
      82             :   void Send(const nsAString& aData, mozilla::ErrorResult& aRv);
      83             :   void Send(mozilla::dom::Blob& aData, mozilla::ErrorResult& aRv);
      84             :   void Send(const mozilla::dom::ArrayBuffer& aData, mozilla::ErrorResult& aRv);
      85             :   void Send(const mozilla::dom::ArrayBufferView& aData,
      86             :             mozilla::ErrorResult& aRv);
      87             : 
      88             :   // Uses XPIDL GetProtocol.
      89             :   bool Ordered() const;
      90             :   uint16_t Id() const;
      91             : 
      92             :   nsresult
      93             :   DoOnMessageAvailable(const nsACString& aMessage, bool aBinary);
      94             : 
      95             :   virtual nsresult
      96             :   OnMessageAvailable(nsISupports* aContext, const nsACString& aMessage) override;
      97             : 
      98             :   virtual nsresult
      99             :   OnBinaryMessageAvailable(nsISupports* aContext, const nsACString& aMessage) override;
     100             : 
     101             :   virtual nsresult OnSimpleEvent(nsISupports* aContext, const nsAString& aName);
     102             : 
     103             :   virtual nsresult
     104             :   OnChannelConnected(nsISupports* aContext) override;
     105             : 
     106             :   virtual nsresult
     107             :   OnChannelClosed(nsISupports* aContext) override;
     108             : 
     109             :   virtual nsresult
     110             :   OnBufferLow(nsISupports* aContext) override;
     111             : 
     112             :   virtual nsresult
     113             :   NotBuffered(nsISupports* aContext) override;
     114             : 
     115             :   virtual void
     116             :   AppReady();
     117             : 
     118             :   // if there are "strong event listeners" or outgoing not sent messages
     119             :   // then this method keeps the object alive when js doesn't have strong
     120             :   // references to it.
     121             :   void UpdateMustKeepAlive();
     122             :   // ATTENTION, when calling this method the object can be released
     123             :   // (and possibly collected).
     124             :   void DontKeepAliveAnyMore();
     125             : 
     126             : protected:
     127             :   ~nsDOMDataChannel();
     128             : 
     129             : private:
     130             :   void Send(nsIInputStream* aMsgStream, const nsACString& aMsgString,
     131             :             uint32_t aMsgLength, bool aIsBinary, mozilla::ErrorResult& aRv);
     132             : 
     133             :   // to keep us alive while we have listeners
     134             :   RefPtr<nsDOMDataChannel> mSelfRef;
     135             :   // Owning reference
     136             :   RefPtr<mozilla::DataChannel> mDataChannel;
     137             :   nsString  mOrigin;
     138             :   enum DataChannelBinaryType {
     139             :     DC_BINARY_TYPE_ARRAYBUFFER,
     140             :     DC_BINARY_TYPE_BLOB,
     141             :   };
     142             :   DataChannelBinaryType mBinaryType;
     143             :   bool mCheckMustKeepAlive;
     144             :   bool mSentClose;
     145             : };
     146             : 
     147             : #endif // nsDOMDataChannel_h

Generated by: LCOV version 1.13