|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef MEMSPYEVENTMONITOR_H |
|
19 #define MEMSPYEVENTMONITOR_H |
|
20 |
|
21 // System includes |
|
22 #include <kernel.h> |
|
23 #include <kern_priv.h> |
|
24 |
|
25 // Classes referenced |
|
26 class DMemSpyDriverDevice; |
|
27 |
|
28 // For EMTypeMask |
|
29 enum TMemSpyEventMonitorEvent |
|
30 { |
|
31 EMemSpyEventNull = 0x0000, |
|
32 // |
|
33 EMemSpyEventThreadAdd = 0x0001, |
|
34 EMemSpyEventThreadRemove = 0x0002, |
|
35 EMemSpyEventThreadKill = 0x0004, |
|
36 // |
|
37 EMemSpyEventProcessAdd = 0x0008, |
|
38 EMemSpyEventProcessUpdate = 0x0010, |
|
39 EMemSpyEventProcessRemove = 0x0020, |
|
40 // |
|
41 EMemSpyEventChunkAdd = 0x0040, |
|
42 EMemSpyEventChunkUpdate = 0x0080, |
|
43 EMemSpyEventChunkDelete = 0x0100, |
|
44 }; |
|
45 |
|
46 |
|
47 class MMemSpyEventMonitorObserver |
|
48 { |
|
49 public: // From MMemSpyEventMonitorObserver |
|
50 virtual TUint EMTypeMask() const = 0; |
|
51 // |
|
52 virtual void EMHandleProcessAdd( DProcess& /*aProcess*/ ) { } |
|
53 virtual void EMHandleProcessUpdated( DProcess& /*aProcess*/ ) { } |
|
54 virtual void EMHandleProcessRemoved( DProcess& /*aProcess*/ ) { } |
|
55 // |
|
56 virtual void EMHandleThreadAdd( DThread& /*aThread*/ ) { } |
|
57 virtual void EMHandleThreadRemoved( DThread& /*aThread*/ ) { } |
|
58 virtual void EMHandleThreadKilled( DThread& /*aThread*/ ) { } |
|
59 // |
|
60 virtual void EMHandleChunkAdd( DChunk& /*aChunk*/ ) { } |
|
61 virtual void EMHandleChunkUpdated( DChunk& /*aChunk*/ ) { } |
|
62 virtual void EMHandleChunkDeleted( DChunk& /*aChunk*/ ) { } |
|
63 |
|
64 public: // Nasty, but I don't care... |
|
65 SDblQueLink __iEMLink; |
|
66 }; |
|
67 |
|
68 |
|
69 |
|
70 class DMemSpyEventMonitor : public DKernelEventHandler |
|
71 { |
|
72 public: |
|
73 DMemSpyEventMonitor(); |
|
74 ~DMemSpyEventMonitor(); |
|
75 |
|
76 public: // Device API |
|
77 TInt Create( DMemSpyDriverDevice* aDevice ); |
|
78 TInt Start(); |
|
79 TInt Stop(); |
|
80 |
|
81 public: // API |
|
82 TInt RequestEvents( MMemSpyEventMonitorObserver& aObserver ); |
|
83 TInt RequestEventsCancel( MMemSpyEventMonitorObserver& aObserver ); |
|
84 |
|
85 private: // Handle kernel event callbacks |
|
86 static TUint EventHandler( TKernelEvent aEvent, TAny* a1, TAny* a2, TAny* aThis ); |
|
87 TUint HandleEvent( TKernelEvent aType, TAny* a1, TAny* a2 ); |
|
88 // |
|
89 void EventProcessAdd( DProcess* aProcess ); |
|
90 void EventProcessUpdate( DProcess* aProcess ); |
|
91 void EventProcessRemoved( DProcess* aProcess ); |
|
92 // |
|
93 void EventThreadAdd( DThread* aThread ); |
|
94 void EventThreadRemoved( DThread* aThread ); |
|
95 void EventThreadKilled( DThread* aThread ); |
|
96 // |
|
97 void EventChunkAdd( DChunk* aChunk ); |
|
98 void EventChunkUpdate( DChunk* aChunk ); |
|
99 void EventChunkDelete( DChunk* aChunk ); |
|
100 |
|
101 private: // Internal methods |
|
102 TBool IsObserving( MMemSpyEventMonitorObserver& aObserver ); |
|
103 |
|
104 private: |
|
105 /** Lock serialising calls to event handler */ |
|
106 DMutex* iLock; |
|
107 |
|
108 /** open reference to LDD for avoiding lifetime issues */ |
|
109 DLogicalDevice* iDevice; |
|
110 |
|
111 // List of observers |
|
112 SDblQue iObservers; |
|
113 |
|
114 // Whether we are tracking or not |
|
115 TBool iTracking; |
|
116 }; |
|
117 |
|
118 #endif |