1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/cache2/CacheIndexIterator.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,57 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#ifndef CacheIndexIterator__h__ 1.9 +#define CacheIndexIterator__h__ 1.10 + 1.11 +#include "nsTArray.h" 1.12 +#include "nsCOMPtr.h" 1.13 +#include "nsAutoPtr.h" 1.14 +#include "mozilla/SHA1.h" 1.15 + 1.16 +namespace mozilla { 1.17 +namespace net { 1.18 + 1.19 +class CacheIndex; 1.20 +struct CacheIndexRecord; 1.21 + 1.22 +class CacheIndexIterator 1.23 +{ 1.24 +public: 1.25 + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CacheIndexIterator) 1.26 + 1.27 + CacheIndexIterator(CacheIndex *aIndex, bool aAddNew); 1.28 + virtual ~CacheIndexIterator(); 1.29 + 1.30 + // Returns a hash of a next entry. If there is no entry NS_ERROR_NOT_AVAILABLE 1.31 + // is returned and the iterator is closed. Other error is returned when the 1.32 + // iterator is closed for other reason, e.g. shutdown. 1.33 + nsresult GetNextHash(SHA1Sum::Hash *aHash); 1.34 + 1.35 + // Closes the iterator. This means the iterator is removed from the list of 1.36 + // iterators in CacheIndex. 1.37 + nsresult Close(); 1.38 + 1.39 +protected: 1.40 + friend class CacheIndex; 1.41 + 1.42 + nsresult CloseInternal(nsresult aStatus); 1.43 + 1.44 + bool ShouldBeNewAdded() { return mAddNew; } 1.45 + virtual void AddRecord(CacheIndexRecord *aRecord); 1.46 + virtual void AddRecords(const nsTArray<CacheIndexRecord *> &aRecords); 1.47 + bool RemoveRecord(CacheIndexRecord *aRecord); 1.48 + bool ReplaceRecord(CacheIndexRecord *aOldRecord, 1.49 + CacheIndexRecord *aNewRecord); 1.50 + 1.51 + nsresult mStatus; 1.52 + nsRefPtr<CacheIndex> mIndex; 1.53 + nsTArray<CacheIndexRecord *> mRecords; 1.54 + bool mAddNew; 1.55 +}; 1.56 + 1.57 +} // net 1.58 +} // mozilla 1.59 + 1.60 +#endif