LCOV - code coverage report
Current view: top level - xpcom/io - SnappyFrameUtils.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 2 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 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 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_SnappyFrameUtils_h__
       8             : #define mozilla_SnappyFrameUtils_h__
       9             : 
      10             : #include "mozilla/Attributes.h"
      11             : #include "nsError.h"
      12             : 
      13             : namespace mozilla {
      14             : namespace detail {
      15             : 
      16             : //
      17             : // Utility class providing primitives necessary to build streams based
      18             : // on the snappy compressor.  This essentially abstracts the framing format
      19             : // defined in:
      20             : //
      21             : //  other-licences/snappy/src/framing_format.txt
      22             : //
      23             : // NOTE: Currently only the StreamIdentifier and CompressedData chunks are
      24             : //       supported.
      25             : //
      26             : class SnappyFrameUtils
      27             : {
      28             : public:
      29             :   enum ChunkType
      30             :   {
      31             :     Unknown,
      32             :     StreamIdentifier,
      33             :     CompressedData,
      34             :     UncompressedData,
      35             :     Padding,
      36             :     Reserved,
      37             :     ChunkTypeCount
      38             :   };
      39             : 
      40             :   static const size_t kChunkTypeLength = 1;
      41             :   static const size_t kChunkLengthLength = 3;
      42             :   static const size_t kHeaderLength = kChunkTypeLength + kChunkLengthLength;
      43             :   static const size_t kStreamIdentifierDataLength = 6;
      44             :   static const size_t kCRCLength = 4;
      45             : 
      46             :   static nsresult
      47             :   WriteStreamIdentifier(char* aDest, size_t aDestLength,
      48             :                         size_t* aBytesWrittenOut);
      49             : 
      50             :   static nsresult
      51             :   WriteCompressedData(char* aDest, size_t aDestLength,
      52             :                       const char* aData, size_t aDataLength,
      53             :                       size_t* aBytesWrittenOut);
      54             : 
      55             :   static nsresult
      56             :   ParseHeader(const char* aSource, size_t aSourceLength, ChunkType* aTypeOut,
      57             :               size_t* aDataLengthOut);
      58             : 
      59             :   static nsresult
      60             :   ParseData(char* aDest, size_t aDestLength,
      61             :             ChunkType aType, const char* aData, size_t aDataLength,
      62             :             size_t* aBytesWrittenOut, size_t* aBytesReadOut);
      63             : 
      64             :   static nsresult
      65             :   ParseStreamIdentifier(char* aDest, size_t aDestLength,
      66             :                         const char* aData, size_t aDataLength,
      67             :                         size_t* aBytesWrittenOut, size_t* aBytesReadOut);
      68             : 
      69             :   static nsresult
      70             :   ParseCompressedData(char* aDest, size_t aDestLength,
      71             :                       const char* aData, size_t aDataLength,
      72             :                       size_t* aBytesWrittenOut, size_t* aBytesReadOut);
      73             : 
      74             :   static size_t
      75             :   MaxCompressedBufferLength(size_t aSourceLength);
      76             : 
      77             : protected:
      78           0 :   SnappyFrameUtils() { }
      79           0 :   virtual ~SnappyFrameUtils() { }
      80             : };
      81             : 
      82             : } // namespace detail
      83             : } // namespace mozilla
      84             : 
      85             : #endif // mozilla_SnappyFrameUtils_h__

Generated by: LCOV version 1.13