|
1 // Copyright (c) 2007-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 "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 // |
|
15 |
|
16 #include "logonbackofftimer.h" |
|
17 #include "SysStartDebug.h" |
|
18 |
|
19 |
|
20 const TInt KMonitorLogonRetryFirstInterval = 100000; // 100ms |
|
21 const TInt KMonitorLogonRetryMaxInterval = 10000000; // 10s |
|
22 const TInt KMonitorLogonRetryIntervalMultiple = 2; |
|
23 |
|
24 |
|
25 |
|
26 /** |
|
27 Called from CMonitor |
|
28 */ |
|
29 void CLogonBackoffTimer::ProcessLogon() |
|
30 { |
|
31 |
|
32 if( (iMonitor.DoProcessLogon() == KErrNoMemory) ) |
|
33 { |
|
34 iTimer.After( iStatus, iRetryInterval ); |
|
35 SetActive(); |
|
36 |
|
37 if( (iRetryInterval *= KMonitorLogonRetryIntervalMultiple) >= KMonitorLogonRetryMaxInterval ) |
|
38 { |
|
39 iRetryInterval = KMonitorLogonRetryMaxInterval; |
|
40 } |
|
41 |
|
42 |
|
43 DEBUGPRINT1( _L("SysMonMonitor: Logon failed owing to lack of memory ") ); |
|
44 } |
|
45 else |
|
46 { |
|
47 iMonitor.ActivateSelf(); |
|
48 iRetryInterval = KMonitorLogonRetryFirstInterval; |
|
49 } |
|
50 |
|
51 } |
|
52 |
|
53 |
|
54 |
|
55 void CLogonBackoffTimer::RunL() |
|
56 { |
|
57 |
|
58 ProcessLogon(); |
|
59 } |
|
60 |
|
61 |
|
62 |
|
63 void CLogonBackoffTimer::DoCancel() |
|
64 { |
|
65 |
|
66 iTimer.Cancel(); |
|
67 } |
|
68 |
|
69 |
|
70 |
|
71 TInt CLogonBackoffTimer::RunError( TInt /*aError*/ ) |
|
72 { |
|
73 |
|
74 iTimer.Cancel(); |
|
75 |
|
76 return KErrNone; |
|
77 } |
|
78 |
|
79 |
|
80 |
|
81 CLogonBackoffTimer* CLogonBackoffTimer::NewL( MLogonCallback& aMonitor ) |
|
82 { |
|
83 |
|
84 CLogonBackoffTimer* self = new(ELeave) CLogonBackoffTimer( aMonitor ); |
|
85 CleanupStack::PushL( self ); |
|
86 self->ConstructL(); |
|
87 CleanupStack::Pop(); |
|
88 |
|
89 return self; |
|
90 } |
|
91 |
|
92 |
|
93 |
|
94 void CLogonBackoffTimer::ConstructL() |
|
95 { |
|
96 |
|
97 User::LeaveIfError( iTimer.CreateLocal() ); |
|
98 CActiveScheduler::Add( this ); |
|
99 } |
|
100 |
|
101 |
|
102 |
|
103 CLogonBackoffTimer::CLogonBackoffTimer( MLogonCallback& aMonitor ) |
|
104 : CActive( EPriorityStandard ), iMonitor( aMonitor ), iRetryInterval( KMonitorLogonRetryFirstInterval ) |
|
105 { |
|
106 } |
|
107 |
|
108 |
|
109 |
|
110 CLogonBackoffTimer::~CLogonBackoffTimer() |
|
111 { |
|
112 Cancel(); |
|
113 iTimer.Close(); |
|
114 } |