|
1 // Copyright (c) 2004-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 "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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef CACHEMGR_H |
|
17 #define CACHEMGR_H |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <cinidata.h> |
|
21 #include "log.h" |
|
22 #include "panic.h" |
|
23 #include "srvdefs.h" |
|
24 |
|
25 _LIT(KCacheMgrIniFile, "centrep.ini"); |
|
26 |
|
27 class CSharedRepository; |
|
28 |
|
29 /** |
|
30 @internalTechnology |
|
31 This is the class which manages Coarse-Grained cache operations including delayed-unloading of |
|
32 repositories and forced eviction of repositories under OOM conditions. |
|
33 */ |
|
34 class CRepositoryCacheManager : public CTimer |
|
35 { |
|
36 friend class TRepositoryCacheManagerTester; |
|
37 public: |
|
38 static CRepositoryCacheManager* NewLC(); |
|
39 ~CRepositoryCacheManager(); |
|
40 void ConstructL(); |
|
41 |
|
42 void EnableCache(); |
|
43 void DisableCache(); |
|
44 void EnableCache(TInt aDefaultTimeout, TInt aCacheSize); |
|
45 |
|
46 inline TBool Enabled(); |
|
47 |
|
48 TBool StartEviction(CSharedRepository*& aRepository); |
|
49 |
|
50 void RemoveIdleRepository(CSharedRepository* aRepository); |
|
51 void FlushCache(); |
|
52 |
|
53 protected: |
|
54 /** |
|
55 @internalTechnology |
|
56 This is the class/structure which keeps eviction-related cache data |
|
57 */ |
|
58 class TRepositoryCacheInfo |
|
59 { |
|
60 public: |
|
61 TTime iCacheTime; |
|
62 CSharedRepository* iSharedRepository; |
|
63 }; |
|
64 |
|
65 void RunL(); |
|
66 |
|
67 private: |
|
68 inline CRepositoryCacheManager(); |
|
69 |
|
70 void Evict(TInt aIdleRepIndex); |
|
71 |
|
72 static TInt ForcedEvictionSortOrder(const TRepositoryCacheInfo &aRepository1, const TRepositoryCacheInfo &aRepository2); |
|
73 static TInt TimerEvictionSortOrder(const TRepositoryCacheInfo &aRepository1, const TRepositoryCacheInfo &aRepository2); |
|
74 |
|
75 private: |
|
76 TBool iEnabled; |
|
77 TInt iTotalCacheUsage; |
|
78 RArray<TRepositoryCacheInfo> iIdleRepositories; |
|
79 TTimeIntervalMicroSeconds32 iDefaultTimeout; |
|
80 TInt iCacheSize; |
|
81 }; |
|
82 |
|
83 #include "cachemgr.inl" |
|
84 |
|
85 #endif // CACHEMGR_H |