|
1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Base class for activation objects |
|
15 // |
|
16 #ifdef __SMP__ |
|
17 #include <nkernsmp/nkern.h> |
|
18 #endif |
|
19 #include "TraceCoreActivationBase.h" |
|
20 #include "TraceCore.h" |
|
21 #include "TraceCoreDebug.h" |
|
22 #include "TraceCoreMessageSender.h" |
|
23 #include "OstTraceDefinitions.h" |
|
24 #ifdef OST_TRACE_COMPILER_IN_USE |
|
25 #include "TraceCoreActivationBaseTraces.h" |
|
26 #endif |
|
27 |
|
28 |
|
29 |
|
30 /** |
|
31 * Constructor |
|
32 */ |
|
33 DTraceCoreActivationBase::DTraceCoreActivationBase() |
|
34 #if defined(__SMP__) |
|
35 : iActivationReadLock(TSpinLock::EOrderBTrace-1) |
|
36 #endif |
|
37 { |
|
38 } |
|
39 |
|
40 |
|
41 /** |
|
42 * Destructor |
|
43 */ |
|
44 DTraceCoreActivationBase::~DTraceCoreActivationBase() |
|
45 { |
|
46 } |
|
47 |
|
48 |
|
49 /** |
|
50 * Subscribes to message ID and registers to activation interface list |
|
51 * |
|
52 * @param aMessageID the message id to be subscribed |
|
53 */ |
|
54 TInt DTraceCoreActivationBase::Init( TUint32 aMessageId ) |
|
55 { |
|
56 // Subscribes to a message by message ID |
|
57 TInt err = Subscribe( aMessageId ); |
|
58 if ( err == KErrNone ) |
|
59 { |
|
60 // If subscribe succeeds, GetInstance will not return NULL |
|
61 err = DTraceCore::GetInstance()->RegisterActivation( *this ); |
|
62 } |
|
63 |
|
64 TC_TRACE( ETraceLevelFlow, Kern::Printf( "<DTraceCoreActivationBase::Init() - %d", err ) ); |
|
65 return err; |
|
66 } |
|
67 |
|
68 |
|
69 /** |
|
70 * Subscribes to message ID and registers to activation interface list |
|
71 * |
|
72 * @param aMessageID the message id to be subscribed |
|
73 * @param aMsgFormat Message format e.g. EMessageHeaderFormatOst |
|
74 */ |
|
75 TInt DTraceCoreActivationBase::SubscribeMessage(TUint32 aMessageId, TMessageHeaderFormat aMsgFormat) |
|
76 { |
|
77 return Subscribe(aMessageId, aMsgFormat) ; |
|
78 } |
|
79 |
|
80 |
|
81 /** |
|
82 * Registers an activation notification interface |
|
83 * |
|
84 * @param aNotification the notification interface |
|
85 */ |
|
86 TInt DTraceCoreActivationBase::RegisterActivationNotification( MTraceCoreActivationNotification& aNotification ) |
|
87 { |
|
88 OstTrace1( TRACE_FLOW, DBTRACECOREACTIVATIONBASE_REGISTERACTIVATIONNOTIFICATION_ENTRY, "> DBTraceCoreActivationBase::RegisterActivationNotification 0x%x", ( TUint )&( aNotification ) ); |
|
89 |
|
90 TInt retval = iActivationNotification.Append( &aNotification ); |
|
91 |
|
92 OstTrace1( TRACE_FLOW, DBTRACECOREACTIVATIONBASE_REGISTERACTIVATIONNOTIFICATION_EXIT, "< DBTraceCoreActivationBase::RegisterActivationNotification Ret:%d", retval ); |
|
93 return retval; |
|
94 } |
|
95 |
|
96 |
|
97 /** |
|
98 * Sends notification to TraceCore internal activation notification interfaces. |
|
99 * |
|
100 * @pre Method should be called with writer lock (iActivationWriteLock) held. |
|
101 * |
|
102 * @param aFromSettings ETrue if activation was due to settings read, EFalse if from some other source |
|
103 * @param aComponentId Component ID of the activation |
|
104 */ |
|
105 void DTraceCoreActivationBase::NotifyInternalActivation( TBool aFromSettings, TUint32 aComponentId ) |
|
106 { |
|
107 OstTraceExt2( TRACE_FLOW, DBTRACECOREACTIVATIONBASE_NOTIFYINTERNALACTIVATION_ENTRY, "> DBTraceCoreActivationBase::NotifyInternalActivation. FromSettings:%d, ComponentID:%x", (TUint32)aFromSettings, (TUint32) aComponentId ); |
|
108 |
|
109 for ( int i = 0; i < iActivationNotification.Count(); i++ ) |
|
110 { |
|
111 iActivationNotification[ i ]->ActivationChanged( *this, aFromSettings, aComponentId ); |
|
112 } |
|
113 } |
|
114 |
|
115 |
|
116 /** |
|
117 * Send response |
|
118 * |
|
119 * @param aMessage Response message |
|
120 */ |
|
121 void DTraceCoreActivationBase::SendResponse( TTraceMessage& aMessage ) |
|
122 { |
|
123 iMessageSender->SendMessage( aMessage ); |
|
124 } |
|
125 |