appsupport_plat/oom_monitor_api/inc/oommonitorsession.h
changeset 35 13fd6fd25fe7
parent 0 2e3d3ce01487
--- a/appsupport_plat/oom_monitor_api/inc/oommonitorsession.h	Fri May 14 16:01:13 2010 +0300
+++ b/appsupport_plat/oom_monitor_api/inc/oommonitorsession.h	Thu May 27 13:01:09 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -21,50 +21,125 @@
 
 #include <e32std.h>
 
+const TInt KOomMaxAllocationWithoutPermission = 1048576;
+const TUid KOomMemoryMonitorStatusPropertyCategory = {0x10207218};
+const TUint32 KOomMemoryMonitorStatusPropertyKey = 0;
+enum TMemoryMonitorStatusPropertyValues
+    {
+    // Above Treshhold: Free Ram is above good treshhold point and memory monitor isn't freeing any memory
+    EAboveTreshHold,
+    
+    // Freeing Memory: Memory monitor is in the middle of freeing memory
+    EFreeingMemory,
+    
+    // Below Treshhold: Memory monitor has tried to free some RAM but total memory is still below treshhold and memory monitor has given up freeing more memory.
+    EBelowTreshHold
+    };
 class ROomMonitorSession : public RSessionBase
-	{
+    {
+public:
+
+    /**  Defines the application priorities of OOM monitor. */
+    enum TOomPriority
+        {
+        /**
+        * Application can be closed if needed.
+        */
+        EOomPriorityNormal = 0,
+
+        /**
+        * Application should not be closed if possible.
+        */
+        EOomPriorityHigh,
+
+        /**
+        * Application is busy and should not be closed.
+        */
+        EOomPriorityBusy
+        };
+
 public:
-	/**
-	* Connects a new session.
-	* Sessions must be connected before any other APIs can be used.
-	* When the client has finished using a session, Close() must be called.
-	* @return KErrNone if successful, error code otherwise.
-	*/
-	IMPORT_C TInt Connect();
-	/**
-	* Request that the OOM monitor attempts to free some memory.
-	* This function may take several seconds to execute, depending on
-	* the memory state. It will not return until the attempt to recover
-	* memory has completed.
-	* @param aBytesRequested The number of bytes of free memory that the client requests.
-	* @return KErrNone if the request memory is free. KErrNoMemory if that
-	*         amount of memory could not be recovered. Other error codes may
-	*         also be returned.
-	*/
-	IMPORT_C TInt RequestFreeMemory(TInt aBytesRequested);
-	/**
-	* Request that the OOM monitor attempts to free some memory.
-	* This is an asynchronous version of the request for free memory.
-	* @param aBytesRequested The number of bytes of free memory that the client requests.
-	* @param aStatus will be completed when the attempt to recover memory
-	*        has finished. This may take several seconds, depending on
-	*        the memory state. On completion, aStatus will be set to 
-	*        KErrNone if the request memory is free. KErrNoMemory if that
-	*        amount of memory could not be recovered. Other error codes may
-	*        also be set.
-	*/
-	IMPORT_C void RequestFreeMemory(TInt aBytesRequested, TRequestStatus& aStatus);
-	/**
-	* Cancels the asynchronous request for free memory.
-	*/
-	IMPORT_C void CancelRequestFreeMemory();
-	/**
-	* Notifiy the OOM monitor that this application is not responding
-	* to the EEikCmdExit request to exit the application.
-	* This function is used by the Avkon framework's app shutter.
-	* @param aWgId the window group identifier of the app that is not exiting.
-	*/
-	IMPORT_C void ThisAppIsNotExiting(TInt aWgId);
-	};
+    /**
+    * Connects a new session.
+    * Sessions must be connected before any other APIs can be used.
+    * When the client has finished using a session, Close() must be called.
+    * @return KErrNone if successful, error code otherwise.
+    */
+    IMPORT_C TInt Connect();
+
+    /**
+    * Request that the OOM monitor attempts to free some paged memory.
+    * This function may take several seconds to execute, depending on
+    * the memory state. It will not return until the attempt to recover
+    * memory has completed.
+    * @param aBytesRequested The number of bytes of free memory that the client requests.
+    * @return KErrNone if the request memory is free. KErrNoMemory if that
+    *         amount of memory could not be recovered. Other error codes may
+    *         also be returned.
+    */
+    IMPORT_C TInt RequestFreeMemory(TInt aBytesRequested);
+
+    /**
+    * Request that the OOM monitor attempts to free some paged memory.
+    * This is an asynchronous version of the request for free paged memory.
+    * @param aBytesRequested The number of bytes of free memory that the client requests.
+    * @param aStatus will be completed when the attempt to recover memory
+    *        has finished. This may take several seconds, depending on
+    *        the memory state. On completion, aStatus will be set to 
+    *        KErrNone if the request memory is free. KErrNoMemory if that
+    *        amount of memory could not be recovered. Other error codes may
+    *        also be set.
+    */
+    IMPORT_C void RequestFreeMemory(TInt aBytesRequested, TRequestStatus& aStatus);
+    
+    /**
+    * Request that the OOM monitor attempts to free some memory for an optional allocation.
+    * The passed in plugin ID is used to determine the priority for this allocation.
+    * Lower priority OOM actions may be executed to free enough RAM for this allocation.
+    * This function may take several seconds to execute, depending on
+    * the memory state. It will not return until the attempt to recover
+    * memory has completed.
+    * @param aBytesRequested The number of bytes of free memory that the client requests.
+    * @param aPluginId The ID of the plugin that may delete the allocation in event of low memory.
+    * @return KErrNone if the request memory is free. KErrNoMemory if that
+    *         amount of memory could not be recovered. Other error codes may
+    *         also be returned.
+    */
+    IMPORT_C TInt RequestOptionalRam(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TInt& aBytesAvailable);
+    
+    /**
+    * Request that the OOM monitor attempts to free some memory for an optional allocation.
+    * The passed in plugin ID is used to determine the priority for this allocation.
+    * Lower priority OOM actions may be executed to free enough RAM for this allocation.
+    * This function may take several seconds to execute, depending on
+    * the memory state. It will not return until the attempt to recover
+    * memory has completed.
+    * @param aBytesRequested The number of bytes of free memory that the client requests.
+    * @param aPluginId The ID of the plugin that may delete the allocation in event of low memory.
+    * @param aStatus The TRequestStatus (completes with the number of bytes freed (aStatus >= 0) or an error (aStatus <= 0))
+    * @return None
+    */
+    IMPORT_C void RequestOptionalRam(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TRequestStatus& aStatus);
+
+    /**
+    * Cancels the asynchronous request for free memory.
+    */
+    IMPORT_C void CancelRequestFreeMemory();
+
+    /**
+    * Notify the OOM monitor that this application is not responding
+    * to the EEikCmdExit request to exit the application.
+    * This function is used by the Avkon framework's app shutter.
+    * @param aWgId the window group identifier of the app that is not exiting.
+    */
+    IMPORT_C void ThisAppIsNotExiting(TInt aWgId);
+
+    /**
+    * Notify the OOM monitor that this application has the specified priority
+    * @param aPriority the priority of the application
+    */
+    IMPORT_C void SetOomPriority(TOomPriority aPriority);
+    
+    };
 
 #endif // R_OOMMONITORSESSION_H