uiacceltk/hitchcock/goommonitor/inc/goomlog.h
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Logging functionality for GOOM monitor profiling
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef GOOMLOG_H_
       
    19 #define GOOMLOG_H_
       
    20 
       
    21 #ifdef _DEBUG
       
    22 
       
    23 #include <apgwgnam.h>
       
    24 
       
    25 #include "goomwindowgrouplist.h"
       
    26 
       
    27 const TUint KTimeBetweenMemorySamples = 100000; // In microseconds
       
    28 const TUint KSamplingDurationUint = 3000000;
       
    29 
       
    30 const TUint KMaxBytesOfLoggingPerSample = 20;
       
    31 
       
    32 NONSHARABLE_CLASS(CGOomLogger) : public CTimer
       
    33     {
       
    34 public:
       
    35     static CGOomLogger* NewL(RWsSession& aWs, RFs& aFs);
       
    36     
       
    37     // Start logging the available memory every n micro seconds
       
    38     // Firstly a list of the app IDs is written to the log (foreground app first)
       
    39     // Note that the log is created in memory (to a pre-allocated buffer) and flushed out after it is complete
       
    40     // the samples are saved in CSV format so that they can easily be cut and pasted to plot graphs etc.
       
    41     void StartL();
       
    42     
       
    43 // From CTimer / CActice
       
    44     void RunL();
       
    45     void DoCancel();
       
    46     
       
    47     ~CGOomLogger();
       
    48     
       
    49     void Write(const TDesC8& aBuffer);
       
    50     
       
    51 protected:
       
    52     void LogApplicationIds();
       
    53     void LogFreeMemory();
       
    54     
       
    55     CGOomLogger(RWsSession& aWs, RFs& aFs);
       
    56     void ConstructL();
       
    57     
       
    58     // Duplicated functionality from GOomMonitor
       
    59     // Duplicated because it was messy to reuse it and to minimise changes to OOM monitor during development of new features
       
    60     void ColapseWindowGroupTree();
       
    61     
       
    62     TUid GetUidFromWindowGroupId(TInt aWgId);
       
    63 
       
    64     RWsSession& iWs;    
       
    65     
       
    66     // Used to get a list of open applications
       
    67     RArray<RWsSession::TWindowGroupChainInfo> iWgIds;
       
    68     CApaWindowGroupName* iWgName;
       
    69     HBufC* iWgNameBuf;              // owned by iWgName
       
    70     
       
    71     RFs& iFs;
       
    72     
       
    73     RFile iFile;
       
    74     TBool iIsOpen;
       
    75     
       
    76     // The time when the logging was started
       
    77     TTime iStartTime;
       
    78     
       
    79     TBuf8<(KSamplingDurationUint / KTimeBetweenMemorySamples) * KMaxBytesOfLoggingPerSample> iWriteBuffer;
       
    80     };
       
    81 
       
    82 #endif //_DEBUG
       
    83 
       
    84 #endif /*OOMLOG_H_*/