LCOV - code coverage report
Current view: top level - dom/quota - UsageInfo.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 39 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 12 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 file,
       5             :  * You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef mozilla_dom_quota_usageinfo_h__
       8             : #define mozilla_dom_quota_usageinfo_h__
       9             : 
      10             : #include "mozilla/dom/quota/QuotaCommon.h"
      11             : 
      12             : #include "mozilla/Atomics.h"
      13             : #include "mozilla/CheckedInt.h"
      14             : 
      15             : BEGIN_QUOTA_NAMESPACE
      16             : 
      17             : class UsageInfo
      18             : {
      19             : public:
      20           0 :   UsageInfo()
      21           0 :     : mDatabaseUsage(0)
      22             :     , mFileUsage(0)
      23           0 :     , mLimit(0)
      24           0 :   { }
      25             : 
      26           0 :   virtual ~UsageInfo()
      27           0 :   { }
      28             : 
      29             :   void
      30           0 :   Append(const UsageInfo& aUsageInfo)
      31             :   {
      32           0 :     IncrementUsage(&mDatabaseUsage, aUsageInfo.mDatabaseUsage);
      33           0 :     IncrementUsage(&mFileUsage, aUsageInfo.mFileUsage);
      34           0 :   }
      35             : 
      36             :   void
      37           0 :   AppendToDatabaseUsage(uint64_t aUsage)
      38             :   {
      39           0 :     IncrementUsage(&mDatabaseUsage, aUsage);
      40           0 :   }
      41             : 
      42             :   void
      43           0 :   AppendToFileUsage(uint64_t aUsage)
      44             :   {
      45           0 :     IncrementUsage(&mFileUsage, aUsage);
      46           0 :   }
      47             : 
      48             :   void
      49           0 :   SetLimit(uint64_t aLimit)
      50             :   {
      51           0 :     mLimit = aLimit;
      52           0 :   }
      53             : 
      54             :   uint64_t
      55             :   DatabaseUsage()
      56             :   {
      57             :     return mDatabaseUsage;
      58             :   }
      59             : 
      60             :   uint64_t
      61           0 :   FileUsage()
      62             :   {
      63           0 :     return mFileUsage;
      64             :   }
      65             : 
      66             :   uint64_t
      67           0 :   Limit()
      68             :   {
      69           0 :     return mLimit;
      70             :   }
      71             : 
      72             :   uint64_t
      73           0 :   TotalUsage()
      74             :   {
      75           0 :     uint64_t totalUsage = mDatabaseUsage;
      76           0 :     IncrementUsage(&totalUsage, mFileUsage);
      77           0 :     return totalUsage;
      78             :   }
      79             : 
      80             :   void
      81           0 :   ResetUsage()
      82             :   {
      83           0 :     mDatabaseUsage = 0;
      84           0 :     mFileUsage = 0;
      85           0 :   }
      86             : 
      87             :   static void
      88           0 :   IncrementUsage(uint64_t* aUsage, uint64_t aDelta)
      89             :   {
      90           0 :     MOZ_ASSERT(aUsage);
      91           0 :     CheckedUint64 value = *aUsage;
      92           0 :     value += aDelta;
      93           0 :     if (value.isValid()) {
      94           0 :       *aUsage = value.value();
      95             :     } else {
      96           0 :       *aUsage = UINT64_MAX;
      97             :     }
      98           0 :   }
      99             : 
     100             : private:
     101             :   uint64_t mDatabaseUsage;
     102             :   uint64_t mFileUsage;
     103             :   uint64_t mLimit;
     104             : };
     105             : 
     106             : END_QUOTA_NAMESPACE
     107             : 
     108             : #endif // mozilla_dom_quota_usageinfo_h__

Generated by: LCOV version 1.13