LCOV - code coverage report
Current view: top level - netwerk/protocol/http - AltDataOutputStreamParent.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 37 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 10 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 sw=2 ts=8 et tw=80 : */
       3             : 
       4             : /* This Source Code Form is subject to the terms of the Mozilla Public
       5             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       6             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       7             : 
       8             : #include "mozilla/net/AltDataOutputStreamParent.h"
       9             : #include "mozilla/Unused.h"
      10             : 
      11             : namespace mozilla {
      12             : namespace net {
      13             : 
      14           0 : NS_IMPL_ISUPPORTS0(AltDataOutputStreamParent)
      15             : 
      16           0 : AltDataOutputStreamParent::AltDataOutputStreamParent(nsIOutputStream* aStream)
      17             :   : mOutputStream(aStream)
      18             :   , mStatus(NS_OK)
      19           0 :   , mIPCOpen(true)
      20             : {
      21           0 :   MOZ_ASSERT(NS_IsMainThread(), "Main thread only");
      22           0 : }
      23             : 
      24           0 : AltDataOutputStreamParent::~AltDataOutputStreamParent()
      25             : {
      26           0 :   MOZ_ASSERT(NS_IsMainThread(), "Main thread only");
      27           0 : }
      28             : 
      29             : mozilla::ipc::IPCResult
      30           0 : AltDataOutputStreamParent::RecvWriteData(const nsCString& data)
      31             : {
      32           0 :   if (NS_FAILED(mStatus)) {
      33           0 :     if (mIPCOpen) {
      34           0 :       Unused << SendError(mStatus);
      35             :     }
      36           0 :     return IPC_OK();
      37             :   }
      38             :   nsresult rv;
      39             :   uint32_t n;
      40           0 :   if (mOutputStream) {
      41           0 :     rv = mOutputStream->Write(data.BeginReading(), data.Length(), &n);
      42           0 :     MOZ_ASSERT(n == data.Length() || NS_FAILED(rv));
      43           0 :     if (NS_FAILED(rv) && mIPCOpen) {
      44           0 :       Unused << SendError(rv);
      45             :     }
      46             :   }
      47           0 :   return IPC_OK();
      48             : }
      49             : 
      50             : mozilla::ipc::IPCResult
      51           0 : AltDataOutputStreamParent::RecvClose()
      52             : {
      53           0 :   if (NS_FAILED(mStatus)) {
      54           0 :     if (mIPCOpen) {
      55           0 :       Unused << SendError(mStatus);
      56             :     }
      57           0 :     return IPC_OK();
      58             :   }
      59             :   nsresult rv;
      60           0 :   if (mOutputStream) {
      61           0 :     rv = mOutputStream->Close();
      62           0 :     if (NS_FAILED(rv) && mIPCOpen) {
      63           0 :       Unused << SendError(rv);
      64             :     }
      65           0 :     mOutputStream = nullptr;
      66             :   }
      67           0 :   return IPC_OK();
      68             : }
      69             : 
      70             : void
      71           0 : AltDataOutputStreamParent::ActorDestroy(ActorDestroyReason aWhy)
      72             : {
      73           0 :   mIPCOpen = false;
      74           0 : }
      75             : 
      76             : mozilla::ipc::IPCResult
      77           0 : AltDataOutputStreamParent::RecvDeleteSelf()
      78             : {
      79           0 :   mIPCOpen = false;
      80           0 :   Unused << SendDeleteSelf();
      81           0 :   return IPC_OK();
      82             : }
      83             : 
      84             : } // namespace net
      85             : } // namespace mozilla

Generated by: LCOV version 1.13