77
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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: OOM Monitor plug-in interface.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <apgwgnam.h>
|
|
19 |
#include "oommonitorplugin.h"
|
|
20 |
#include "oommemorymonitor.h"
|
|
21 |
#include "OomTraces.h"
|
|
22 |
|
|
23 |
// TLS is used to store the CMemoryMonitor pointer, CMemoryMonitor
|
|
24 |
// being the main object in the OOM monitor thread. This allows
|
|
25 |
// plugins to access the CMemoryMonitor object easily.
|
|
26 |
EXPORT_C void SetMemoryMonitorTls(CMemoryMonitor* aMonitor)
|
|
27 |
{
|
|
28 |
FUNC_LOG;
|
|
29 |
|
|
30 |
Dll::SetTls(aMonitor);
|
|
31 |
}
|
|
32 |
|
|
33 |
CMemoryMonitor* MemoryMonitorTls()
|
|
34 |
{
|
|
35 |
FUNC_LOG;
|
|
36 |
|
|
37 |
return static_cast<CMemoryMonitor*>(Dll::Tls());
|
|
38 |
}
|
|
39 |
|
|
40 |
|
|
41 |
void OomMonitorPluginPanic(TOomMonitorPluginPanic aReason)
|
|
42 |
{
|
|
43 |
FUNC_LOG;
|
|
44 |
|
|
45 |
_LIT(KCat, "OomMonitorPlugin");
|
|
46 |
User::Panic(KCat, aReason);
|
|
47 |
}
|
|
48 |
|
|
49 |
|
|
50 |
EXPORT_C COomMonitorPlugin::COomMonitorPlugin()
|
|
51 |
: iMemoryMonitor(MemoryMonitorTls())
|
|
52 |
{
|
|
53 |
FUNC_LOG;
|
|
54 |
|
|
55 |
__ASSERT_ALWAYS(iMemoryMonitor, OomMonitorPluginPanic(EOomMonitorPluginPanic_PluginConstructedOutsideOomMonitorThread));
|
|
56 |
}
|
|
57 |
|
|
58 |
EXPORT_C COomMonitorPlugin::~COomMonitorPlugin()
|
|
59 |
{
|
|
60 |
FUNC_LOG;
|
|
61 |
}
|
|
62 |
|
|
63 |
EXPORT_C void COomMonitorPlugin::ConstructL()
|
|
64 |
{
|
|
65 |
FUNC_LOG;
|
|
66 |
|
|
67 |
// CAppOomMonitorPlugin assumes ConstructL is empty
|
|
68 |
}
|
|
69 |
|
|
70 |
EXPORT_C void COomMonitorPlugin::ExtensionInterface(TUid /*aInterfaceId*/, TAny*& /*aImplementaion*/)
|
|
71 |
{
|
|
72 |
FUNC_LOG;
|
|
73 |
}
|
|
74 |
|
|
75 |
EXPORT_C RFs& COomMonitorPlugin::FsSession()
|
|
76 |
{
|
|
77 |
FUNC_LOG;
|
|
78 |
|
|
79 |
return iMemoryMonitor->iFs;
|
|
80 |
}
|
|
81 |
|
|
82 |
EXPORT_C RWsSession& COomMonitorPlugin::WsSession()
|
|
83 |
{
|
|
84 |
FUNC_LOG;
|
|
85 |
|
|
86 |
return iMemoryMonitor->iWs;
|
|
87 |
}
|
|
88 |
|
|
89 |
EXPORT_C void COomMonitorPluginV2::FreeRam()
|
|
90 |
{
|
|
91 |
// Note that OomMonitorV2 will not call this version of the function
|
|
92 |
// so it does not need to be implemented in derived classes.
|
|
93 |
}
|
|
94 |
|
|
95 |
EXPORT_C CAppOomMonitorPlugin* CAppOomMonitorPlugin::NewL(TUid aAppUid)
|
|
96 |
{
|
|
97 |
CAppOomMonitorPlugin* self = new(ELeave) CAppOomMonitorPlugin(aAppUid);
|
|
98 |
// ConstructL() currently not needed
|
|
99 |
return self;
|
|
100 |
}
|
|
101 |
|
|
102 |
CAppOomMonitorPlugin::CAppOomMonitorPlugin(TUid aAppUid)
|
|
103 |
: iAppUid(aAppUid)
|
|
104 |
{
|
|
105 |
}
|
|
106 |
|
|
107 |
void CAppOomMonitorPlugin::FreeRam()
|
|
108 |
{
|
|
109 |
SendMessageToApp(KAppOomMonitor_FreeRam);
|
|
110 |
}
|
|
111 |
|
|
112 |
void CAppOomMonitorPlugin::MemoryGood()
|
|
113 |
{
|
|
114 |
SendMessageToApp(KAppOomMonitor_MemoryGood);
|
|
115 |
}
|
|
116 |
|
|
117 |
void CAppOomMonitorPlugin::SendMessageToApp(TInt aMessage)
|
|
118 |
{
|
|
119 |
RWsSession& ws = WsSession();
|
|
120 |
TInt wgId = 0;
|
|
121 |
|
|
122 |
do
|
|
123 |
{
|
|
124 |
CApaWindowGroupName::FindByAppUid(iAppUid, ws, wgId);
|
|
125 |
if (wgId>0)
|
|
126 |
{
|
|
127 |
TWsEvent event;
|
|
128 |
event.SetType(aMessage);
|
|
129 |
event.SetTimeNow();
|
|
130 |
ws.SendEventToWindowGroup(wgId, event);
|
|
131 |
}
|
|
132 |
}
|
|
133 |
while (wgId>0);
|
|
134 |
}
|
|
135 |
|