javaextensions/location/position/src/ctimeouttimer.cpp
changeset 21 2a9601315dfc
equal deleted inserted replaced
18:e8e63152f320 21:2a9601315dfc
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "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".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Handles timeouts for CTrackingPositioner
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "ctimeouttimer.h"
       
    21 
       
    22 using namespace java::location;
       
    23 
       
    24 // ============================ MEMBER FUNCTIONS ===============================
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // CTimeoutTimer::CTimeoutTimer
       
    28 // C++ default constructor can NOT contain any code, that
       
    29 // might leave.
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 CTimeoutTimer::CTimeoutTimer(const TCallBack& aCallBack) :
       
    33         CTimer(EPriorityNormal), iCallBack(aCallBack)
       
    34 {
       
    35     CActiveScheduler::Add(this);
       
    36 }
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // CTimeoutTimer::NewL
       
    40 // Two-phased constructor.
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 CTimeoutTimer* CTimeoutTimer::NewL(const TCallBack& aCallBack)
       
    44 {
       
    45     CTimeoutTimer* self = new(ELeave) CTimeoutTimer(aCallBack);
       
    46     CleanupStack::PushL(self);
       
    47     self->ConstructL();
       
    48     CleanupStack::Pop(self);
       
    49     return self;
       
    50 }
       
    51 
       
    52 // Destructor
       
    53 CTimeoutTimer::~CTimeoutTimer()
       
    54 {
       
    55     Cancel();
       
    56 }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CTimeoutTimer::TimeoutAfter
       
    60 // (other items were commented in a header).
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 void CTimeoutTimer::TimeoutAfter(const TTimeIntervalMicroSeconds& aDelay)
       
    64 {
       
    65     if (aDelay < MAKE_TINT64(0, KMaxTInt))
       
    66     {
       
    67         CTimer::After(I64INT(aDelay.Int64()));
       
    68     }
       
    69     else
       
    70     {
       
    71         TTime timeoutTime;
       
    72         timeoutTime.HomeTime();
       
    73         timeoutTime += aDelay;
       
    74         CTimer::At(timeoutTime);
       
    75     }
       
    76 }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CTimeoutTimer::RunL
       
    80 // (other items were commented in a header).
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 void CTimeoutTimer::RunL()
       
    84 {
       
    85     if (iStatus == KErrNone)
       
    86     {
       
    87         iCallBack.CallBack();
       
    88     }
       
    89 }
       
    90 
       
    91 //  End of File