Update contrib.
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32\sfile\sf_cache_client.h
24 #if !defined(__SF_CACHE_CLIENT_H__)
25 #define __SF_CACHE_CLIENT_H__
27 #include "sf_cache_man.h"
32 NONSHARABLE_CLASS(CCacheClient) : public CBase
36 void Purge(TBool aPurgeDirty = EFalse);
38 TUint8* AllocateAndLockSegments(TInt64 aPos, TInt& aSegmentCount, TBool aMakeDirty, TBool aExtendExisting);
40 TUint8* FindAndLockSegments(TInt64 aPos, TInt& aSegmentCount, TInt& aFilledSegmentCount, TInt& aLockError, TBool aMakeDirty);
41 TUint8* FindSegment(TInt64 aPos);
44 void UnlockSegments(TInt64 aPos);
47 void MarkSegmentsAsFilled(TInt64 aPos, TInt aSegmentCount);
48 void MarkSegmentsAsDirty(TInt64 aPos, TInt aSegmentCount);
50 TInt FindFirstDirtySegment(TInt64& aPos, TUint8*& aAddr);
52 void MarkSegmentsAsClean(TInt64 aPos);
55 void SetMaxSegments(TInt aMaxSegments);
57 TBool SegmentEmpty(TInt64 aPos);
58 TBool SegmentDirty(TInt64 aPos);
59 TBool TooManyLockedSegments();
61 inline TInt CacheOffset(TInt64 aLinAddr) const \
62 {return(I64LOW(aLinAddr)& ((1 << iManager.SegmentSizeLog2())-1));}
65 TInt SegmentSizeLog2();
66 TInt64 SegmentSizeMask();
68 TInt CacheLineSizeInSegments();
70 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
75 // class can only be instantiated from friend class CCacheManager
76 static CCacheClient* NewL(CCacheManager& aManager);
78 CCacheClient(CCacheManager& aManager);
81 TInt LockSegments(TInt64 aPos, TInt aSegmentCount, TBool aMakeDirty);
83 const CCacheManager::TCacheLine* FindCacheLine(TInt64 aPos);
84 TInt FindCacheLineIndex(TInt64 aPos);
86 TBool FreeCacheLine(const CCacheManager::TCacheLine* aCacheLine);
88 void RemoveCacheLine(const CCacheManager::TCacheLine* aCacheLine);
89 void RemoveEmptySegments(const CCacheManager::TCacheLine* aCacheLine);
91 void RemoveLru(const CCacheManager::TCacheLine* aCacheLineToExclude);
93 inline TInt StartSegment(const CCacheManager::TCacheLine* aCacheLine, TInt64 aPos);
94 inline TInt CacheLineLen(const CCacheManager::TCacheLine* aCacheLine);
99 CCacheManager& iManager;
101 // segment array for segments that contain valid data
102 RPointerArray<CCacheManager::TCacheLine>* iCacheLines;
103 TInt iMaxBytesCached;
105 TInt iLastCacheLineIndex;
107 friend class CCacheManager;