LCOV - code coverage report
Current view: top level - dom/fetch - Response.h (source / functions) Hit Total Coverage
Test: output.info Lines: 8 27 29.6 %
Date: 2017-07-14 16:53:18 Functions: 8 19 42.1 %
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_Response_h
       8             : #define mozilla_dom_Response_h
       9             : 
      10             : #include "nsWrapperCache.h"
      11             : #include "nsISupportsImpl.h"
      12             : 
      13             : #include "mozilla/dom/Fetch.h"
      14             : #include "mozilla/dom/ResponseBinding.h"
      15             : 
      16             : #include "InternalHeaders.h"
      17             : #include "InternalResponse.h"
      18             : 
      19             : namespace mozilla {
      20             : namespace ipc {
      21             : class PrincipalInfo;
      22             : } // namespace ipc
      23             : 
      24             : namespace dom {
      25             : 
      26             : class Headers;
      27             : 
      28             : class Response final : public nsISupports
      29             :                      , public FetchBody<Response>
      30             :                      , public nsWrapperCache
      31             : {
      32             :   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
      33          21 :   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Response)
      34             : 
      35             : public:
      36             :   Response(nsIGlobalObject* aGlobal, InternalResponse* aInternalResponse);
      37             : 
      38             :   Response(const Response& aOther) = delete;
      39             : 
      40             :   JSObject*
      41           1 :   WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
      42             :   {
      43           1 :     return ResponseBinding::Wrap(aCx, this, aGivenProto);
      44             :   }
      45             : 
      46             :   ResponseType
      47           0 :   Type() const
      48             :   {
      49           0 :     return mInternalResponse->Type();
      50             :   }
      51             :   void
      52           0 :   GetUrl(nsAString& aUrl) const
      53             :   {
      54           0 :     CopyUTF8toUTF16(mInternalResponse->GetURL(), aUrl);
      55           0 :   }
      56             :   bool
      57           0 :   Redirected() const
      58             :   {
      59           0 :     return mInternalResponse->IsRedirected();
      60             :   }
      61             :   uint16_t
      62           0 :   Status() const
      63             :   {
      64           0 :     return mInternalResponse->GetStatus();
      65             :   }
      66             : 
      67             :   bool
      68           0 :   Ok() const
      69             :   {
      70           0 :     return mInternalResponse->GetStatus() >= 200 &&
      71           0 :            mInternalResponse->GetStatus() <= 299;
      72             :   }
      73             : 
      74             :   void
      75           0 :   GetStatusText(nsCString& aStatusText) const
      76             :   {
      77           0 :     aStatusText = mInternalResponse->GetStatusText();
      78           0 :   }
      79             : 
      80             :   InternalHeaders*
      81           2 :   GetInternalHeaders() const
      82             :   {
      83           2 :     return mInternalResponse->Headers();
      84             :   }
      85             : 
      86             :   void
      87             :   InitChannelInfo(nsIChannel* aChannel)
      88             :   {
      89             :     mInternalResponse->InitChannelInfo(aChannel);
      90             :   }
      91             : 
      92             :   const ChannelInfo&
      93           0 :   GetChannelInfo() const
      94             :   {
      95           0 :     return mInternalResponse->GetChannelInfo();
      96             :   }
      97             : 
      98             :   const UniquePtr<mozilla::ipc::PrincipalInfo>&
      99           0 :   GetPrincipalInfo() const
     100             :   {
     101           0 :     return mInternalResponse->GetPrincipalInfo();
     102             :   }
     103             : 
     104             :   Headers* Headers_();
     105             : 
     106             :   void
     107           1 :   GetBody(nsIInputStream** aStream) { return mInternalResponse->GetBody(aStream); }
     108             : 
     109             :   static already_AddRefed<Response>
     110             :   Error(const GlobalObject& aGlobal);
     111             : 
     112             :   static already_AddRefed<Response>
     113             :   Redirect(const GlobalObject& aGlobal, const nsAString& aUrl, uint16_t aStatus, ErrorResult& aRv);
     114             : 
     115             :   static already_AddRefed<Response>
     116             :   Constructor(const GlobalObject& aGlobal,
     117             :               const Optional<fetch::BodyInit>& aBody,
     118             :               const ResponseInit& aInit, ErrorResult& rv);
     119             : 
     120           3 :   nsIGlobalObject* GetParentObject() const
     121             :   {
     122           3 :     return mOwner;
     123             :   }
     124             : 
     125             :   already_AddRefed<Response>
     126             :   Clone(ErrorResult& aRv) const;
     127             : 
     128             :   already_AddRefed<Response>
     129             :   CloneUnfiltered(ErrorResult& aRv) const;
     130             : 
     131             :   void
     132             :   SetBody(nsIInputStream* aBody, int64_t aBodySize);
     133             : 
     134             :   already_AddRefed<InternalResponse>
     135             :   GetInternalResponse() const;
     136             : 
     137             : private:
     138             :   ~Response();
     139             : 
     140             :   RefPtr<InternalResponse> mInternalResponse;
     141             :   // Lazily created
     142             :   RefPtr<Headers> mHeaders;
     143             : };
     144             : 
     145             : } // namespace dom
     146             : } // namespace mozilla
     147             : 
     148             : #endif // mozilla_dom_Response_h

Generated by: LCOV version 1.13