sysresmonitoring/oommonitor/inc/oomlog.h
branchRCL_3
changeset 1 0fdb7f6b0309
child 19 924385140d98
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomlog.h	Fri Feb 19 22:58:54 2010 +0200
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Logging functionality for OOM monitor profiling.
+*
+*/
+
+
+#ifndef OOMLOG_H_
+#define OOMLOG_H_
+
+#ifdef _DEBUG
+
+#include <apgwgnam.h>
+
+#include "oomwindowgrouplist.h"
+
+const TUint KTimeBetweenMemorySamples = 100000; // In microseconds
+const TUint KSamplingDurationUint = 3000000;
+
+const TUint KMaxBytesOfLoggingPerSample = 20;
+
+NONSHARABLE_CLASS(COomLogger) : public CTimer
+    {
+public:
+    static COomLogger* NewL(RWsSession& aWs, RFs& aFs);
+    
+    // Start logging the available memory every n micro seconds
+    // Firstly a list of the app IDs is written to the log (foreground app first)
+    // Note that the log is created in memory (to a pre-allocated buffer) and flushed out after it is complete
+    // the samples are saved in CSV format so that they can easily be cut and pasted to plot graphs etc.
+    void StartL();
+    
+// From CTimer / CActice
+    void RunL();
+    void DoCancel();
+    
+    ~COomLogger();
+    
+    void Write(const TDesC8& aBuffer);
+    
+protected:
+    void LogApplicationIds();
+    void LogFreeMemory();
+    
+    COomLogger(RWsSession& aWs, RFs& aFs);
+    void ConstructL();
+    
+    // Duplicated functionality from OomMonitor
+    // Duplicated because it was messy to reuse it and to minimise changes to OOM monitor during development of new features
+    void ColapseWindowGroupTree();
+    
+    TUid GetUidFromWindowGroupId(TInt aWgId);
+
+    RWsSession& iWs;    
+    
+    // Used to get a list of open applications
+    RArray<RWsSession::TWindowGroupChainInfo> iWgIds;
+    CApaWindowGroupName* iWgName;
+    HBufC* iWgNameBuf;              // owned by iWgName
+    
+    RFs& iFs;
+    
+    RFile iFile;
+    TBool iIsOpen;
+    
+    // The time when the logging was started
+    TTime iStartTime;
+    
+    TBuf8<(KSamplingDurationUint / KTimeBetweenMemorySamples) * KMaxBytesOfLoggingPerSample> iWriteBuffer;
+    };
+
+#endif //_DEBUG
+
+#endif /*OOMLOG_H_*/