sl@0
|
1 |
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// f32test\ext\logext.cpp
|
sl@0
|
15 |
// extension that records/prints out accesses to each function and length of reads and writes
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <f32fsys.h>
|
sl@0
|
20 |
|
sl@0
|
21 |
struct TAccessLength
|
sl@0
|
22 |
{
|
sl@0
|
23 |
TInt iless512;
|
sl@0
|
24 |
TInt i512;
|
sl@0
|
25 |
TInt imore512;
|
sl@0
|
26 |
};
|
sl@0
|
27 |
|
sl@0
|
28 |
class CLoggerExtProxyDrive : public CBaseExtProxyDrive
|
sl@0
|
29 |
{
|
sl@0
|
30 |
public:
|
sl@0
|
31 |
static CLoggerExtProxyDrive* NewL(CProxyDrive* aProxyDrive, CMountCB* aMount);
|
sl@0
|
32 |
~CLoggerExtProxyDrive();
|
sl@0
|
33 |
public:
|
sl@0
|
34 |
virtual TInt Initialise();
|
sl@0
|
35 |
virtual TInt Dismounted();
|
sl@0
|
36 |
virtual TInt Enlarge(TInt aLength);
|
sl@0
|
37 |
virtual TInt ReduceSize(TInt aPos, TInt aLength);
|
sl@0
|
38 |
virtual TInt Read(TInt64 aPos,TInt aLength,const TAny* aTrg,TInt aThreadHandle,TInt anOffset);
|
sl@0
|
39 |
virtual TInt Read(TInt64 aPos,TInt aLength,TDes8& aTrg);
|
sl@0
|
40 |
virtual TInt Write(TInt64 aPos,TInt aLength,const TAny* aSrc,TInt aThreadHandle,TInt anOffset);
|
sl@0
|
41 |
virtual TInt Write(TInt64 aPos,const TDesC8& aSrc);
|
sl@0
|
42 |
virtual TInt Caps(TDes8& anInfo);
|
sl@0
|
43 |
virtual TInt Format(TFormatInfo& anInfo);
|
sl@0
|
44 |
virtual TInt GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput);
|
sl@0
|
45 |
private:
|
sl@0
|
46 |
CLoggerExtProxyDrive(CProxyDrive* aProxyDrive, CMountCB* aMount);
|
sl@0
|
47 |
private:
|
sl@0
|
48 |
TInt iInitialise;
|
sl@0
|
49 |
TInt iDismounted;
|
sl@0
|
50 |
TInt iEnlarge;
|
sl@0
|
51 |
TInt iReduceSize;
|
sl@0
|
52 |
TInt iReadThread;
|
sl@0
|
53 |
TAccessLength iReadThreadLength;
|
sl@0
|
54 |
TInt iRead;
|
sl@0
|
55 |
TAccessLength iReadLength;
|
sl@0
|
56 |
TInt iWriteThread;
|
sl@0
|
57 |
TAccessLength iWriteThreadLength;
|
sl@0
|
58 |
TInt iWrite;
|
sl@0
|
59 |
TAccessLength iWriteLength;
|
sl@0
|
60 |
TInt iCaps;
|
sl@0
|
61 |
TInt iFormat;
|
sl@0
|
62 |
};
|
sl@0
|
63 |
|
sl@0
|
64 |
class CLoggerProxyDriveFactory : public CProxyDriveFactory
|
sl@0
|
65 |
{
|
sl@0
|
66 |
public:
|
sl@0
|
67 |
CLoggerProxyDriveFactory();
|
sl@0
|
68 |
virtual TInt Install();
|
sl@0
|
69 |
virtual CProxyDrive* NewProxyDriveL(CProxyDrive* aProxy,CMountCB* aMount);
|
sl@0
|
70 |
};
|
sl@0
|
71 |
|
sl@0
|
72 |
|
sl@0
|
73 |
|
sl@0
|
74 |
LOCAL_C void LogLength(TAccessLength& aAccess,TInt aLength)
|
sl@0
|
75 |
//
|
sl@0
|
76 |
//
|
sl@0
|
77 |
//
|
sl@0
|
78 |
{
|
sl@0
|
79 |
if(aLength<512)
|
sl@0
|
80 |
{
|
sl@0
|
81 |
aAccess.iless512++;
|
sl@0
|
82 |
}
|
sl@0
|
83 |
else if(aLength==512)
|
sl@0
|
84 |
{
|
sl@0
|
85 |
aAccess.i512++;
|
sl@0
|
86 |
}
|
sl@0
|
87 |
else
|
sl@0
|
88 |
aAccess.imore512++;
|
sl@0
|
89 |
}
|
sl@0
|
90 |
|
sl@0
|
91 |
LOCAL_C void PrintLength(TAccessLength& aAccess)
|
sl@0
|
92 |
//
|
sl@0
|
93 |
//
|
sl@0
|
94 |
//
|
sl@0
|
95 |
{
|
sl@0
|
96 |
RDebug::Print(_L("\t<512 = %d"),aAccess.iless512);
|
sl@0
|
97 |
RDebug::Print(_L("\t 512 = %d"),aAccess.i512);
|
sl@0
|
98 |
RDebug::Print(_L("\t>512 = %d"),aAccess.imore512);
|
sl@0
|
99 |
}
|
sl@0
|
100 |
|
sl@0
|
101 |
|
sl@0
|
102 |
CLoggerExtProxyDrive* CLoggerExtProxyDrive::NewL(CProxyDrive* aProxyDrive, CMountCB* aMount)
|
sl@0
|
103 |
//
|
sl@0
|
104 |
//
|
sl@0
|
105 |
//
|
sl@0
|
106 |
{
|
sl@0
|
107 |
CLoggerExtProxyDrive* temp=new(ELeave) CLoggerExtProxyDrive(aProxyDrive,aMount);
|
sl@0
|
108 |
return(temp);
|
sl@0
|
109 |
}
|
sl@0
|
110 |
|
sl@0
|
111 |
|
sl@0
|
112 |
CLoggerExtProxyDrive::CLoggerExtProxyDrive(CProxyDrive* aProxyDrive, CMountCB* aMount):CBaseExtProxyDrive(aProxyDrive,aMount)
|
sl@0
|
113 |
{
|
sl@0
|
114 |
RDebug::Print(_L("CLoggerExtProxyDrive::CLoggerExtProxyDrive"));
|
sl@0
|
115 |
}
|
sl@0
|
116 |
|
sl@0
|
117 |
CLoggerExtProxyDrive::~CLoggerExtProxyDrive()
|
sl@0
|
118 |
//
|
sl@0
|
119 |
//
|
sl@0
|
120 |
//
|
sl@0
|
121 |
{
|
sl@0
|
122 |
// print out the figures obtained
|
sl@0
|
123 |
RDebug::Print(_L("Initialise = %d"),iInitialise);
|
sl@0
|
124 |
RDebug::Print(_L("Dismounted = %d"),iDismounted);
|
sl@0
|
125 |
RDebug::Print(_L("Enlarge = %d"),iEnlarge);
|
sl@0
|
126 |
RDebug::Print(_L("ReduceSize = %d"),iReduceSize);
|
sl@0
|
127 |
RDebug::Print(_L("Read Thread = %d"),iReadThread);
|
sl@0
|
128 |
if(iReadThread)
|
sl@0
|
129 |
PrintLength(iReadThreadLength);
|
sl@0
|
130 |
RDebug::Print(_L("Read = %d"),iRead);
|
sl@0
|
131 |
if(iRead)
|
sl@0
|
132 |
PrintLength(iReadLength);
|
sl@0
|
133 |
RDebug::Print(_L("Write Thread = %d"),iWriteThread);
|
sl@0
|
134 |
if(iWriteThread)
|
sl@0
|
135 |
PrintLength(iWriteThreadLength);
|
sl@0
|
136 |
RDebug::Print(_L("Write = %d"),iWrite);
|
sl@0
|
137 |
if(iWrite)
|
sl@0
|
138 |
PrintLength(iWriteLength);
|
sl@0
|
139 |
RDebug::Print(_L("Caps = %d"),iCaps);
|
sl@0
|
140 |
RDebug::Print(_L("Format = %d"),iFormat);
|
sl@0
|
141 |
}
|
sl@0
|
142 |
|
sl@0
|
143 |
TInt CLoggerExtProxyDrive::Initialise()
|
sl@0
|
144 |
//
|
sl@0
|
145 |
//
|
sl@0
|
146 |
//
|
sl@0
|
147 |
{
|
sl@0
|
148 |
RDebug::Print(_L("CLoggerExtProxyDrive::Initialise()"));
|
sl@0
|
149 |
++iInitialise;
|
sl@0
|
150 |
return(CBaseExtProxyDrive::Initialise());
|
sl@0
|
151 |
}
|
sl@0
|
152 |
|
sl@0
|
153 |
TInt CLoggerExtProxyDrive::Dismounted()
|
sl@0
|
154 |
//
|
sl@0
|
155 |
//
|
sl@0
|
156 |
//
|
sl@0
|
157 |
{
|
sl@0
|
158 |
RDebug::Print(_L("CLoggerExtProxyDrive::Dismounted()"));
|
sl@0
|
159 |
++iDismounted;
|
sl@0
|
160 |
return(CBaseExtProxyDrive::Dismounted());
|
sl@0
|
161 |
}
|
sl@0
|
162 |
|
sl@0
|
163 |
TInt CLoggerExtProxyDrive::Enlarge(TInt aLength)
|
sl@0
|
164 |
//
|
sl@0
|
165 |
//
|
sl@0
|
166 |
//
|
sl@0
|
167 |
{
|
sl@0
|
168 |
++iEnlarge;
|
sl@0
|
169 |
return(CBaseExtProxyDrive::Enlarge(aLength));
|
sl@0
|
170 |
}
|
sl@0
|
171 |
|
sl@0
|
172 |
|
sl@0
|
173 |
TInt CLoggerExtProxyDrive::ReduceSize(TInt aPos, TInt aLength)
|
sl@0
|
174 |
//
|
sl@0
|
175 |
//
|
sl@0
|
176 |
//
|
sl@0
|
177 |
{
|
sl@0
|
178 |
++iReduceSize;
|
sl@0
|
179 |
return(CBaseExtProxyDrive::ReduceSize(aPos,aLength));
|
sl@0
|
180 |
}
|
sl@0
|
181 |
|
sl@0
|
182 |
TInt CLoggerExtProxyDrive::Read(TInt64 aPos,TInt aLength,const TAny* aTrg,TInt aThreadHandle,TInt anOffset)
|
sl@0
|
183 |
//
|
sl@0
|
184 |
//
|
sl@0
|
185 |
//
|
sl@0
|
186 |
{
|
sl@0
|
187 |
++iReadThread;
|
sl@0
|
188 |
LogLength(iReadThreadLength,aLength);
|
sl@0
|
189 |
return(CBaseExtProxyDrive::Read(aPos,aLength,aTrg,aThreadHandle,anOffset));
|
sl@0
|
190 |
}
|
sl@0
|
191 |
|
sl@0
|
192 |
TInt CLoggerExtProxyDrive::Read(TInt64 aPos,TInt aLength,TDes8& aTrg)
|
sl@0
|
193 |
//
|
sl@0
|
194 |
//
|
sl@0
|
195 |
//
|
sl@0
|
196 |
{
|
sl@0
|
197 |
++iRead;
|
sl@0
|
198 |
LogLength(iReadLength,aLength);
|
sl@0
|
199 |
return(CBaseExtProxyDrive::Read(aPos,aLength,aTrg));
|
sl@0
|
200 |
}
|
sl@0
|
201 |
|
sl@0
|
202 |
TInt CLoggerExtProxyDrive::Write(TInt64 aPos,TInt aLength,const TAny* aSrc,TInt aThreadHandle,TInt anOffset)
|
sl@0
|
203 |
//
|
sl@0
|
204 |
//
|
sl@0
|
205 |
//
|
sl@0
|
206 |
{
|
sl@0
|
207 |
++iWriteThread;
|
sl@0
|
208 |
LogLength(iWriteThreadLength,aLength);
|
sl@0
|
209 |
return(CBaseExtProxyDrive::Write(aPos,aLength,aSrc,aThreadHandle,anOffset));
|
sl@0
|
210 |
}
|
sl@0
|
211 |
|
sl@0
|
212 |
TInt CLoggerExtProxyDrive::Write(TInt64 aPos,const TDesC8& aSrc)
|
sl@0
|
213 |
//
|
sl@0
|
214 |
//
|
sl@0
|
215 |
//
|
sl@0
|
216 |
{
|
sl@0
|
217 |
++iWrite;
|
sl@0
|
218 |
LogLength(iWriteLength,aSrc.Length());
|
sl@0
|
219 |
return(CBaseExtProxyDrive::Write(aPos,aSrc));
|
sl@0
|
220 |
}
|
sl@0
|
221 |
|
sl@0
|
222 |
TInt CLoggerExtProxyDrive::Caps(TDes8& anInfo)
|
sl@0
|
223 |
//
|
sl@0
|
224 |
//
|
sl@0
|
225 |
//
|
sl@0
|
226 |
{
|
sl@0
|
227 |
++iCaps;
|
sl@0
|
228 |
return(CBaseExtProxyDrive::Caps(anInfo));
|
sl@0
|
229 |
}
|
sl@0
|
230 |
|
sl@0
|
231 |
TInt CLoggerExtProxyDrive::Format(TFormatInfo& anInfo)
|
sl@0
|
232 |
//
|
sl@0
|
233 |
//
|
sl@0
|
234 |
//
|
sl@0
|
235 |
{
|
sl@0
|
236 |
++iFormat;
|
sl@0
|
237 |
return(CBaseExtProxyDrive::Format(anInfo));
|
sl@0
|
238 |
}
|
sl@0
|
239 |
|
sl@0
|
240 |
|
sl@0
|
241 |
TInt CLoggerExtProxyDrive::GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput)
|
sl@0
|
242 |
{
|
sl@0
|
243 |
switch(aInterfaceId)
|
sl@0
|
244 |
{
|
sl@0
|
245 |
// file caching supported, so pass query on to next extension
|
sl@0
|
246 |
case ELocalBufferSupport:
|
sl@0
|
247 |
return CBaseExtProxyDrive::LocalBufferSupport();
|
sl@0
|
248 |
|
sl@0
|
249 |
default:
|
sl@0
|
250 |
return CBaseExtProxyDrive::GetInterface(aInterfaceId, aInterface, aInput);
|
sl@0
|
251 |
}
|
sl@0
|
252 |
}
|
sl@0
|
253 |
|
sl@0
|
254 |
CLoggerProxyDriveFactory::CLoggerProxyDriveFactory()
|
sl@0
|
255 |
//
|
sl@0
|
256 |
//
|
sl@0
|
257 |
//
|
sl@0
|
258 |
{
|
sl@0
|
259 |
RDebug::Print(_L("CLoggerProxyDriveFactory::CLoggerProxyDriveFactory"));
|
sl@0
|
260 |
}
|
sl@0
|
261 |
|
sl@0
|
262 |
TInt CLoggerProxyDriveFactory::Install()
|
sl@0
|
263 |
//
|
sl@0
|
264 |
//
|
sl@0
|
265 |
//
|
sl@0
|
266 |
{
|
sl@0
|
267 |
_LIT(KLoggerName,"Logger");
|
sl@0
|
268 |
return(SetName(&KLoggerName));
|
sl@0
|
269 |
}
|
sl@0
|
270 |
|
sl@0
|
271 |
|
sl@0
|
272 |
CProxyDrive* CLoggerProxyDriveFactory::NewProxyDriveL(CProxyDrive* aProxy,CMountCB* aMount)
|
sl@0
|
273 |
//
|
sl@0
|
274 |
//
|
sl@0
|
275 |
//
|
sl@0
|
276 |
{
|
sl@0
|
277 |
return(CLoggerExtProxyDrive::NewL(aProxy,aMount));
|
sl@0
|
278 |
}
|
sl@0
|
279 |
|
sl@0
|
280 |
extern "C" {
|
sl@0
|
281 |
|
sl@0
|
282 |
EXPORT_C CProxyDriveFactory* CreateFileSystem()
|
sl@0
|
283 |
//
|
sl@0
|
284 |
// Create a new file system
|
sl@0
|
285 |
//
|
sl@0
|
286 |
{
|
sl@0
|
287 |
return(new CLoggerProxyDriveFactory());
|
sl@0
|
288 |
}
|
sl@0
|
289 |
}
|
sl@0
|
290 |
|