|
1 // btrace_appstart.cpp |
|
2 // |
|
3 // Copyright (c) 2008 - 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "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 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #include "btrace_parser.h" |
|
14 #include <fshell/common.mmh> |
|
15 |
|
16 |
|
17 // |
|
18 // CBtraceAppStart |
|
19 // |
|
20 |
|
21 EXPORT_C CBtraceAppStart* CBtraceAppStart::NewL(CBtraceReader& aReader, CBtraceContext& aContext) |
|
22 { |
|
23 CBtraceAppStart* self = new (ELeave) CBtraceAppStart(aReader, aContext); |
|
24 CleanupStack::PushL(self); |
|
25 self->ConstructL(); |
|
26 CleanupStack::Pop(self); |
|
27 return self; |
|
28 } |
|
29 |
|
30 CBtraceAppStart::CBtraceAppStart(CBtraceReader& aReader, CBtraceContext& aContext) |
|
31 : iReader(aReader), iContext(aContext) |
|
32 { |
|
33 } |
|
34 |
|
35 EXPORT_C CBtraceAppStart::~CBtraceAppStart() |
|
36 { |
|
37 iReader.RemoveObserver(KAmTraceCategory, *this); |
|
38 iNotifs.Close(); |
|
39 } |
|
40 |
|
41 void CBtraceAppStart::ConstructL() |
|
42 { |
|
43 iReader.AddObserverL(KAmTraceCategory, *this); |
|
44 } |
|
45 |
|
46 void CBtraceAppStart::HandleBtraceFrameL(const TBtraceFrame& aFrame) |
|
47 { |
|
48 if (aFrame.iCategory != KAmTraceCategory) return; |
|
49 |
|
50 switch (aFrame.iSubCategory) |
|
51 { |
|
52 case EAmTraceSubCategoryEvCapture: |
|
53 { |
|
54 const TUint32* data = reinterpret_cast<const TUint32*>(aFrame.iData.Ptr()); |
|
55 const TAmTraceEventEvCapture event = static_cast<TAmTraceEventEvCapture>(*data++); |
|
56 |
|
57 switch (event) |
|
58 { |
|
59 case EAmTraceEventEvCaptureAppStart: |
|
60 { |
|
61 const TInt32 wgId = *data++; |
|
62 SeenAppStartL(aFrame.iTickCount, wgId); |
|
63 } |
|
64 break; |
|
65 |
|
66 default: |
|
67 // ignore the event |
|
68 break; |
|
69 }; |
|
70 } |
|
71 break; |
|
72 |
|
73 default: |
|
74 // ignore anything we don't know about. |
|
75 break; |
|
76 }; |
|
77 } |
|
78 |
|
79 void CBtraceAppStart::SeenAppStartL(const TBtraceTickCount& aTickCount, TInt aWindowGroupId) |
|
80 { |
|
81 const TBtraceWindowGroupId* btraceWgId = iContext.FindWindowGroup(aWindowGroupId); |
|
82 if (btraceWgId) |
|
83 { |
|
84 TInt ii = iNotifs.Count(); |
|
85 while (--ii >= 0) |
|
86 { |
|
87 TAppStartNotif& nt = iNotifs[ii]; |
|
88 if (iContext.WindowGroupName(*btraceWgId).MatchF(nt.iWindowGroupNamePattern) != KErrNotFound) |
|
89 { |
|
90 MBtraceAppStartObserver& observer = nt.iObserver; |
|
91 if (nt.iPersistence == ENotificationOneShot) |
|
92 { |
|
93 iNotifs.Remove(ii); |
|
94 } |
|
95 observer.HandleAppStartL(aTickCount); |
|
96 } |
|
97 } |
|
98 } |
|
99 } |
|
100 |
|
101 EXPORT_C void CBtraceAppStart::NotifyAppStartL(MBtraceAppStartObserver& aObserver, const TDesC& aWindowGroupNamePattern) |
|
102 { |
|
103 NotifyAppStartL(aObserver, aWindowGroupNamePattern, ENotificationOneShot); |
|
104 } |
|
105 |
|
106 EXPORT_C void CBtraceAppStart::NotifyAppStartL(MBtraceAppStartObserver& aObserver, const TDesC& aWindowGroupNamePattern, TBtraceNotificationPersistence aPersistence) |
|
107 { |
|
108 TAppStartNotif notify(aObserver, aWindowGroupNamePattern, aPersistence); |
|
109 User::LeaveIfError(iNotifs.Append(notify)); |
|
110 } |
|
111 |
|
112 EXPORT_C void CBtraceAppStart::CancelNotifyAppStart(MBtraceAppStartObserver& aObserver) |
|
113 { |
|
114 for (TInt i = (iNotifs.Count() - 1); i >= 0; --i) |
|
115 { |
|
116 if (&iNotifs[i].iObserver == &aObserver) |
|
117 { |
|
118 iNotifs.Remove(i); |
|
119 } |
|
120 } |
|
121 } |
|
122 |
|
123 |
|
124 // |
|
125 // CBtraceAppStart::TAppStartNotif |
|
126 // |
|
127 |
|
128 CBtraceAppStart::TAppStartNotif::TAppStartNotif(MBtraceAppStartObserver& aObserver, const TDesC& aWindowGroupNamePattern, TBtraceNotificationPersistence aPersistence) |
|
129 : iObserver(aObserver), iWindowGroupNamePattern(aWindowGroupNamePattern), iPersistence(aPersistence) |
|
130 { |
|
131 } |