LCOV - code coverage report
Current view: top level - netwerk/protocol/about - nsAboutBlank.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 24 25 96.0 %
Date: 2017-07-14 16:53:18 Functions: 6 6 100.0 %
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 "nsAboutBlank.h"
       7             : #include "nsStringStream.h"
       8             : #include "nsNetUtil.h"
       9             : #include "nsContentUtils.h"
      10             : 
      11         264 : NS_IMPL_ISUPPORTS(nsAboutBlank, nsIAboutModule)
      12             : 
      13             : NS_IMETHODIMP
      14           4 : nsAboutBlank::NewChannel(nsIURI* aURI,
      15             :                          nsILoadInfo* aLoadInfo,
      16             :                          nsIChannel** result)
      17             : {
      18           4 :     NS_ENSURE_ARG_POINTER(aURI);
      19             : 
      20           8 :     nsCOMPtr<nsIInputStream> in;
      21           4 :     nsresult rv = NS_NewCStringInputStream(getter_AddRefs(in), EmptyCString());
      22           4 :     if (NS_FAILED(rv)) return rv;
      23             : 
      24           8 :     nsCOMPtr<nsIChannel> channel;
      25          12 :     rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
      26             :                                           aURI,
      27             :                                           in,
      28           8 :                                           NS_LITERAL_CSTRING("text/html"),
      29           8 :                                           NS_LITERAL_CSTRING("utf-8"),
      30          12 :                                           aLoadInfo);
      31           4 :     if (NS_FAILED(rv)) return rv;
      32             : 
      33           4 :     channel.forget(result);
      34           4 :     return rv;
      35             : }
      36             : 
      37             : NS_IMETHODIMP
      38          42 : nsAboutBlank::GetURIFlags(nsIURI *aURI, uint32_t *result)
      39             : {
      40          42 :     *result = nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
      41             :               nsIAboutModule::URI_CAN_LOAD_IN_CHILD |
      42             :               nsIAboutModule::MAKE_LINKABLE |
      43             :               nsIAboutModule::HIDE_FROM_ABOUTABOUT;
      44          42 :     return NS_OK;
      45             : }
      46             : 
      47             : nsresult
      48           2 : nsAboutBlank::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
      49             : {
      50           2 :     nsAboutBlank* about = new nsAboutBlank();
      51           2 :     if (about == nullptr)
      52           0 :         return NS_ERROR_OUT_OF_MEMORY;
      53           2 :     NS_ADDREF(about);
      54           2 :     nsresult rv = about->QueryInterface(aIID, aResult);
      55           2 :     NS_RELEASE(about);
      56           2 :     return rv;
      57             : }
      58             : 
      59             : ////////////////////////////////////////////////////////////////////////////////

Generated by: LCOV version 1.13