LCOV - code coverage report
Current view: top level - dom/fetch - Headers.h (source / functions) Hit Total Coverage
Test: output.info Lines: 1 33 3.0 %
Date: 2017-07-14 16:53:18 Functions: 1 20 5.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 mozilla_dom_Headers_h
       8             : #define mozilla_dom_Headers_h
       9             : 
      10             : #include "mozilla/dom/HeadersBinding.h"
      11             : 
      12             : #include "nsClassHashtable.h"
      13             : #include "nsWrapperCache.h"
      14             : 
      15             : #include "InternalHeaders.h"
      16             : 
      17             : namespace mozilla {
      18             : 
      19             : class ErrorResult;
      20             : 
      21             : namespace dom {
      22             : 
      23             : template<typename K, typename V> class Record;
      24             : class HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord;
      25             : class OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord;
      26             : 
      27             : /**
      28             :  * This Headers class is only used to represent the content facing Headers
      29             :  * object. It is actually backed by an InternalHeaders implementation. Gecko
      30             :  * code should NEVER use this, except in the Request and Response
      31             :  * implementations, where they must always be created from the backing
      32             :  * InternalHeaders object.
      33             :  */
      34             : class Headers final : public nsISupports
      35             :                     , public nsWrapperCache
      36             : {
      37             :   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
      38           1 :   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Headers)
      39             : 
      40             :   friend class Request;
      41             :   friend class Response;
      42             : 
      43             : private:
      44             :   nsCOMPtr<nsISupports> mOwner;
      45             :   RefPtr<InternalHeaders> mInternalHeaders;
      46             : 
      47             : public:
      48           0 :   explicit Headers(nsISupports* aOwner, InternalHeaders* aInternalHeaders)
      49           0 :     : mOwner(aOwner)
      50           0 :     , mInternalHeaders(aInternalHeaders)
      51             :   {
      52           0 :   }
      53             : 
      54             :   explicit Headers(const Headers& aOther) = delete;
      55             : 
      56             :   static bool PrefEnabled(JSContext* cx, JSObject* obj);
      57             : 
      58             :   static already_AddRefed<Headers>
      59             :   Constructor(const GlobalObject& aGlobal,
      60             :               const Optional<HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord>& aInit,
      61             :               ErrorResult& aRv);
      62             : 
      63             :   static already_AddRefed<Headers>
      64             :   Constructor(const GlobalObject& aGlobal,
      65             :               const OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord& aInit,
      66             :               ErrorResult& aRv);
      67             : 
      68             :   static already_AddRefed<Headers>
      69             :   Create(nsIGlobalObject* aGlobalObject,
      70             :          const OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord& aInit,
      71             :          ErrorResult& aRv);
      72             : 
      73           0 :   void Append(const nsACString& aName, const nsACString& aValue,
      74             :               ErrorResult& aRv)
      75             :   {
      76           0 :     mInternalHeaders->Append(aName, aValue, aRv);
      77           0 :   }
      78             : 
      79           0 :   void Delete(const nsACString& aName, ErrorResult& aRv)
      80             :   {
      81           0 :     mInternalHeaders->Delete(aName, aRv);
      82           0 :   }
      83             : 
      84           0 :   void Get(const nsACString& aName, nsACString& aValue, ErrorResult& aRv) const
      85             :   {
      86           0 :     mInternalHeaders->Get(aName, aValue, aRv);
      87           0 :   }
      88             : 
      89             :   void GetFirst(const nsACString& aName, nsACString& aValue, ErrorResult& aRv) const
      90             :   {
      91             :     mInternalHeaders->GetFirst(aName, aValue, aRv);
      92             :   }
      93             : 
      94           0 :   bool Has(const nsACString& aName, ErrorResult& aRv) const
      95             :   {
      96           0 :     return mInternalHeaders->Has(aName, aRv);
      97             :   }
      98             : 
      99           0 :   void Set(const nsACString& aName, const nsACString& aValue, ErrorResult& aRv)
     100             :   {
     101           0 :     mInternalHeaders->Set(aName, aValue, aRv);
     102           0 :   }
     103             : 
     104           0 :   uint32_t GetIterableLength() const
     105             :   {
     106           0 :     return mInternalHeaders->GetIterableLength();
     107             :   }
     108           0 :   const nsString GetKeyAtIndex(unsigned aIndex) const
     109             :   {
     110           0 :     return mInternalHeaders->GetKeyAtIndex(aIndex);
     111             :   }
     112           0 :   const nsString GetValueAtIndex(unsigned aIndex) const
     113             :   {
     114           0 :     return mInternalHeaders->GetValueAtIndex(aIndex);
     115             :   }
     116             : 
     117             :   // ChromeOnly
     118           0 :   HeadersGuardEnum Guard() const
     119             :   {
     120           0 :     return mInternalHeaders->Guard();
     121             :   }
     122             : 
     123           0 :   void SetGuard(HeadersGuardEnum aGuard, ErrorResult& aRv)
     124             :   {
     125           0 :     mInternalHeaders->SetGuard(aGuard, aRv);
     126           0 :   }
     127             : 
     128             :   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
     129           0 :   nsISupports* GetParentObject() const { return mOwner; }
     130             : 
     131             : private:
     132             :   virtual ~Headers();
     133             : 
     134             :   InternalHeaders*
     135           0 :   GetInternalHeaders() const
     136             :   {
     137           0 :     return mInternalHeaders;
     138             :   }
     139             : };
     140             : 
     141             : } // namespace dom
     142             : } // namespace mozilla
     143             : 
     144             : #endif // mozilla_dom_Headers_h

Generated by: LCOV version 1.13