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