diff -r 000000000000 -r c53acadfccc6 harvester/server/src/harvesteroomao.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/harvester/server/src/harvesteroomao.cpp Mon Jan 18 20:34:07 2010 +0200 @@ -0,0 +1,109 @@ +/* +* Copyright (c) 2009 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" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Low memory observer for havester server +* +*/ + + +#include "harvesteroomao.h" +#include "harvestercommon.h" + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CHarvesterOomAO* CHarvesterOomAO::NewL( MHarvesterOomObserver& aObserver ) + { + CHarvesterOomAO* self = new (ELeave) CHarvesterOomAO( aObserver ); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// --------------------------------------------------------------------------- +// CHarvesterOomAO +// --------------------------------------------------------------------------- +// +CHarvesterOomAO::CHarvesterOomAO( MHarvesterOomObserver& aObserver ) : + CActive( CActive::EPriorityUserInput ) + { + iObserver = &aObserver; + } + + +// --------------------------------------------------------------------------- +// ~CHarvesterOomAO +// --------------------------------------------------------------------------- +// +CHarvesterOomAO::~CHarvesterOomAO() + { + iOomMsgQueue.Close(); + } + +// --------------------------------------------------------------------------- +// ConstructL +// --------------------------------------------------------------------------- +// +void CHarvesterOomAO::ConstructL() + { + CActiveScheduler::Add( this); + + iOomMsgQueue.OpenGlobal( KHarvesterOomQueue ); + iOomMsgQueue.NotifyDataAvailable( iStatus ); + SetActive(); + } + +// --------------------------------------------------------------------------- +// RunL +// --------------------------------------------------------------------------- +// +void CHarvesterOomAO::RunL() + { + User::LeaveIfError( iStatus.Int() ); + + TInt oomStatus(0); + TInt err = iOomMsgQueue.Receive( oomStatus ); + + if( oomStatus == TMdsOomFreeRam ) + { + iObserver->MemoryLow(); + } + else + { + iObserver->MemoryGood(); + } + + iOomMsgQueue.NotifyDataAvailable( iStatus ); + SetActive(); + } + +// --------------------------------------------------------------------------- +// DoCancel +// --------------------------------------------------------------------------- +// +void CHarvesterOomAO::DoCancel() + { + iOomMsgQueue.CancelDataAvailable(); + } + +// --------------------------------------------------------------------------- +// RunError +// --------------------------------------------------------------------------- +// +TInt CHarvesterOomAO::RunError( TInt /*aError*/ ) + { + return KErrNone; + } +