LCOV - code coverage report
Current view: top level - netwerk/base - nsInputStreamChannel.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 22 41 53.7 %
Date: 2017-07-14 16:53:18 Functions: 7 12 58.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #include "nsInputStreamChannel.h"
       7             : 
       8             : //-----------------------------------------------------------------------------
       9             : // nsInputStreamChannel
      10             : 
      11             : namespace mozilla {
      12             : namespace net {
      13             : 
      14             : nsresult
      15           3 : nsInputStreamChannel::OpenContentStream(bool async, nsIInputStream **result,
      16             :                                         nsIChannel** channel)
      17             : {
      18           3 :   NS_ENSURE_TRUE(mContentStream, NS_ERROR_NOT_INITIALIZED);
      19             : 
      20             :   // If content length is unknown, then we must guess.  In this case, we assume
      21             :   // the stream can tell us.  If the stream is a pipe, then this will not work.
      22             : 
      23           3 :   if (mContentLength < 0) {
      24             :     uint64_t avail;
      25           3 :     nsresult rv = mContentStream->Available(&avail);
      26           3 :     if (rv == NS_BASE_STREAM_CLOSED) {
      27             :       // This just means there's nothing in the stream
      28           0 :       avail = 0;
      29           3 :     } else if (NS_FAILED(rv)) {
      30           0 :       return rv;
      31             :     }
      32           3 :     mContentLength = avail;
      33             :   }
      34             : 
      35           3 :   EnableSynthesizedProgressEvents(true);
      36             : 
      37           3 :   NS_ADDREF(*result = mContentStream);
      38           3 :   return NS_OK;
      39             : }
      40             : 
      41             : //-----------------------------------------------------------------------------
      42             : // nsInputStreamChannel::nsISupports
      43             : 
      44         649 : NS_IMPL_ISUPPORTS_INHERITED(nsInputStreamChannel,
      45             :                             nsBaseChannel,
      46             :                             nsIInputStreamChannel)
      47             : 
      48             : //-----------------------------------------------------------------------------
      49             : // nsInputStreamChannel::nsIInputStreamChannel
      50             : 
      51             : NS_IMETHODIMP
      52           6 : nsInputStreamChannel::SetURI(nsIURI *uri)
      53             : {
      54           6 :   NS_ENSURE_TRUE(!URI(), NS_ERROR_ALREADY_INITIALIZED);
      55           6 :   nsBaseChannel::SetURI(uri);
      56           6 :   return NS_OK;
      57             : }
      58             : 
      59             : NS_IMETHODIMP
      60           0 : nsInputStreamChannel::GetContentStream(nsIInputStream **stream)
      61             : {
      62           0 :   NS_IF_ADDREF(*stream = mContentStream);
      63           0 :   return NS_OK;
      64             : }
      65             : 
      66             : NS_IMETHODIMP
      67           6 : nsInputStreamChannel::SetContentStream(nsIInputStream *stream)
      68             : {
      69           6 :   NS_ENSURE_TRUE(!mContentStream, NS_ERROR_ALREADY_INITIALIZED);
      70           6 :   mContentStream = stream;
      71           6 :   return NS_OK;
      72             : }
      73             : 
      74             : NS_IMETHODIMP
      75           0 : nsInputStreamChannel::GetSrcdocData(nsAString& aSrcdocData)
      76             : {
      77           0 :   aSrcdocData = mSrcdocData;
      78           0 :   return NS_OK;
      79             : }
      80             : 
      81             : NS_IMETHODIMP
      82           0 : nsInputStreamChannel::SetSrcdocData(const nsAString& aSrcdocData)
      83             : {
      84           0 :   mSrcdocData = aSrcdocData;
      85           0 :   mIsSrcdocChannel = true;
      86           0 :   return NS_OK;
      87             : }
      88             : 
      89             : NS_IMETHODIMP
      90           1 : nsInputStreamChannel::GetIsSrcdocChannel(bool *aIsSrcdocChannel)
      91             : {
      92           1 :   *aIsSrcdocChannel = mIsSrcdocChannel;
      93           1 :   return NS_OK;
      94             : }
      95             : 
      96             : NS_IMETHODIMP
      97           0 : nsInputStreamChannel::GetBaseURI(nsIURI** aBaseURI)
      98             : {
      99           0 :   *aBaseURI = mBaseURI;
     100           0 :   NS_IF_ADDREF(*aBaseURI);
     101           0 :   return NS_OK;
     102             : }
     103             : 
     104             : NS_IMETHODIMP
     105           0 : nsInputStreamChannel::SetBaseURI(nsIURI* aBaseURI)
     106             : {
     107           0 :   mBaseURI = aBaseURI;
     108           0 :   return NS_OK;
     109             : }
     110             : 
     111             : } // namespace net
     112             : } // namespace mozilla

Generated by: LCOV version 1.13