sl@0: // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test/usb\t_usb_device\src\activetimer.cpp sl@0: // USB Test Program T_USB_DEVICE, functional part. sl@0: // Device-side part, to work against T_USB_HOST running on the host. sl@0: // sl@0: // sl@0: sl@0: #include "general.h" // CActiveControl, CActiveRW sl@0: #include "activetimer.h" sl@0: sl@0: extern RTest test; sl@0: extern TBool gVerbose; sl@0: extern TBool gSkip; sl@0: extern TBool gStopOnFail; sl@0: extern TInt gSoakCount; sl@0: sl@0: // sl@0: // --- class CActiveTimer --------------------------------------------------------- sl@0: // sl@0: sl@0: CActiveTimer::CActiveTimer(CConsoleBase* aConsole, RDEVCLIENT* aPort) sl@0: : CActive(EPriorityNormal), sl@0: iConsole(aConsole), sl@0: iPort(aPort) sl@0: { sl@0: CActiveScheduler::Add(this); sl@0: } sl@0: sl@0: sl@0: CActiveTimer* CActiveTimer::NewL(CConsoleBase* aConsole, RDEVCLIENT* aPort) sl@0: { sl@0: CActiveTimer* self = new (ELeave) CActiveTimer(aConsole, aPort); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(); // self sl@0: return self; sl@0: } sl@0: sl@0: sl@0: void CActiveTimer::ConstructL() sl@0: { sl@0: User::LeaveIfError(iTimer.CreateLocal()); sl@0: } sl@0: sl@0: sl@0: CActiveTimer::~CActiveTimer() sl@0: { sl@0: TUSB_VERBOSE_PRINT("CActiveTimer::~CActiveTimer()"); sl@0: Cancel(); // base class sl@0: iTimer.Close(); sl@0: } sl@0: sl@0: sl@0: void CActiveTimer::DoCancel() sl@0: { sl@0: TUSB_VERBOSE_PRINT("CActiveTimer::DoCancel()"); sl@0: iTimer.Cancel(); sl@0: } sl@0: sl@0: sl@0: void CActiveTimer::RunL() sl@0: { sl@0: TUSB_VERBOSE_PRINT("CActiveTimer::RunL()"); sl@0: // Nothing to do here, as we call ReadCancel() after a manual WaitForRequest() sl@0: // (in CActiveRW::ReceiveVersion()). sl@0: } sl@0: sl@0: sl@0: void CActiveTimer::Activate(TTimeIntervalMicroSeconds32 aDelay) sl@0: { sl@0: __ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 666)); sl@0: iTimer.After(iStatus, aDelay); sl@0: SetActive(); sl@0: } sl@0: sl@0: sl@0: // -eof-