os/kernelhwsrv/kerneltest/e32test/usb/t_usb_device/src/activetimer.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // e32test/usb\t_usb_device\src\activetimer.cpp
    15 // USB Test Program T_USB_DEVICE, functional part.
    16 // Device-side part, to work against T_USB_HOST running on the host.
    17 // 
    18 //
    19 
    20 #include "general.h"									// CActiveControl, CActiveRW
    21 #include "activetimer.h"
    22 
    23 extern RTest test;
    24 extern TBool gVerbose;
    25 extern TBool gSkip;
    26 extern TBool gStopOnFail;
    27 extern TInt gSoakCount;
    28 
    29 //
    30 // --- class CActiveTimer ---------------------------------------------------------
    31 //
    32 
    33 CActiveTimer::CActiveTimer(CConsoleBase* aConsole, RDEVCLIENT* aPort)
    34 	: CActive(EPriorityNormal),
    35 	  iConsole(aConsole),
    36 	  iPort(aPort)
    37 	{
    38 	CActiveScheduler::Add(this);
    39 	}
    40 
    41 
    42 CActiveTimer* CActiveTimer::NewL(CConsoleBase* aConsole, RDEVCLIENT* aPort)
    43 	{
    44 	CActiveTimer* self = new (ELeave) CActiveTimer(aConsole, aPort);
    45 	CleanupStack::PushL(self);
    46 	self->ConstructL();
    47 	CleanupStack::Pop();									// self
    48 	return self;
    49 	}
    50 
    51 
    52 void CActiveTimer::ConstructL()
    53 	{
    54 	User::LeaveIfError(iTimer.CreateLocal());
    55 	}
    56 
    57 
    58 CActiveTimer::~CActiveTimer()
    59 	{
    60 	TUSB_VERBOSE_PRINT("CActiveTimer::~CActiveTimer()");
    61 	Cancel();												// base class
    62 	iTimer.Close();
    63 	}
    64 
    65 
    66 void CActiveTimer::DoCancel()
    67 	{
    68 	TUSB_VERBOSE_PRINT("CActiveTimer::DoCancel()");
    69 	iTimer.Cancel();
    70 	}
    71 
    72 
    73 void CActiveTimer::RunL()
    74 	{
    75 	TUSB_VERBOSE_PRINT("CActiveTimer::RunL()");
    76 	// Nothing to do here, as we call ReadCancel() after a manual WaitForRequest()
    77 	// (in CActiveRW::ReceiveVersion()).
    78 	}
    79 
    80 
    81 void CActiveTimer::Activate(TTimeIntervalMicroSeconds32 aDelay)
    82 	{
    83 	__ASSERT_ALWAYS(!IsActive(), User::Panic(KActivePanic, 666));
    84 	iTimer.After(iStatus, aDelay);
    85 	SetActive();
    86 	}
    87 
    88 
    89 // -eof-