sysresmonitoring/oommonitor/inc/oommemorymonitor.h
branchRCL_3
changeset 1 0fdb7f6b0309
child 18 0818dd463d41
equal deleted inserted replaced
0:2e3d3ce01487 1:0fdb7f6b0309
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Main classes for Out of Memory Monitor.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef OOMMEMORYMONITOR_H
       
    20 #define OOMMEMORYMONITOR_H
       
    21 
       
    22 #include <e32property.h>
       
    23 #include <f32file.h>
       
    24 #include <w32std.h>
       
    25 #include "oomglobalconfig.h"
       
    26 #include "oomwindowgrouplist.h"
       
    27 #include "oommonitorsession.h"
       
    28 
       
    29 enum TActionTriggerType
       
    30     {
       
    31     ERamRotation,
       
    32     EClientServerRequestOptionalRam,
       
    33     EClientServerRequestFreeMemory,
       
    34     EPublishAndSubscribe        
       
    35     };
       
    36 
       
    37 // ---------------------------------------------------------
       
    38 // CMemoryMonitor
       
    39 // ---------------------------------------------------------
       
    40 //
       
    41 class COutOfMemoryWatcher;
       
    42 class CSubscribeHelper;
       
    43 class COomMonitorPlugin;
       
    44 class CMemoryMonitorServer;
       
    45 class CWservEventReceiver;
       
    46 class COomActionList;
       
    47 class COomLogger;
       
    48 class COomConfig;
       
    49 class COomClientRequestQueue;
       
    50 
       
    51 /**
       
    52  *  The main manager class for Oom Monitor. It has the following responsibility: 
       
    53  *  
       
    54  *  - initiates building the static configuration at boot time and owns the object which holds this. 
       
    55  *  - owns and drives the action list which runs actions
       
    56  *  - owns the internal representation of the window group list and an active object to monitor window group changes
       
    57  *  - owns the public API via the server and client request queue.
       
    58  *  - has an active object which monitors low RAM events
       
    59  *
       
    60  *  @lib oommonitor.lib
       
    61  *  @since S60 v5.0
       
    62  */
       
    63 NONSHARABLE_CLASS(CMemoryMonitor) : public CBase
       
    64     {
       
    65 public:
       
    66     static CMemoryMonitor* NewL();
       
    67     ~CMemoryMonitor();
       
    68 
       
    69 public: // event handlers
       
    70     void FreeMemThresholdCrossedL();
       
    71     void AppNotExiting(TInt aWgId);
       
    72     void StartFreeSomeRamL(TInt aTargetFree);
       
    73     void StartFreeSomeRamL(TInt aTargetFree, TInt aMaxPriority);
       
    74     void FreeOptionalRamL(TInt aBytesRequested, TInt aPluginId); // The ID of the plugin that will clear up the allocation, used to determine the priority of the allocation
       
    75     void HandleFocusedWgChangeL();
       
    76     static const COomGlobalConfig& GlobalConfig();
       
    77     void SetPriorityBusy(TInt aWgId);
       
    78     void SetPriorityNormal(TInt aWgId);
       
    79     void SetPriorityHigh(TInt aWgId);
       
    80     void ResetTargets();
       
    81     void RequestTimerCallbackL();
       
    82     void GetFreeMemory(TInt& aCurrentFreeMemory);
       
    83     TActionTriggerType ActionTrigger() const;
       
    84 #ifdef CLIENT_REQUEST_QUEUE
       
    85     void ActionsCompleted(TInt aBytesFree, TBool aMemoryGood);
       
    86     TInt GoodThreshold() const;
       
    87     TInt LowThreshold() const;
       
    88 #endif
       
    89     void RequestFreeMemoryL(TInt aBytesRequested);
       
    90     void RequestFreeMemoryPandSL(TInt aBytesRequested);
       
    91     
       
    92     /*
       
    93      * Sets the RProperty associated with KOomMemoryMonitorStatusPropertyKey
       
    94      * It checks if the value is going to be changed. 
       
    95      * If the new value is the same as the old one then the property is not updated
       
    96      * If the new value is different from the previously set one then the property is update
       
    97      * 
       
    98      * @param aNewValue one of TMemoryMonitorStatusPropertyValues 
       
    99      */
       
   100     void SetMemoryMonitorStatusProperty(const TMemoryMonitorStatusPropertyValues aValue);
       
   101    
       
   102 private:
       
   103     CMemoryMonitor();
       
   104     void ConstructL();
       
   105 #ifndef CLIENT_REQUEST_QUEUE
       
   106     static TInt WatchdogStatusStatusChanged(TAny* aPtr);
       
   107     void HandleWatchdogStatusCallBack();
       
   108     TBool FreeMemoryAboveThreshold(TInt& aCurrentFreeMemory);    void CloseNextApp();
       
   109 #endif
       
   110     void RefreshThresholds();
       
   111     
       
   112 public:
       
   113     // All members are owned
       
   114     // generally useful sessions
       
   115     RFs iFs;
       
   116     RWsSession iWs;
       
   117 
       
   118 private: //data
       
   119 
       
   120     // parameters for OOM watcher.
       
   121     TInt iLowThreshold;
       
   122     TInt iGoodThreshold;
       
   123     TInt iCurrentTarget;
       
   124 #ifdef CLIENT_REQUEST_QUEUE
       
   125     TInt iClientBytesRequested;
       
   126 #endif        
       
   127     // event receivers
       
   128     
       
   129     /**
       
   130      * The active object which monitors the kernel change notifier for changes in the low and good thresholds
       
   131      * Own
       
   132      */    
       
   133     COutOfMemoryWatcher* iOOMWatcher;
       
   134     
       
   135     
       
   136     CWservEventReceiver* iWservEventReceiver;
       
   137 
       
   138 #ifndef CLIENT_REQUEST_QUEUE
       
   139     // parameters for P&S watcher.
       
   140     /**
       
   141     * The handle to the P&S property that can be used to initiate OOM Monitor actions
       
   142     */    
       
   143     RProperty iWatchdogStatusProperty;
       
   144 
       
   145     /**
       
   146      * The active object which monitors the P&S property that can be used to initiate OOM Monitor actions
       
   147      * Own.       
       
   148      */    
       
   149     CSubscribeHelper* iWatchdogStatusSubscriber;
       
   150 #endif
       
   151     
       
   152     /**
       
   153      * The Memory Monitor Server
       
   154      * Own.       
       
   155      */
       
   156     CMemoryMonitorServer* iServer;
       
   157     
       
   158 #ifdef CLIENT_REQUEST_QUEUE
       
   159     COomClientRequestQueue* iQueue;
       
   160 #endif
       
   161     
       
   162 #ifdef _DEBUG    
       
   163     /**
       
   164      * Oom logging tool - samples free memory for profiling
       
   165      * Own.       
       
   166      */
       
   167     COomLogger* iLogger;
       
   168 #endif
       
   169     
       
   170     /**
       
   171      * A list of window group Ids, with child window groups removed such that there is one Id per application
       
   172      * Own.       
       
   173      */    
       
   174     COomWindowGroupList* iOomWindowGroupList;
       
   175     
       
   176     /**
       
   177      * The object responsible for identifying the best actions to run, and running them 
       
   178      * Own.       
       
   179      */
       
   180     COomActionList* iOomActionList;
       
   181     
       
   182     /**
       
   183      * The entire Oom Monitor configuration
       
   184      * Own.       
       
   185      */
       
   186     COomConfig* iConfig;
       
   187 
       
   188     /**
       
   189      * The most recent value the memory monitor status property was set to 
       
   190      */
       
   191     TInt iLastMemoryMonitorStatusProperty;
       
   192     
       
   193     TActionTriggerType iActionTrigger;
       
   194     };
       
   195 
       
   196 #endif /*OOMMEMORYMONITOR_H*/