1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/loggingservices/filelogger/SSVR/FLOGTHRD.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,188 @@
1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +/**
1.20 + @file
1.21 +*/
1.22 +
1.23 +#include <flogger.h>
1.24 +#include "FLOGSTD.H"
1.25 +
1.26 +
1.27 +
1.28 +#ifdef __WINS__
1.29 +/**
1.30 +stack for file logger
1.31 +
1.32 +@internalComponent
1.33 +*/
1.34 +const TUint KFLoggerStackSize=0x3000;
1.35 +
1.36 +/**
1.37 +min heap size for file logger
1.38 +
1.39 +@internalComponent
1.40 +*/
1.41 +const TUint KFLoggerMinHeapSize=0x1000;
1.42 +
1.43 +/**
1.44 +define _FLOGGER_LARGE_HEAP if flogger is
1.45 +running out of memory (KErrNoMemory)
1.46 +*/
1.47 +#ifdef _FLOGGER_LARGE_HEAP
1.48 +
1.49 + /**
1.50 + Max heap size for file logger
1.51 +
1.52 + @internalComponent
1.53 + */
1.54 + const TUint KFLoggerMaxHeapSize=0x100000; /// 1M
1.55 +
1.56 +#else
1.57 +
1.58 + /**
1.59 + Max heap size for file logger
1.60 +
1.61 + @internalComponent
1.62 + */
1.63 + const TUint KFLoggerMaxHeapSize=0x40000; /// 256K
1.64 +
1.65 +#endif // _FLOGGER_LARGE_HEAP
1.66 +#endif //__WINS__
1.67 +
1.68 +/**
1.69 +Uid for the Flogger server
1.70 +
1.71 +@internalComponent
1.72 +*/
1.73 +const TInt KFLoggerServerUid=0x10004ee0;
1.74 +
1.75 +/**
1.76 +Literal which contains FLOGSVR
1.77 +
1.78 +@internalComponent
1.79 +*/
1.80 +_LIT(KFLoggerServerExecutable,"FLOGSVR");
1.81 +
1.82 +/**
1.83 +FLogger class definition
1.84 +*/
1.85 +
1.86 +TInt FLogger::Start()
1.87 +/**
1.88 +Start the FLOGGER server.
1.89 +
1.90 +@return KErrNone if successful
1.91 +*/
1.92 + {
1.93 +
1.94 + TRequestStatus stat;
1.95 + RProcess server;
1.96 + TInt ret=server.Create(KFLoggerServerExecutable,KNullDesC,TUidType(KNullUid,KNullUid,TUid::Uid(KFLoggerServerUid)),EOwnerThread);
1.97 + if (ret!=KErrNone)
1.98 + return ret;
1.99 + server.Rendezvous(stat);
1.100 + server.Resume();
1.101 + server.Close();
1.102 + User::WaitForRequest(stat);
1.103 + return stat.Int();
1.104 + }
1.105 +
1.106 +EXPORT_C TInt FLogger::Run(FLogger::TSignal& /*aSignal*/)
1.107 +/**
1.108 +Instantiates Active scheduler for the asynchronous request.
1.109 +
1.110 +@param aSignal signal info
1.111 +@return KErrNone if successful else KErrNoMemory
1.112 +*/
1.113 + {
1.114 +
1.115 + __UHEAP_MARK;
1.116 +
1.117 + TInt ret = KErrNone;
1.118 + CTrapCleanup* cleanup=CTrapCleanup::New();
1.119 + if (cleanup==NULL)
1.120 + ret=KErrNoMemory;
1.121 +
1.122 + if (ret==KErrNone)
1.123 + ret=Init();
1.124 +
1.125 + RProcess::Rendezvous(ret);
1.126 + if (ret==KErrNone)
1.127 + CActiveScheduler::Start();
1.128 +
1.129 + delete CActiveScheduler::Current();
1.130 + delete cleanup;
1.131 +
1.132 + __UHEAP_MARKEND;
1.133 +
1.134 + return ret;
1.135 + }
1.136 +
1.137 +TInt FLogger::Init()
1.138 +/**
1.139 +Initialises CFLoggerScheduler
1.140 +
1.141 +@return KErrNone if successful
1.142 +*/
1.143 + {
1.144 +
1.145 + TRAPD(ret,CFLoggerScheduler::NewL());
1.146 + return ret;
1.147 + }
1.148 +
1.149 +/**
1.150 +CFLoggerScheduler class definitions
1.151 +*/
1.152 +
1.153 +void CFLoggerScheduler::NewL()
1.154 +/**
1.155 +Installs CActiveScheduler
1.156 +*/
1.157 + {
1.158 +
1.159 +#ifdef __WINS__
1.160 +// ensure the server thread has a handle on FLOGGER.DLL
1.161 + _LIT(KFLoggerLibraryName,"FLOGGER");
1.162 + RLibrary l;
1.163 + User::LeaveIfError(l.Load(KFLoggerLibraryName,KNullDesC));
1.164 +#endif
1.165 +
1.166 + User::LeaveIfError(RThread::RenameMe(KFLoggerServerName));
1.167 +//
1.168 + CFLoggerScheduler* self=new(ELeave) CFLoggerScheduler;
1.169 + CActiveScheduler::Install(self);
1.170 + self->iServer=CFileLoggerServer::NewL();
1.171 + }
1.172 +
1.173 +CFLoggerScheduler::~CFLoggerScheduler()
1.174 +/**
1.175 +Destructor
1.176 +*/
1.177 + {
1.178 +
1.179 + delete iServer;
1.180 + }
1.181 +
1.182 +void CFLoggerScheduler::Error(TInt aError) const
1.183 +/**
1.184 +Message servicing failed
1.185 +
1.186 +@param aError error value for failed message
1.187 +*/
1.188 + {
1.189 + iServer->Error(aError);
1.190 + }
1.191 +