dom/quota/UsageInfo.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set ts=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/. */
     7 #ifndef mozilla_dom_quota_usageinfo_h__
     8 #define mozilla_dom_quota_usageinfo_h__
    10 #include "mozilla/dom/quota/QuotaCommon.h"
    12 #include "mozilla/Atomics.h"
    13 #include "Utilities.h"
    15 BEGIN_QUOTA_NAMESPACE
    17 class UsageInfo
    18 {
    19 public:
    20   UsageInfo()
    21   : mCanceled(false), mDatabaseUsage(0), mFileUsage(0)
    22   { }
    24   virtual ~UsageInfo()
    25   { }
    27   bool
    28   Canceled()
    29   {
    30     return mCanceled;
    31   }
    33   void
    34   AppendToDatabaseUsage(uint64_t aUsage)
    35   {
    36     IncrementUsage(&mDatabaseUsage, aUsage);
    37   }
    39   void
    40   AppendToFileUsage(uint64_t aUsage)
    41   {
    42     IncrementUsage(&mFileUsage, aUsage);
    43   }
    45   uint64_t
    46   DatabaseUsage()
    47   {
    48     return mDatabaseUsage;
    49   }
    51   uint64_t
    52   FileUsage()
    53   {
    54     return mFileUsage;
    55   }
    57   uint64_t
    58   TotalUsage()
    59   {
    60     uint64_t totalUsage = mDatabaseUsage;
    61     IncrementUsage(&totalUsage, mFileUsage);
    62     return totalUsage;
    63   }
    65   void
    66   ResetUsage()
    67   {
    68     mDatabaseUsage = 0;
    69     mFileUsage = 0;
    70   }
    72 protected:
    73   mozilla::Atomic<bool> mCanceled;
    75 private:
    76   uint64_t mDatabaseUsage;
    77   uint64_t mFileUsage;
    78 };
    80 END_QUOTA_NAMESPACE
    82 #endif // mozilla_dom_quota_usageinfo_h__

mercurial