os/security/authorisation/userpromptservice/database/test/dumpupsdb/source/activewaiter.cpp
Update contrib.
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include "activewaiter.h"
21 CActiveWaiter::CActiveWaiter()
22 : CActive(CActive::EPriorityStandard)
24 CActiveScheduler::Add(this);
27 CActiveWaiter::~CActiveWaiter()
31 void CActiveWaiter::WaitActiveL(TInt aExpectedStatus /*=KErrNone*/)
33 ASSERT(!iScheduler.IsStarted());
38 if(iStatus.Int() != aExpectedStatus)
40 User::Leave(iStatus.Int());
45 Sets the active scheduler active and immidiately Cancels, calling the
46 supplied cancel observer during DoCancel();
47 @param aCancelObserver performs and DoCancel() operations on behalf of this object
49 void CActiveWaiter::SetActiveAndCancel(MActiveWaiterObserver& aCancelObserver)
51 ASSERT(!iScheduler.IsStarted());
52 ASSERT(iCancelObserver == NULL);
55 iCancelObserver = &aCancelObserver;
61 Cancels the current operation, and stops the active scheduler loop,
62 allowing a previous call to WaitActiveL() to return.
63 @param aCancelObserver performs and DoCancel() operations on behalf of this object
65 void CActiveWaiter::CancelWaitActive(MActiveWaiterObserver& aCancelObserver)
67 ASSERT(iScheduler.IsStarted());
68 ASSERT(iCancelObserver == NULL);
70 iCancelObserver = &aCancelObserver;
74 ASSERT(iScheduler.CanStopNow());
75 iScheduler.AsyncStop();
78 void CActiveWaiter::RunL()
80 if (iScheduler.IsStarted())
82 ASSERT(iScheduler.CanStopNow());
83 iScheduler.AsyncStop();
87 void CActiveWaiter::DoCancel()
89 ASSERT(iCancelObserver != NULL);
91 iCancelObserver->DoCancel();
92 iCancelObserver = NULL;