internetradio2.0/cachemgmtinc/ircachecleanup.h
changeset 14 896e9dbc5f19
parent 12 608f67c22514
child 15 065198191975
equal deleted inserted replaced
12:608f67c22514 14:896e9dbc5f19
     1 /*
       
     2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32base.h>
       
    20 
       
    21 //Max size in Bytes
       
    22 const TInt KCacheLimitSize = 8*1024*1024;
       
    23 
       
    24 class CIRCacheMgmt;
       
    25 
       
    26 NONSHARABLE_CLASS (CIRCacheCleanup):public CTimer
       
    27 	{
       
    28 	public:
       
    29 
       
    30     /**
       
    31      * Two-phased constructor.
       
    32      * @return  The newly created object.
       
    33      */
       
    34     static CIRCacheCleanup* NewL(CIRCacheMgmt& aCacheDb);
       
    35 
       
    36     /**
       
    37      * Destructor.
       
    38      */
       
    39     ~CIRCacheCleanup();
       
    40 
       
    41 	private:
       
    42 
       
    43     /**
       
    44      * Default Constructor.
       
    45      * @param CIRCacheMgmt refrerence
       
    46      */
       
    47     CIRCacheCleanup(CIRCacheMgmt& aCacheDb);
       
    48 
       
    49     /**
       
    50      * Second-phase constructor.
       
    51      */
       
    52     void ConstructL();
       
    53 
       
    54     /**
       
    55      *CleanupCacheDbL()
       
    56      * Cleansup routine
       
    57      */
       
    58     void CleanupCacheDbL();
       
    59     
       
    60     /**
       
    61      *CheckStatusL()
       
    62      * CheckStatus of CacheDb and do cleanup if necessary
       
    63      */
       
    64     void CheckStatusL();
       
    65     
       
    66 
       
    67     /**
       
    68      * @see CTimer::RunL().
       
    69      */
       
    70     void RunL();
       
    71     
       
    72     /**
       
    73      * GetCleanupInterval().
       
    74      *gets the cleanup routine call interval based on the current cache size.
       
    75      *formula derivation:
       
    76 	 *Timeinterval of cleanup (T) is inversely proportional to the cache size(S)
       
    77 	 *Minimum time interval for cleanup routine 2 min.
       
    78 	 *Maximum time interval for cleanup routine ~35mins.
       
    79 	 *timeintervalperbyte = (35-2)*60*1000000/1024*1024
       
    80 	 *TimeInterval = timeintervalperbyte*(MaxCacheLimit-CurrentCachesize)
       
    81      */
       
    82      TUint32 GetCleanupInterval();
       
    83      
       
    84 	private:
       
    85 
       
    86     /** The cache database. */
       
    87     CIRCacheMgmt& iDatabase;
       
    88 	};