metadataengine/server/inc/mdsgarbagecollector.h
changeset 0 c53acadfccc6
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     1 /*
       
     2 * Copyright (c) 2002-2009 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:  This is garbage colletion class which sends*
       
    15 */
       
    16 
       
    17 #ifndef _MDSGARBAGECOLLECTOR_H_
       
    18 #define _MDSGARBAGECOLLECTOR_H_
       
    19 
       
    20 #include <e32std.h>
       
    21 #include <e32base.h>
       
    22 
       
    23 class MMdSGarbageCollectorObserver
       
    24 	{
       
    25 	public:
       
    26 		/*
       
    27 		 * @return if the garbage collection need to be started again
       
    28 		 */
       
    29 		virtual TBool StartGarbageCollectionL() = 0;
       
    30 	};
       
    31 
       
    32 class CMdSGarbageCollector : public CActive
       
    33 {
       
    34 public:
       
    35 	virtual ~CMdSGarbageCollector();
       
    36 	/**
       
    37 	 * Two phase constructor.
       
    38 	 * @param aObserver an observer which will be notified when the garbage collector starts.
       
    39 	 * @return an instance of CMdSGarbageCollector
       
    40 	 */
       
    41 	static CMdSGarbageCollector* NewL(MMdSGarbageCollectorObserver& aObserver);
       
    42 	
       
    43 	/**
       
    44 	 * Two phase constructor.
       
    45 	 * @param aObserver an observer which will be notified when the garbage collector starts.
       
    46  	 * @return an instance of CMdSGarbageCollector
       
    47 	 */
       
    48 	static CMdSGarbageCollector* NewLC(MMdSGarbageCollectorObserver& aObserver);
       
    49 	
       
    50 	/**
       
    51 	 * Starts garbage connection with a delay. The same value will also be used as interval between
       
    52 	 * following garbage collections if the observer returns ETrue when StartGarbageCollectionL()
       
    53 	 * is called.
       
    54 	 * 
       
    55 	 * @param aDelay delay before garbage collection starts
       
    56 	 */
       
    57 	void Start( TInt aDelay );
       
    58 	
       
    59 	/**
       
    60 	 * Pauses garbage collection.
       
    61 	 */
       
    62 	void Pause();
       
    63 	
       
    64 	/**
       
    65 	 * Resumes garbage collection.
       
    66 	 */
       
    67 	void Resume();
       
    68 
       
    69 private:
       
    70 	CMdSGarbageCollector(MMdSGarbageCollectorObserver& aObserver);
       
    71 	void ConstructL();
       
    72 	
       
    73 	virtual void RunL();
       
    74 	virtual void DoCancel();
       
    75 	virtual TInt RunError( TInt aError );
       
    76 	
       
    77 private:
       
    78 	RTimer iTimer;
       
    79 
       
    80 	TTimeIntervalMicroSeconds32 iDelay;
       
    81 	TTimeIntervalMicroSeconds32 iNewDelay;
       
    82 
       
    83 	MMdSGarbageCollectorObserver& iObserver;
       
    84 };
       
    85 
       
    86 #endif