--- a/sysresmonitoring/oommonitor/src/oomrunplugin.cpp Thu Jul 15 18:49:38 2010 +0300
+++ b/sysresmonitoring/oommonitor/src/oomrunplugin.cpp Thu Aug 19 10:05:08 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,6 +21,9 @@
#include "oommonitorplugin.h"
#include "oompanic.h"
+#include <apgtask.h>
+#include <w32std.h>
+
COomRunPlugin* COomRunPlugin::NewL(TUint aPluginId, COomRunPluginConfig& aConfig, MOomActionObserver& aStateChangeObserver, COomMonitorPlugin& aPlugin, COomMonitorPluginV2* aV2Plugin)
{
FUNC_LOG;
@@ -34,21 +37,40 @@
// Run the OOM plugin in order to free memory
// Call the COomAction::MemoryFreed when it is done
-void COomRunPlugin::FreeMemory(TInt aBytesRequested)
+void COomRunPlugin::FreeMemory(TInt aBytesRequested, TBool aIsDataPaged)
{
FUNC_LOG;
- TRACES1("COomRunPlugin::FreeMemory: iPluginId = %x", iPluginId);
-
- // Ask the plugin to free some memory
-
+ iFreeMemoryCalled = ETrue;
+
// Do we have a V2 plugin, if so then use it
if (iV2Plugin)
+ {
+ //RDebug::Printf("COomRunPlugin::FreeMemory: Requesting to free the RAM iV2Plugin->FreeRam(%d) \n",aBytesRequested);
iV2Plugin->FreeRam(aBytesRequested);
- else
- // If we only have a V1 plugin then use that
+ }
+ else if( aIsDataPaged )
+ {
+ if (IsAppDataPaged(iPlugin) )
+ {
+ //the plugins implemented by the application which are WDP enabled
+ //are notified.
+ //RDebug::Printf("COomRunPlugin::FreeMemory: Requesting to free the RAM to Data paged app \n");
+ iPlugin.FreeRam();
+ }
+ else
+ {
+ //Request is for freeing the paged memory(swap) but the App(iPlugin belongs to)
+ //is non WDP no need to notify; as it can't free the swap memory
+ iFreeMemoryCalled = EFalse;
+ return;
+ }
+ }
+ else
+ {
+ //Unpaged memory will be freed in case of non WDP app
+ //RDebug::Printf("COomRunPlugin::FreeMemory: Requesting to free the RAM \n");
iPlugin.FreeRam();
-
- iFreeMemoryCalled = ETrue;
+ }
// Wait for the required time before we signal completion.
__ASSERT_DEBUG(!iPluginWaiter->IsActive(), OomMonitorPanic(KStartingActivePluginWaiter));
@@ -94,3 +116,50 @@
iPluginWaiter = COomPluginWaiter::NewL(waitDuration, *this);
}
+
+//-----------------------------------------------------------------------------
+// Function: IsAppDataPaged
+// Checks whether the application which implements the given
+// COomMonitorPlugin is data paged
+//-----------------------------------------------------------------------------
+//
+TBool COomRunPlugin::IsAppDataPaged
+ ( COomMonitorPlugin& aPlugin ) const
+ {
+ FUNC_LOG;
+ /*
+ /TRACES1("COomRunPlugin::IsAppDataPaged: aPlugin.AppId() = %x ", aPlugin.AppId() );
+ //RDebug::Printf("COomRunPlugin::IsAppDataPaged: aPlugin.AppId() = %x ", aPlugin.AppId() );
+ */
+ //the function find the process with given appid and check
+ //application supports the data paging.
+ RProcess clientprocess;
+ TApaTaskList taskList(aPlugin.WsSession());
+ RThread clientthread;
+ TInt err = clientthread.Open
+ (taskList.FindApp(aPlugin.AppId()).ThreadId());
+
+ //RDebug::Printf("COomRunPlugin::IsAppDataPaged: clientthread.Open() err = %d ", err );
+
+ if( !err )
+ {
+ //getting the process which provides the plugin
+ err = clientthread.Process(clientprocess);
+ RDebug::Printf("COomRunPlugin::IsAppDataPaged: clientthread.Process() err = %d ", err );
+
+ if( !err )
+ {
+ //checking whether the process is Data paged or not
+ TBool isdatapaged = clientprocess.DefaultDataPaged();
+ clientprocess.Close();
+ clientthread.Close();
+ //RDebug::Printf("COomRunPlugin::IsAppDataPaged: isdatapaged = %d ", isdatapaged );
+
+ return isdatapaged;
+ }
+ clientthread.Close();
+ }
+ //could not successfully open the handle of process or thread,
+ //the return EFalse
+ return EFalse;
+ }