First public contribution.
1 // Copyright (c) 2002-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 the License "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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32test\ext\logext.cpp
15 // extension that records/prints out accesses to each function and length of reads and writes
28 class CLoggerExtProxyDrive : public CBaseExtProxyDrive
31 static CLoggerExtProxyDrive* NewL(CProxyDrive* aProxyDrive, CMountCB* aMount);
32 ~CLoggerExtProxyDrive();
34 virtual TInt Initialise();
35 virtual TInt Dismounted();
36 virtual TInt Enlarge(TInt aLength);
37 virtual TInt ReduceSize(TInt aPos, TInt aLength);
38 virtual TInt Read(TInt64 aPos,TInt aLength,const TAny* aTrg,TInt aThreadHandle,TInt anOffset);
39 virtual TInt Read(TInt64 aPos,TInt aLength,TDes8& aTrg);
40 virtual TInt Write(TInt64 aPos,TInt aLength,const TAny* aSrc,TInt aThreadHandle,TInt anOffset);
41 virtual TInt Write(TInt64 aPos,const TDesC8& aSrc);
42 virtual TInt Caps(TDes8& anInfo);
43 virtual TInt Format(TFormatInfo& anInfo);
44 virtual TInt GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput);
46 CLoggerExtProxyDrive(CProxyDrive* aProxyDrive, CMountCB* aMount);
53 TAccessLength iReadThreadLength;
55 TAccessLength iReadLength;
57 TAccessLength iWriteThreadLength;
59 TAccessLength iWriteLength;
64 class CLoggerProxyDriveFactory : public CProxyDriveFactory
67 CLoggerProxyDriveFactory();
68 virtual TInt Install();
69 virtual CProxyDrive* NewProxyDriveL(CProxyDrive* aProxy,CMountCB* aMount);
74 LOCAL_C void LogLength(TAccessLength& aAccess,TInt aLength)
91 LOCAL_C void PrintLength(TAccessLength& aAccess)
96 RDebug::Print(_L("\t<512 = %d"),aAccess.iless512);
97 RDebug::Print(_L("\t 512 = %d"),aAccess.i512);
98 RDebug::Print(_L("\t>512 = %d"),aAccess.imore512);
102 CLoggerExtProxyDrive* CLoggerExtProxyDrive::NewL(CProxyDrive* aProxyDrive, CMountCB* aMount)
107 CLoggerExtProxyDrive* temp=new(ELeave) CLoggerExtProxyDrive(aProxyDrive,aMount);
112 CLoggerExtProxyDrive::CLoggerExtProxyDrive(CProxyDrive* aProxyDrive, CMountCB* aMount):CBaseExtProxyDrive(aProxyDrive,aMount)
114 RDebug::Print(_L("CLoggerExtProxyDrive::CLoggerExtProxyDrive"));
117 CLoggerExtProxyDrive::~CLoggerExtProxyDrive()
122 // print out the figures obtained
123 RDebug::Print(_L("Initialise = %d"),iInitialise);
124 RDebug::Print(_L("Dismounted = %d"),iDismounted);
125 RDebug::Print(_L("Enlarge = %d"),iEnlarge);
126 RDebug::Print(_L("ReduceSize = %d"),iReduceSize);
127 RDebug::Print(_L("Read Thread = %d"),iReadThread);
129 PrintLength(iReadThreadLength);
130 RDebug::Print(_L("Read = %d"),iRead);
132 PrintLength(iReadLength);
133 RDebug::Print(_L("Write Thread = %d"),iWriteThread);
135 PrintLength(iWriteThreadLength);
136 RDebug::Print(_L("Write = %d"),iWrite);
138 PrintLength(iWriteLength);
139 RDebug::Print(_L("Caps = %d"),iCaps);
140 RDebug::Print(_L("Format = %d"),iFormat);
143 TInt CLoggerExtProxyDrive::Initialise()
148 RDebug::Print(_L("CLoggerExtProxyDrive::Initialise()"));
150 return(CBaseExtProxyDrive::Initialise());
153 TInt CLoggerExtProxyDrive::Dismounted()
158 RDebug::Print(_L("CLoggerExtProxyDrive::Dismounted()"));
160 return(CBaseExtProxyDrive::Dismounted());
163 TInt CLoggerExtProxyDrive::Enlarge(TInt aLength)
169 return(CBaseExtProxyDrive::Enlarge(aLength));
173 TInt CLoggerExtProxyDrive::ReduceSize(TInt aPos, TInt aLength)
179 return(CBaseExtProxyDrive::ReduceSize(aPos,aLength));
182 TInt CLoggerExtProxyDrive::Read(TInt64 aPos,TInt aLength,const TAny* aTrg,TInt aThreadHandle,TInt anOffset)
188 LogLength(iReadThreadLength,aLength);
189 return(CBaseExtProxyDrive::Read(aPos,aLength,aTrg,aThreadHandle,anOffset));
192 TInt CLoggerExtProxyDrive::Read(TInt64 aPos,TInt aLength,TDes8& aTrg)
198 LogLength(iReadLength,aLength);
199 return(CBaseExtProxyDrive::Read(aPos,aLength,aTrg));
202 TInt CLoggerExtProxyDrive::Write(TInt64 aPos,TInt aLength,const TAny* aSrc,TInt aThreadHandle,TInt anOffset)
208 LogLength(iWriteThreadLength,aLength);
209 return(CBaseExtProxyDrive::Write(aPos,aLength,aSrc,aThreadHandle,anOffset));
212 TInt CLoggerExtProxyDrive::Write(TInt64 aPos,const TDesC8& aSrc)
218 LogLength(iWriteLength,aSrc.Length());
219 return(CBaseExtProxyDrive::Write(aPos,aSrc));
222 TInt CLoggerExtProxyDrive::Caps(TDes8& anInfo)
228 return(CBaseExtProxyDrive::Caps(anInfo));
231 TInt CLoggerExtProxyDrive::Format(TFormatInfo& anInfo)
237 return(CBaseExtProxyDrive::Format(anInfo));
241 TInt CLoggerExtProxyDrive::GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput)
245 // file caching supported, so pass query on to next extension
246 case ELocalBufferSupport:
247 return CBaseExtProxyDrive::LocalBufferSupport();
250 return CBaseExtProxyDrive::GetInterface(aInterfaceId, aInterface, aInput);
254 CLoggerProxyDriveFactory::CLoggerProxyDriveFactory()
259 RDebug::Print(_L("CLoggerProxyDriveFactory::CLoggerProxyDriveFactory"));
262 TInt CLoggerProxyDriveFactory::Install()
267 _LIT(KLoggerName,"Logger");
268 return(SetName(&KLoggerName));
272 CProxyDrive* CLoggerProxyDriveFactory::NewProxyDriveL(CProxyDrive* aProxy,CMountCB* aMount)
277 return(CLoggerExtProxyDrive::NewL(aProxy,aMount));
282 EXPORT_C CProxyDriveFactory* CreateFileSystem()
284 // Create a new file system
287 return(new CLoggerProxyDriveFactory());