1 /* |
1 /* |
2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
28 |
28 |
29 // --------------------------------------------------------- |
29 // --------------------------------------------------------- |
30 // |
30 // |
31 // --------------------------------------------------------- |
31 // --------------------------------------------------------- |
32 // |
32 // |
33 COutOfMemoryWatcher* COutOfMemoryWatcher::NewL(CMemoryMonitor& aMonitor, TInt aLowRamThreshold, TInt aGoodRamThreshold, TBool aSwapUsageMonitored, TInt aLowSwapThreshold, TInt aGoodSwapThreshold) |
33 COutOfMemoryWatcher* COutOfMemoryWatcher::NewL(CMemoryMonitor& aMonitor, TInt aLowThreshold, TInt aGoodThreshold) |
34 { |
34 { |
35 FUNC_LOG; |
35 FUNC_LOG; |
36 |
36 |
37 COutOfMemoryWatcher* self = new (ELeave) COutOfMemoryWatcher(aMonitor, aSwapUsageMonitored); |
37 COutOfMemoryWatcher* self = new (ELeave) COutOfMemoryWatcher(aMonitor); |
38 CleanupStack::PushL(self); |
38 CleanupStack::PushL(self); |
39 self->ConstructL(aLowRamThreshold, aGoodRamThreshold, aLowSwapThreshold, aGoodSwapThreshold); |
39 self->ConstructL(aLowThreshold, aGoodThreshold); |
40 CleanupStack::Pop(self); |
40 CleanupStack::Pop(self); |
41 return self; |
41 return self; |
42 } |
42 } |
43 |
43 |
44 // --------------------------------------------------------- |
44 // --------------------------------------------------------- |
54 |
54 |
55 // --------------------------------------------------------- |
55 // --------------------------------------------------------- |
56 // |
56 // |
57 // --------------------------------------------------------- |
57 // --------------------------------------------------------- |
58 // |
58 // |
59 COutOfMemoryWatcher::COutOfMemoryWatcher(CMemoryMonitor& aMonitor, TBool aSwapUsageMonitored) |
59 COutOfMemoryWatcher::COutOfMemoryWatcher(CMemoryMonitor& aMonitor) |
60 : CActive(CActive::EPriorityStandard), |
60 : CActive(CActive::EPriorityStandard), |
61 iMemoryMonitor(aMonitor), |
61 iLafShutdown(aMonitor) |
62 iSwapUsageMonitored(aSwapUsageMonitored) |
|
63 { |
62 { |
64 FUNC_LOG; |
63 FUNC_LOG; |
65 |
64 |
66 CActiveScheduler::Add(this); |
65 CActiveScheduler::Add(this); |
67 } |
66 } |
68 |
67 |
69 // --------------------------------------------------------- |
68 // --------------------------------------------------------- |
70 // |
69 // |
71 // --------------------------------------------------------- |
70 // --------------------------------------------------------- |
72 // |
71 // |
73 void COutOfMemoryWatcher::ConstructL(TInt aLowRamThreshold, TInt aGoodRamThreshold, TInt aLowSwapThreshold, TInt aGoodSwapThreshold) |
72 void COutOfMemoryWatcher::ConstructL(TInt aLowThreshold, TInt aGoodThreshold) |
74 { |
73 { |
75 FUNC_LOG; |
74 FUNC_LOG; |
76 |
75 |
77 UserSvr::SetMemoryThresholds(aLowRamThreshold,aGoodRamThreshold); |
76 UserSvr::SetMemoryThresholds(aLowThreshold,aGoodThreshold); |
78 if (iSwapUsageMonitored) |
|
79 { |
|
80 SVMSwapThresholds thresholds; |
|
81 thresholds.iLowThreshold = aLowSwapThreshold; |
|
82 thresholds.iGoodThreshold = aGoodSwapThreshold; |
|
83 UserSvr::HalFunction(EHalGroupVM, EVMHalSetSwapThresholds, &thresholds, 0); |
|
84 } |
|
85 User::LeaveIfError(iChangeNotifier.Create()); |
77 User::LeaveIfError(iChangeNotifier.Create()); |
86 } |
78 } |
87 |
79 |
88 void COutOfMemoryWatcher::UpdateThresholds(TInt aLowRamThreshold, TInt aGoodRamThreshold, TInt aLowSwapThreshold, TInt aGoodSwapThreshold) |
80 void COutOfMemoryWatcher::UpdateThresholds(TInt aLowThreshold, TInt aGoodThreshold) |
89 { |
81 { |
90 FUNC_LOG; |
82 FUNC_LOG; |
91 |
83 |
92 UserSvr::SetMemoryThresholds(aLowRamThreshold,aGoodRamThreshold); |
84 UserSvr::SetMemoryThresholds(aLowThreshold,aGoodThreshold); |
93 if (iSwapUsageMonitored) |
|
94 { |
|
95 SVMSwapThresholds thresholds; |
|
96 thresholds.iLowThreshold = aLowSwapThreshold; |
|
97 thresholds.iGoodThreshold = aGoodSwapThreshold; |
|
98 UserSvr::HalFunction(EHalGroupVM, EVMHalSetSwapThresholds, &thresholds, 0); |
|
99 } |
|
100 } |
85 } |
101 |
86 |
102 // --------------------------------------------------------- |
87 // --------------------------------------------------------- |
103 // |
88 // |
104 // --------------------------------------------------------- |
89 // --------------------------------------------------------- |