camerauis/cameraapp/generic/inc/CamMemoryMonitor.h
branchRCL_3
changeset 54 bac7acad7cb3
parent 0 1ddebce53859
equal deleted inserted replaced
53:61bc0f252b2b 54:bac7acad7cb3
       
     1 /*
       
     2 * Copyright (c) 2007-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:  Class that monitors free memory and attempts to free it if necessary
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CAMMEMORYMONITOR_H
       
    19 #define CAMMEMORYMONITOR_H
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <oommonitorsession.h>
       
    23 
       
    24 
       
    25 class CCamAppController;
       
    26 class CCamAppUi;
       
    27 
       
    28 /**
       
    29  * Class that monitors free memory and attempts to free it if necessary
       
    30  *
       
    31  */
       
    32 class CCamMemoryMonitor : public CActive
       
    33 {
       
    34 
       
    35 public:
       
    36 
       
    37     static CCamMemoryMonitor* NewL( CCamAppUi* aAppUi, CCamAppController* aController );
       
    38 
       
    39     virtual ~CCamMemoryMonitor();
       
    40 
       
    41     /**
       
    42      * Start monitoring free memory. If available memory drop below given limit,
       
    43      * requests memory from OomManager.
       
    44      *
       
    45      * @param aLimit Monitored memory limit
       
    46      * @param aRequestAmount Amount of memory to be requested if below aLimit
       
    47      */
       
    48     void StartMonitoring( TInt aLimit, TInt aRequestAmount );
       
    49 
       
    50     /**
       
    51      * Start monitoring free memory. Uses default or previously given
       
    52      * values for limit and request amount
       
    53      */
       
    54     void StartMonitoring();
       
    55 
       
    56     /**
       
    57      * Stop monitoring free memory.
       
    58      *
       
    59      */
       
    60     void StopMonitoring();
       
    61 
       
    62     /**
       
    63      * Checks for free memory and requests more if below given limit.
       
    64      *
       
    65      * @param aLimit Memory limit to be checked
       
    66      * @param aRequestAmount Amount of memory to be requested if below aLimit
       
    67      * @param aShowNote If ETrue, note will be shown during memory request
       
    68      */
       
    69     TInt CheckAndRequestMemoryL( TInt aLimit, TInt aRequestAmount, TBool aShowNote );
       
    70 
       
    71     /**
       
    72      * Checks for free memory and requests more if below given limit. Uses
       
    73      * default values for limit and request amount.
       
    74      *
       
    75      * @param aShowNote If ETrue, note will be shown during memory request
       
    76      */
       
    77     TInt CheckAndRequestMemoryL( TBool aShowNote );
       
    78 
       
    79 
       
    80 
       
    81     void RunL();
       
    82     void DoCancel();
       
    83 
       
    84 private:
       
    85     CCamMemoryMonitor( CCamAppUi* aAppUi, CCamAppController* aController );
       
    86     void ConstructL();
       
    87 
       
    88     static TInt MemoryCheck( TAny* aPtr );
       
    89 
       
    90     void CheckMemory();
       
    91 private:
       
    92     // data
       
    93 
       
    94     TInt iLimit;
       
    95     TInt iRequestAmount;
       
    96 
       
    97     CCamAppUi* iAppUi;
       
    98     CCamAppController* iController;
       
    99     CPeriodic* iMemoryCheckTimer;
       
   100     ROomMonitorSession iOomMonitor;
       
   101 };
       
   102 
       
   103 #endif /* CCAMMEMORYMONITOR_H_ */