Bumping gaia.json for 8 gaia revision(s) a=gaia-bump
[gecko.git] / netwerk / cache2 / CacheIndexIterator.h
blob1ca005c1ffe5a0724a03087860b24839a2478f2f
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
21 public:
22 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CacheIndexIterator)
24 CacheIndexIterator(CacheIndex *aIndex, bool aAddNew);
26 protected:
27 virtual ~CacheIndexIterator();
29 public:
30 // Returns a hash of a next entry. If there is no entry NS_ERROR_NOT_AVAILABLE
31 // is returned and the iterator is closed. Other error is returned when the
32 // iterator is closed for other reason, e.g. shutdown.
33 nsresult GetNextHash(SHA1Sum::Hash *aHash);
35 // Closes the iterator. This means the iterator is removed from the list of
36 // iterators in CacheIndex.
37 nsresult Close();
39 protected:
40 friend class CacheIndex;
42 nsresult CloseInternal(nsresult aStatus);
44 bool ShouldBeNewAdded() { return mAddNew; }
45 virtual void AddRecord(CacheIndexRecord *aRecord);
46 virtual void AddRecords(const nsTArray<CacheIndexRecord *> &aRecords);
47 bool RemoveRecord(CacheIndexRecord *aRecord);
48 bool ReplaceRecord(CacheIndexRecord *aOldRecord,
49 CacheIndexRecord *aNewRecord);
51 nsresult mStatus;
52 nsRefPtr<CacheIndex> mIndex;
53 nsTArray<CacheIndexRecord *> mRecords;
54 bool mAddNew;
57 } // net
58 } // mozilla
60 #endif