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