|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "ProfilerTimer.h" |
|
19 |
|
20 /* |
|
21 * |
|
22 * CProfilerTimer class implementation |
|
23 * |
|
24 */ |
|
25 // -------------------------------------------------------------------------------------------- |
|
26 CProfilerTimer::CProfilerTimer(const TInt aPriority, MProfilerTimerObserver& aObserver) |
|
27 : |
|
28 CActive(aPriority), |
|
29 iObserver(aObserver) |
|
30 { |
|
31 } |
|
32 |
|
33 // -------------------------------------------------------------------------------------------- |
|
34 CProfilerTimer::~CProfilerTimer() |
|
35 { |
|
36 Cancel(); |
|
37 iTimer.Close(); |
|
38 } |
|
39 |
|
40 // -------------------------------------------------------------------------------------------- |
|
41 CProfilerTimer* CProfilerTimer::NewL(const TInt aPriority, MProfilerTimerObserver& aObserver) |
|
42 { |
|
43 CProfilerTimer* self = new (ELeave) CProfilerTimer(aPriority, aObserver); |
|
44 CleanupStack::PushL(self); |
|
45 self->ConstructL(); |
|
46 CleanupStack::Pop(); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // -------------------------------------------------------------------------------------------- |
|
51 void CProfilerTimer::ConstructL(void) |
|
52 { |
|
53 CActiveScheduler::Add(this); |
|
54 iTimer.CreateLocal(); |
|
55 } |
|
56 |
|
57 // -------------------------------------------------------------------------------------------- |
|
58 void CProfilerTimer::After(TUint aPeriodInSeconds) |
|
59 { |
|
60 Cancel(); |
|
61 TTimeIntervalMicroSeconds32 period = aPeriodInSeconds * 1000000; |
|
62 iTimer.After(iStatus, period); |
|
63 SetActive(); |
|
64 } |
|
65 |
|
66 // -------------------------------------------------------------------------------------------- |
|
67 void CProfilerTimer::DoCancel() |
|
68 { |
|
69 iTimer.Cancel(); |
|
70 } |
|
71 |
|
72 // -------------------------------------------------------------------------------------------- |
|
73 void CProfilerTimer::RunL() |
|
74 { |
|
75 iObserver.HandleTimerExpiresL(iStatus.Int()); |
|
76 } |