netwerk/cache2/CacheIndexIterator.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #ifndef CacheIndexIterator__h__
     6 #define CacheIndexIterator__h__
     8 #include "nsTArray.h"
     9 #include "nsCOMPtr.h"
    10 #include "nsAutoPtr.h"
    11 #include "mozilla/SHA1.h"
    13 namespace mozilla {
    14 namespace net {
    16 class CacheIndex;
    17 struct CacheIndexRecord;
    19 class CacheIndexIterator
    20 {
    21 public:
    22   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CacheIndexIterator)
    24   CacheIndexIterator(CacheIndex *aIndex, bool aAddNew);
    25   virtual ~CacheIndexIterator();
    27   // Returns a hash of a next entry. If there is no entry NS_ERROR_NOT_AVAILABLE
    28   // is returned and the iterator is closed. Other error is returned when the
    29   // iterator is closed for other reason, e.g. shutdown.
    30   nsresult GetNextHash(SHA1Sum::Hash *aHash);
    32   // Closes the iterator. This means the iterator is removed from the list of
    33   // iterators in CacheIndex.
    34   nsresult Close();
    36 protected:
    37   friend class CacheIndex;
    39   nsresult CloseInternal(nsresult aStatus);
    41   bool ShouldBeNewAdded() { return mAddNew; }
    42   virtual void AddRecord(CacheIndexRecord *aRecord);
    43   virtual void AddRecords(const nsTArray<CacheIndexRecord *> &aRecords);
    44   bool RemoveRecord(CacheIndexRecord *aRecord);
    45   bool ReplaceRecord(CacheIndexRecord *aOldRecord,
    46                      CacheIndexRecord *aNewRecord);
    48   nsresult                     mStatus;
    49   nsRefPtr<CacheIndex>         mIndex;
    50   nsTArray<CacheIndexRecord *> mRecords;
    51   bool                         mAddNew;
    52 };
    54 } // net
    55 } // mozilla
    57 #endif

mercurial