LCOV - code coverage report
Current view: top level - netwerk/cache - nsDiskCacheStreams.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 5 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2             :  *
       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             : 
       8             : #ifndef _nsDiskCacheStreams_h_
       9             : #define _nsDiskCacheStreams_h_
      10             : 
      11             : #include "mozilla/MemoryReporting.h"
      12             : #include "nsDiskCacheBinding.h"
      13             : 
      14             : #include "nsCache.h"
      15             : 
      16             : #include "nsIInputStream.h"
      17             : #include "nsIOutputStream.h"
      18             : 
      19             : #include "mozilla/Atomics.h"
      20             : 
      21             : class nsDiskCacheDevice;
      22             : 
      23             : class nsDiskCacheStreamIO : public nsIOutputStream {
      24             : public:
      25             :     explicit nsDiskCacheStreamIO(nsDiskCacheBinding *   binding);
      26             : 
      27             :     NS_DECL_THREADSAFE_ISUPPORTS
      28             :     NS_DECL_NSIOUTPUTSTREAM
      29             : 
      30             :     nsresult    GetInputStream(uint32_t offset, nsIInputStream ** inputStream);
      31             :     nsresult    GetOutputStream(uint32_t offset, nsIOutputStream ** outputStream);
      32             : 
      33             :     nsresult    ClearBinding();
      34             : 
      35           0 :     void        IncrementInputStreamCount() { mInStreamCount++; }
      36           0 :     void        DecrementInputStreamCount()
      37             :                 {
      38           0 :                     mInStreamCount--;
      39           0 :                     NS_ASSERTION(mInStreamCount >= 0, "mInStreamCount has gone negative");
      40           0 :                 }
      41             : 
      42             :     size_t     SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf);
      43             : 
      44             :     // GCC 2.95.2 requires this to be defined, although we never call it.
      45             :     // and OS/2 requires that it not be private
      46             :     nsDiskCacheStreamIO() { NS_NOTREACHED("oops"); }
      47             : 
      48             : private:
      49             :     virtual ~nsDiskCacheStreamIO();
      50             : 
      51             :     nsresult    OpenCacheFile(int flags, PRFileDesc ** fd);
      52             :     nsresult    ReadCacheBlocks(uint32_t bufferSize);
      53             :     nsresult    FlushBufferToFile();
      54             :     void        UpdateFileSize();
      55             :     void        DeleteBuffer();
      56             :     nsresult    CloseOutputStream();
      57             :     nsresult    SeekAndTruncate(uint32_t offset);
      58             : 
      59             :     nsDiskCacheBinding *        mBinding;       // not an owning reference
      60             :     nsDiskCacheDevice *         mDevice;
      61             :     mozilla::Atomic<int32_t>                     mInStreamCount;
      62             :     PRFileDesc *                mFD;
      63             : 
      64             :     uint32_t                    mStreamEnd;     // current size of data
      65             :     uint32_t                    mBufSize;       // current end of buffer
      66             :     char *                      mBuffer;
      67             :     bool                        mOutputStreamIsOpen;
      68             : };
      69             : 
      70             : #endif // _nsDiskCacheStreams_h_

Generated by: LCOV version 1.13