sl@0
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// f32\sfile\sf_cache_client.h
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
/**
|
sl@0
|
19 |
@file
|
sl@0
|
20 |
@internalTechnology
|
sl@0
|
21 |
@released
|
sl@0
|
22 |
*/
|
sl@0
|
23 |
|
sl@0
|
24 |
#if !defined(__SF_CACHE_CLIENT_H__)
|
sl@0
|
25 |
#define __SF_CACHE_CLIENT_H__
|
sl@0
|
26 |
|
sl@0
|
27 |
#include "sf_cache_man.h"
|
sl@0
|
28 |
|
sl@0
|
29 |
// fwd refs
|
sl@0
|
30 |
class CCacheManager;
|
sl@0
|
31 |
|
sl@0
|
32 |
NONSHARABLE_CLASS(CCacheClient) : public CBase
|
sl@0
|
33 |
{
|
sl@0
|
34 |
public:
|
sl@0
|
35 |
~CCacheClient();
|
sl@0
|
36 |
void Purge(TBool aPurgeDirty = EFalse);
|
sl@0
|
37 |
|
sl@0
|
38 |
TUint8* AllocateAndLockSegments(TInt64 aPos, TInt& aSegmentCount, TBool aMakeDirty, TBool aExtendExisting);
|
sl@0
|
39 |
|
sl@0
|
40 |
TUint8* FindAndLockSegments(TInt64 aPos, TInt& aSegmentCount, TInt& aFilledSegmentCount, TInt& aLockError, TBool aMakeDirty);
|
sl@0
|
41 |
TUint8* FindSegment(TInt64 aPos);
|
sl@0
|
42 |
|
sl@0
|
43 |
|
sl@0
|
44 |
void UnlockSegments(TInt64 aPos);
|
sl@0
|
45 |
|
sl@0
|
46 |
|
sl@0
|
47 |
void MarkSegmentsAsFilled(TInt64 aPos, TInt aSegmentCount);
|
sl@0
|
48 |
void MarkSegmentsAsDirty(TInt64 aPos, TInt aSegmentCount);
|
sl@0
|
49 |
|
sl@0
|
50 |
TInt FindFirstDirtySegment(TInt64& aPos, TUint8*& aAddr);
|
sl@0
|
51 |
|
sl@0
|
52 |
void MarkSegmentsAsClean(TInt64 aPos);
|
sl@0
|
53 |
|
sl@0
|
54 |
|
sl@0
|
55 |
void SetMaxSegments(TInt aMaxSegments);
|
sl@0
|
56 |
|
sl@0
|
57 |
TBool SegmentEmpty(TInt64 aPos);
|
sl@0
|
58 |
TBool SegmentDirty(TInt64 aPos);
|
sl@0
|
59 |
TBool TooManyLockedSegments();
|
sl@0
|
60 |
|
sl@0
|
61 |
inline TInt CacheOffset(TInt64 aLinAddr) const \
|
sl@0
|
62 |
{return(I64LOW(aLinAddr)& ((1 << iManager.SegmentSizeLog2())-1));}
|
sl@0
|
63 |
|
sl@0
|
64 |
TInt SegmentSize();
|
sl@0
|
65 |
TInt SegmentSizeLog2();
|
sl@0
|
66 |
TInt64 SegmentSizeMask();
|
sl@0
|
67 |
TInt CacheLineSize();
|
sl@0
|
68 |
TInt CacheLineSizeInSegments();
|
sl@0
|
69 |
|
sl@0
|
70 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
|
sl@0
|
71 |
void DumpCache();
|
sl@0
|
72 |
#endif
|
sl@0
|
73 |
|
sl@0
|
74 |
private:
|
sl@0
|
75 |
// class can only be instantiated from friend class CCacheManager
|
sl@0
|
76 |
static CCacheClient* NewL(CCacheManager& aManager);
|
sl@0
|
77 |
void ConstructL();
|
sl@0
|
78 |
CCacheClient(CCacheManager& aManager);
|
sl@0
|
79 |
|
sl@0
|
80 |
|
sl@0
|
81 |
TInt LockSegments(TInt64 aPos, TInt aSegmentCount, TBool aMakeDirty);
|
sl@0
|
82 |
|
sl@0
|
83 |
const CCacheManager::TCacheLine* FindCacheLine(TInt64 aPos);
|
sl@0
|
84 |
TInt FindCacheLineIndex(TInt64 aPos);
|
sl@0
|
85 |
|
sl@0
|
86 |
TBool FreeCacheLine(const CCacheManager::TCacheLine* aCacheLine);
|
sl@0
|
87 |
|
sl@0
|
88 |
void RemoveCacheLine(const CCacheManager::TCacheLine* aCacheLine);
|
sl@0
|
89 |
void RemoveEmptySegments(const CCacheManager::TCacheLine* aCacheLine);
|
sl@0
|
90 |
|
sl@0
|
91 |
void RemoveLru(const CCacheManager::TCacheLine* aCacheLineToExclude);
|
sl@0
|
92 |
|
sl@0
|
93 |
inline TInt StartSegment(const CCacheManager::TCacheLine* aCacheLine, TInt64 aPos);
|
sl@0
|
94 |
inline TInt CacheLineLen(const CCacheManager::TCacheLine* aCacheLine);
|
sl@0
|
95 |
|
sl@0
|
96 |
TInt CachedBytes();
|
sl@0
|
97 |
TInt LockedBytes();
|
sl@0
|
98 |
private:
|
sl@0
|
99 |
CCacheManager& iManager;
|
sl@0
|
100 |
|
sl@0
|
101 |
// segment array for segments that contain valid data
|
sl@0
|
102 |
RPointerArray<CCacheManager::TCacheLine>* iCacheLines;
|
sl@0
|
103 |
TInt iMaxBytesCached;
|
sl@0
|
104 |
|
sl@0
|
105 |
TInt iLastCacheLineIndex;
|
sl@0
|
106 |
|
sl@0
|
107 |
friend class CCacheManager;
|
sl@0
|
108 |
};
|
sl@0
|
109 |
|
sl@0
|
110 |
|
sl@0
|
111 |
|
sl@0
|
112 |
#endif
|