|
1 // Copyright (c) 2006-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 #ifndef __SYSMONMONITOR_H__ |
|
17 #define __SYSMONMONITOR_H__ |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <e32base.h> |
|
21 #include <startup.hrh> |
|
22 |
|
23 #include "logoncallback.h" |
|
24 #include "logonbackofftimer.h" |
|
25 |
|
26 class CSysMonServer; |
|
27 class CStartupProperties; |
|
28 class CLogonBackoffTimer; |
|
29 class CMonitor; |
|
30 |
|
31 /** |
|
32 Utility class used for decrementing the re-launch attempts after interval defined by |
|
33 KIntervalForReLaunchRateOfFailure |
|
34 */ |
|
35 NONSHARABLE_CLASS(CRelaunchIntervalTimer) : public CTimer |
|
36 { |
|
37 public: |
|
38 static CRelaunchIntervalTimer* NewL(CMonitor& aMonitor); |
|
39 void Start(); |
|
40 ~CRelaunchIntervalTimer(); |
|
41 |
|
42 private: |
|
43 CRelaunchIntervalTimer(CMonitor& aMonitor); |
|
44 void ConstructL(); |
|
45 |
|
46 private: // from CActive |
|
47 void RunL(); |
|
48 |
|
49 private: |
|
50 CMonitor* iMonitor; |
|
51 }; |
|
52 |
|
53 /** |
|
54 This class is responsible for monitoring a single process. |
|
55 @file |
|
56 @internalComponent |
|
57 @released |
|
58 */ |
|
59 class CMonitor:public CActive, public MLogonCallback |
|
60 { |
|
61 public: |
|
62 static CMonitor* NewL(CSysMonServer& aServer, const TProcessId& aId, CStartupProperties* aStartupProperties, TBool aExecuteRecoveryMethodOnFailure); |
|
63 void Start(); |
|
64 TProcessId ProcessId() const; |
|
65 ~CMonitor(); |
|
66 void DecrementRelaunchAttempts(); |
|
67 |
|
68 public: |
|
69 // From MLogonCallback |
|
70 TInt DoProcessLogon(); |
|
71 void ActivateSelf(); |
|
72 |
|
73 protected: |
|
74 static TInt Callback(TAny* aParent); |
|
75 void RestartProcessL(); |
|
76 void RunL(); |
|
77 void DoCancel(); |
|
78 TInt RunError(TInt aError); |
|
79 void CancelMonitor(); |
|
80 |
|
81 protected: |
|
82 CMonitor(CSysMonServer& aServer, const TProcessId& aId); |
|
83 void ConstructL(CStartupProperties* aStartupProperties, TBool aExecuteRecoveryMethodOnFailure); |
|
84 |
|
85 public : |
|
86 static const TInt iOffset; |
|
87 |
|
88 private: |
|
89 void FailureRecoveryPolicy(); |
|
90 TBool HasExceededRateOfFailurePolicy(); |
|
91 #ifdef SYMBIAN_SSM_GRACEFUL_SHUTDOWN |
|
92 void RestartSysDll(TBool aUseStartupMode, TInt aStartupMode = 0); |
|
93 #endif //SYMBIAN_SSM_GRACEFUL_SHUTDOWN |
|
94 private: |
|
95 CSysMonServer& iSysMonServer; |
|
96 TProcessId iProcessId; |
|
97 RProcess iProcess; |
|
98 TTime iLoadTime; |
|
99 CStartupProperties* iStartupProperties; |
|
100 TSglQueLink iSglQueLink; |
|
101 CLogonBackoffTimer* iLogonBackoffTimer; |
|
102 TInt iReLaunchAttempts; // Persistant count of the number of re-launch attempts. |
|
103 CRelaunchIntervalTimer* iReLaunchIntervalTimer; // Timer used for decrementing the re-launch attempts after interval defined by KIntervalForReLaunchRateOfFailure |
|
104 #ifdef SYMBIAN_SSM_GRACEFUL_SHUTDOWN |
|
105 RLibrary iRestartSysLib; |
|
106 TBool iRestartSysLoaded; |
|
107 #endif //SYMBIAN_SSM_GRACEFUL_SHUTDOWN |
|
108 }; |
|
109 |
|
110 #endif |