sysresmonitoring/oommonitor/inc/oomcloseapp.h
changeset 35 13fd6fd25fe7
equal deleted inserted replaced
29:6a787171e1de 35:13fd6fd25fe7
       
     1 /*
       
     2 * Copyright (c) 2006-2010 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:  Classes for executing OOM actions (e.g. closing applications and running plugins).
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef OOMCLOSEAPP_H_
       
    20 #define OOMCLOSEAPP_H_
       
    21 
       
    22 
       
    23 #include <apgtask.h>
       
    24 
       
    25 #include "oomaction.h"
       
    26 
       
    27 class COomAppCloseTimer;
       
    28 class COomAppCloseWatcher;
       
    29 class TApaTask;
       
    30 class TActionRef;
       
    31 
       
    32 /*
       
    33  * The OOM action of closing an application in order to free up memory.
       
    34  *
       
    35  *  @lib oommonitor.lib
       
    36  *  @since S60 v5.0
       
    37  */
       
    38 NONSHARABLE_CLASS(COomCloseApp) : public COomAction
       
    39     {
       
    40 public:
       
    41     /**
       
    42      * Two-phased constructor.
       
    43      * @param aStateChangeObserver an observer to the state of the application
       
    44      * @param aWs a connected handle to a window server session
       
    45      */
       
    46     static COomCloseApp* NewL(MOomActionObserver& aStateChangeObserver, RWsSession& aWs);
       
    47         
       
    48     //from COomAction
       
    49     
       
    50     /**
       
    51      * Close the application in order to free memory
       
    52      * Call the COomAction::MemoryFreed when it is done
       
    53      * @param aBytesRequested not used for clsoe app actions
       
    54      */
       
    55     virtual void FreeMemory(TInt aBytesRequested, TBool aIsDataPaged);
       
    56     
       
    57     ~COomCloseApp();
       
    58     
       
    59     /**
       
    60      * Callback from COomAppCloseWatcher and COomAppCloseTimer
       
    61      */
       
    62     void CloseAppEvent();
       
    63     
       
    64     inline TBool IsRunning();
       
    65 
       
    66     /**
       
    67      * Configure, or reconfigure the COomCloseApp object
       
    68      * Action objects are reused to minimize any memory allocation when memory is low
       
    69      */
       
    70     void Reconfigure(const TActionRef& aRef);
       
    71 
       
    72     inline TUint WgId() const;
       
    73     
       
    74 private:
       
    75     
       
    76     COomCloseApp(MOomActionObserver& aStateChangeObserver, RWsSession& aWs);
       
    77     
       
    78     void ConstructL();
       
    79     
       
    80     TUint iWgId;
       
    81         
       
    82     TBool iAppCloserRunning;
       
    83     TApaTask iCurrentTask;
       
    84 
       
    85     /**
       
    86      * A timeout for an app close action
       
    87      * Own
       
    88      */
       
    89     COomAppCloseTimer* iAppCloseTimer;
       
    90 
       
    91     /**
       
    92      * A watcher for the application closing
       
    93      * Own
       
    94      */
       
    95     COomAppCloseWatcher* iAppCloseWatcher; 
       
    96     };
       
    97 
       
    98 #include "oomcloseapp.inl"
       
    99 
       
   100 #endif /*OOMCLOSEAPP_H_*/