|
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: Classes for executing GOOM actions (e.g. closing applications and running plugins). |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <goommonitorplugin.hrh> |
|
20 #include "goomrunplugin.h" |
|
21 #include "goomtraces.h" |
|
22 #include "goommemorymonitor.h" |
|
23 #include "goommonitorplugin.h" |
|
24 #include "goomactionlist.h" |
|
25 |
|
26 CGOomRunPlugin* CGOomRunPlugin::NewL(TUint aPluginId, CGOomRunPluginConfig& aConfig, MGOomActionObserver& aStateChangeObserver, CGOomMonitorPlugin& aPlugin) |
|
27 { |
|
28 FUNC_LOG; |
|
29 |
|
30 CGOomRunPlugin* self = new (ELeave) CGOomRunPlugin(aPluginId, aConfig, aStateChangeObserver, aPlugin); |
|
31 CleanupStack::PushL(self); |
|
32 self->ConstructL(aConfig); |
|
33 CleanupStack::Pop(self); |
|
34 return self; |
|
35 } |
|
36 |
|
37 // Run the GOOM plugin in order to free memory |
|
38 // Call the CGOomAction::MemoryFreed when it is done |
|
39 void CGOomRunPlugin::FreeMemory(TInt aBytesRequested) |
|
40 { |
|
41 FUNC_LOG; |
|
42 TRACES1("CGOomRunPlugin::FreeMemory: iPluginId = 0x%x", iPluginId); |
|
43 TRACES1("CGOomRunPlugin::FreeMemory: aBytesRequested = %d", aBytesRequested); |
|
44 |
|
45 // Ask the plugin to free some memory, should actually ask the difference |
|
46 // between existing and required amount.. |
|
47 TInt clientId = iStateChangeObserver.ClientId(); |
|
48 TAny* anyp = (TAny*) &clientId; |
|
49 iPlugin.ExtensionInterface(TUid::Uid(KGoomClientSecureId), anyp); |
|
50 iPlugin.FreeRam(aBytesRequested); |
|
51 |
|
52 iFreeMemoryCalled = ETrue; |
|
53 |
|
54 // Wait for the required time before we signal completion. |
|
55 iPluginWaiter->Start(); |
|
56 } |
|
57 |
|
58 // Call the memory good function on the plugin but... |
|
59 // only if there is an outstanding FreeMemory request |
|
60 void CGOomRunPlugin::MemoryGood() |
|
61 { |
|
62 FUNC_LOG; |
|
63 |
|
64 if (iFreeMemoryCalled) |
|
65 { |
|
66 iPlugin.MemoryGood(); |
|
67 iFreeMemoryCalled = EFalse; |
|
68 } |
|
69 } |
|
70 |
|
71 CGOomRunPlugin::~CGOomRunPlugin() |
|
72 { |
|
73 FUNC_LOG; |
|
74 |
|
75 delete iPluginWaiter; |
|
76 } |
|
77 |
|
78 CGOomRunPlugin::CGOomRunPlugin(TUint aPluginId, CGOomRunPluginConfig& aConfig, MGOomActionObserver& aStateChangeObserver, CGOomMonitorPlugin& aPlugin) : CGOomAction(aStateChangeObserver), iPluginId(aPluginId), iPlugin(aPlugin), iConfig(aConfig) |
|
79 { |
|
80 FUNC_LOG; |
|
81 } |
|
82 |
|
83 void CGOomRunPlugin::ConstructL(CGOomRunPluginConfig& aPluginConfig) |
|
84 { |
|
85 FUNC_LOG; |
|
86 |
|
87 TInt waitDuration = CMemoryMonitor::GlobalConfig().iDefaultWaitAfterPlugin; |
|
88 |
|
89 if (aPluginConfig.WaitAfterPluginDefined()) |
|
90 { |
|
91 // If the wait duration for this plugin is overridden then use the overridden value |
|
92 waitDuration = aPluginConfig.WaitAfterPlugin(); |
|
93 } |
|
94 |
|
95 iPluginWaiter = CGOomPluginWaiter::NewL(waitDuration, *this); |
|
96 } |