LCOV - code coverage report
Current view: top level - netwerk/cache - nsDiskCacheEntry.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 33 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 8 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             : #ifndef _nsDiskCacheEntry_h_
       8             : #define _nsDiskCacheEntry_h_
       9             : 
      10             : #include "nsDiskCacheMap.h"
      11             : 
      12             : #include "nsCacheEntry.h"
      13             : 
      14             : 
      15             : /******************************************************************************
      16             :  *  nsDiskCacheEntry
      17             :  *****************************************************************************/
      18             : struct nsDiskCacheEntry {
      19             :     uint32_t        mHeaderVersion; // useful for stand-alone metadata files
      20             :     uint32_t        mMetaLocation;  // for verification
      21             :     int32_t         mFetchCount;
      22             :     uint32_t        mLastFetched;
      23             :     uint32_t        mLastModified;
      24             :     uint32_t        mExpirationTime;
      25             :     uint32_t        mDataSize;
      26             :     uint32_t        mKeySize;       // includes terminating null byte
      27             :     uint32_t        mMetaDataSize;  // includes terminating null byte
      28             :     // followed by key data (mKeySize bytes)
      29             :     // followed by meta data (mMetaDataSize bytes)
      30             : 
      31           0 :     uint32_t        Size()    { return sizeof(nsDiskCacheEntry) +
      32           0 :                                     mKeySize + mMetaDataSize;
      33             :                               }
      34             : 
      35           0 :     char*           Key()     { return reinterpret_cast<char*const>(this) +
      36           0 :                                     sizeof(nsDiskCacheEntry);
      37             :                               }
      38             : 
      39           0 :     char*           MetaData()
      40           0 :                               { return Key() + mKeySize; }
      41             : 
      42             :     nsCacheEntry *  CreateCacheEntry(nsCacheDevice *  device);
      43             : 
      44           0 :     void Swap()         // host to network (memory to disk)
      45             :     {
      46             : #if defined(IS_LITTLE_ENDIAN)
      47           0 :         mHeaderVersion      = htonl(mHeaderVersion);
      48           0 :         mMetaLocation       = htonl(mMetaLocation);
      49           0 :         mFetchCount         = htonl(mFetchCount);
      50           0 :         mLastFetched        = htonl(mLastFetched);
      51           0 :         mLastModified       = htonl(mLastModified);
      52           0 :         mExpirationTime     = htonl(mExpirationTime);
      53           0 :         mDataSize           = htonl(mDataSize);
      54           0 :         mKeySize            = htonl(mKeySize);
      55           0 :         mMetaDataSize       = htonl(mMetaDataSize);
      56             : #endif
      57           0 :     }
      58             : 
      59           0 :     void Unswap()       // network to host (disk to memory)
      60             :     {
      61             : #if defined(IS_LITTLE_ENDIAN)
      62           0 :         mHeaderVersion      = ntohl(mHeaderVersion);
      63           0 :         mMetaLocation       = ntohl(mMetaLocation);
      64           0 :         mFetchCount         = ntohl(mFetchCount);
      65           0 :         mLastFetched        = ntohl(mLastFetched);
      66           0 :         mLastModified       = ntohl(mLastModified);
      67           0 :         mExpirationTime     = ntohl(mExpirationTime);
      68           0 :         mDataSize           = ntohl(mDataSize);
      69           0 :         mKeySize            = ntohl(mKeySize);
      70           0 :         mMetaDataSize       = ntohl(mMetaDataSize);
      71             : #endif
      72           0 :     }
      73             : };
      74             : 
      75             : 
      76             : /******************************************************************************
      77             :  *  nsDiskCacheEntryInfo
      78             :  *****************************************************************************/
      79             : class nsDiskCacheEntryInfo : public nsICacheEntryInfo {
      80             : public:
      81             :     NS_DECL_ISUPPORTS
      82             :     NS_DECL_NSICACHEENTRYINFO
      83             : 
      84           0 :     nsDiskCacheEntryInfo(const char * deviceID, nsDiskCacheEntry * diskEntry)
      85           0 :         : mDeviceID(deviceID)
      86           0 :         , mDiskEntry(diskEntry)
      87             :     {
      88           0 :     }
      89             : 
      90             :     const char* Key() { return mDiskEntry->Key(); }
      91             : 
      92             : private:
      93           0 :     virtual ~nsDiskCacheEntryInfo() {}
      94             : 
      95             :     const char *        mDeviceID;
      96             :     nsDiskCacheEntry *  mDiskEntry;
      97             : };
      98             : 
      99             : 
     100             : #endif /* _nsDiskCacheEntry_h_ */

Generated by: LCOV version 1.13