diff -r 000000000000 -r b16258d2340f applayerpluginsandutils/bookmarksupport/test/cenrepsrv/cachemgr.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/applayerpluginsandutils/bookmarksupport/test/cenrepsrv/cachemgr.h Tue Feb 02 01:09:52 2010 +0200 @@ -0,0 +1,85 @@ +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef CACHEMGR_H +#define CACHEMGR_H + +#include +#include +#include "log.h" +#include "panic.h" +#include "srvdefs.h" + +_LIT(KCacheMgrIniFile, "centrep.ini"); + +class CSharedRepository; + +/** +@internalTechnology +This is the class which manages Coarse-Grained cache operations including delayed-unloading of +repositories and forced eviction of repositories under OOM conditions. +*/ +class CRepositoryCacheManager : public CTimer + { + friend class TRepositoryCacheManagerTester; +public: + static CRepositoryCacheManager* NewLC(); + ~CRepositoryCacheManager(); + void ConstructL(); + + void EnableCache(); + void DisableCache(); + void EnableCache(TInt aDefaultTimeout, TInt aCacheSize); + + inline TBool Enabled(); + + TBool StartEviction(CSharedRepository*& aRepository); + + void RemoveIdleRepository(CSharedRepository* aRepository); + void FlushCache(); + +protected: + /** + @internalTechnology + This is the class/structure which keeps eviction-related cache data + */ + class TRepositoryCacheInfo + { + public: + TTime iCacheTime; + CSharedRepository* iSharedRepository; + }; + + void RunL(); + +private: + inline CRepositoryCacheManager(); + + void Evict(TInt aIdleRepIndex); + + static TInt ForcedEvictionSortOrder(const TRepositoryCacheInfo &aRepository1, const TRepositoryCacheInfo &aRepository2); + static TInt TimerEvictionSortOrder(const TRepositoryCacheInfo &aRepository1, const TRepositoryCacheInfo &aRepository2); + +private: + TBool iEnabled; + TInt iTotalCacheUsage; + RArray iIdleRepositories; + TTimeIntervalMicroSeconds32 iDefaultTimeout; + TInt iCacheSize; + }; + +#include "cachemgr.inl" + +#endif // CACHEMGR_H