equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
50 } |
50 } |
51 |
51 |
52 |
52 |
53 CMemSpyViewHeapTracking::~CMemSpyViewHeapTracking() |
53 CMemSpyViewHeapTracking::~CMemSpyViewHeapTracking() |
54 { |
54 { |
55 delete iStopTimerCallBack; |
55 delete iStopTimerCallBack; |
56 //iEngine.HelperSysMemTracker().RemoveObserver( this ); |
|
57 } |
56 } |
58 |
57 |
59 |
58 |
60 void CMemSpyViewHeapTracking::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune ) |
59 void CMemSpyViewHeapTracking::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune ) |
61 { |
60 { |
65 CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune ); |
64 CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune ); |
66 |
65 |
67 // Backup current config because it may be overwritten with Basic/Full mode settings. |
66 // Backup current config because it may be overwritten with Basic/Full mode settings. |
68 TMemSpyEngineHelperSysMemTrackerConfig config; |
67 TMemSpyEngineHelperSysMemTrackerConfig config; |
69 |
68 |
70 GetSwmtConfig( config ); |
69 GetSwmtConfigL( config ); |
71 |
70 |
72 iOriginalConfig = config; |
71 iOriginalConfig = config; |
73 |
72 |
74 if ( config.iMode != TMemSpyEngineHelperSysMemTrackerConfig::MemSpyEngineSysMemTrackerModeCustom ) |
73 if ( config.iMode != TMemSpyEngineHelperSysMemTrackerConfig::MemSpyEngineSysMemTrackerModeCustom ) |
75 { |
74 { |
80 // Make sure the correct item is selected |
79 // Make sure the correct item is selected |
81 TInt index = 0; |
80 TInt index = 0; |
82 if ( aSelectionRune != NULL ) |
81 if ( aSelectionRune != NULL ) |
83 { |
82 { |
84 const TMemSpyViewType viewType = (TMemSpyViewType) ((TInt) aSelectionRune); |
83 const TMemSpyViewType viewType = (TMemSpyViewType) ((TInt) aSelectionRune); |
85 index = IndexByViewType( viewType ); |
84 index = IndexByViewTypeL( viewType ); |
86 } |
85 } |
87 iListBox->SetCurrentItemIndex( index ); |
86 iListBox->SetCurrentItemIndex( index ); |
88 HandleListBoxItemSelectedL( index ); |
87 HandleListBoxItemSelectedL( index ); |
89 } |
88 } |
90 |
89 |
128 const TInt index = iListBox->CurrentItemIndex(); |
127 const TInt index = iListBox->CurrentItemIndex(); |
129 |
128 |
130 // Get current config |
129 // Get current config |
131 TMemSpyEngineHelperSysMemTrackerConfig config; |
130 TMemSpyEngineHelperSysMemTrackerConfig config; |
132 |
131 |
133 GetSwmtConfig( config ); |
132 GetSwmtConfigL( config ); |
134 |
133 |
135 // |
134 // |
136 if ( index == 0 ) |
135 if ( index == 0 ) |
137 { |
136 { |
138 // This is the start/stop toggle so we don't make a child view |
137 // This is the start/stop toggle so we don't make a child view |
140 |
139 |
141 // ... instead we either start or stop the tracker |
140 // ... instead we either start or stop the tracker |
142 // if ( !iEngine.HelperSysMemTracker().IsActive() ) |
141 // if ( !iEngine.HelperSysMemTracker().IsActive() ) |
143 if ( !iMemSpySession.IsSwmtRunningL() ) |
142 if ( !iMemSpySession.IsSwmtRunningL() ) |
144 { |
143 { |
145 iState = EMemSpyViewHeapTrackingStateSingleOn; |
144 DumpNowL(); |
146 // Setting observer to be able to stop SWMT after first cycle is completed |
|
147 //iEngine.HelperSysMemTracker().SetObserver( this ); |
|
148 iMemSpySession.ForceSwmtUpdateL(); |
|
149 } |
145 } |
150 |
146 |
151 // Redraw listbox |
147 // Redraw listbox |
152 RefreshL(); |
148 RefreshL(); |
153 } |
149 } |
163 iMemSpySession.StopSwmtTimerL(); |
159 iMemSpySession.StopSwmtTimerL(); |
164 |
160 |
165 } |
161 } |
166 else if ( iState == EMemSpyViewHeapTrackingStateIdle ) |
162 else if ( iState == EMemSpyViewHeapTrackingStateIdle ) |
167 { |
163 { |
168 iState = EMemSpyViewHeapTrackingStateTimerOn; |
164 iState = EMemSpyViewHeapTrackingStateTimerOn; |
169 iMemSpySession.StartSwmtTimerL(); |
165 RefreshL(); |
|
166 StartSwmtTimerL(); |
170 } |
167 } |
171 |
168 |
172 // Redraw listbox |
169 // Redraw listbox |
173 RefreshL(); |
170 RefreshL(); |
174 } |
171 } |
203 else if ( index == 3 ) |
200 else if ( index == 3 ) |
204 { |
201 { |
205 if ( config.iMode == TMemSpyEngineHelperSysMemTrackerConfig::MemSpyEngineSysMemTrackerModeCustom ) |
202 if ( config.iMode == TMemSpyEngineHelperSysMemTrackerConfig::MemSpyEngineSysMemTrackerModeCustom ) |
206 { |
203 { |
207 child = new(ELeave) CMemSpyViewHeapTrackingSettings( iMemSpySession, iObserver ); |
204 child = new(ELeave) CMemSpyViewHeapTrackingSettings( iMemSpySession, iObserver ); |
208 } |
205 } |
209 else |
|
210 { |
|
211 child = new(ELeave) CMemSpyViewHeapTrackingResults( iMemSpySession, iObserver ); |
|
212 } |
|
213 } |
|
214 else if ( index == 4 ) |
|
215 { |
|
216 child = new(ELeave) CMemSpyViewHeapTrackingResults( iMemSpySession, iObserver ); |
|
217 } |
206 } |
218 if ( child ) |
207 if ( child ) |
219 { |
208 { |
220 CleanupStack::PushL( child ); |
209 CleanupStack::PushL( child ); |
221 child->ConstructL( Rect(), *Parent() ); |
210 child->ConstructL( Rect(), *Parent() ); |
235 TBuf<KMaxFullName + 1> item; |
224 TBuf<KMaxFullName + 1> item; |
236 |
225 |
237 // Get current config |
226 // Get current config |
238 TMemSpyEngineHelperSysMemTrackerConfig config; |
227 TMemSpyEngineHelperSysMemTrackerConfig config; |
239 |
228 |
240 GetSwmtConfig( config ); |
229 GetSwmtConfigL( config ); |
241 |
230 |
242 // 1st item |
231 // 1st item |
243 _LIT( KItem1FormatEnable, "\tGet dump now" ); |
232 _LIT( KItem1FormatEnable, "\tGet dump now" ); |
244 model->AppendL( KItem1FormatEnable ); |
233 model->AppendL( KItem1FormatEnable ); |
245 |
234 |
246 |
235 |
247 // 1st item |
236 // 1st item |
248 //if ( iEngine.HelperSysMemTracker().IsActive() && iState == EMemSpyViewHeapTrackingStateTimerOn ) |
237 //if ( iEngine.HelperSysMemTracker().IsActive() && iState == EMemSpyViewHeapTrackingStateTimerOn ) |
249 if ( iMemSpySession.IsSwmtRunningL() && iState == EMemSpyViewHeapTrackingStateTimerOn ) |
238 if ( iState == EMemSpyViewHeapTrackingStateTimerOn ) //iMemSpySession.IsSwmtRunningL() && |
250 { |
239 { |
251 _LIT( KItem1FormatEnable, "\tStop timer\t\t%d (sec)" ); |
240 _LIT( KItem1FormatEnable, "\tStop timer\t\t%d (sec)" ); |
252 TName item; |
241 TName item; |
253 item.Format( KItem1FormatEnable, config.iTimerPeriod.Int() / 1000000 ); |
242 item.Format( KItem1FormatEnable, config.iTimerPeriod.Int() / 1000000 ); |
254 model->AppendL( item ); |
243 model->AppendL( item ); |
314 } |
303 } |
315 model->AppendL( item ); |
304 model->AppendL( item ); |
316 break; |
305 break; |
317 } |
306 } |
318 default: break; |
307 default: break; |
319 } |
308 } |
320 |
|
321 // 4th item |
|
322 TInt cycleCount = iMemSpySession.GetSwmtCyclesCount(); |
|
323 |
|
324 if ( cycleCount > 0 ) |
|
325 { |
|
326 _LIT( KItem2Format, "\tResults\t\t%d cycles" ); |
|
327 TFullName item; |
|
328 item.Format( KItem2Format, cycleCount ); |
|
329 model->AppendL( item ); |
|
330 } |
|
331 else |
|
332 { |
|
333 _LIT( KItem2Format, "\tResults\t\tNo results" ); |
|
334 model->AppendL( KItem2Format ); |
|
335 } |
|
336 |
309 |
337 // Set up list box |
310 // Set up list box |
338 CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); |
311 CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); |
339 listbox->Model()->SetItemTextArray( model ); |
312 listbox->Model()->SetItemTextArray( model ); |
340 listbox->Model()->SetOwnershipType( ELbmOwnsItemArray ); |
313 listbox->Model()->SetOwnershipType( ELbmOwnsItemArray ); |
353 |
326 |
354 void CMemSpyViewHeapTracking::HandleCycleFinishedL( const CMemSpyEngineHelperSysMemTrackerCycle& /*aCycle*/ ) |
327 void CMemSpyViewHeapTracking::HandleCycleFinishedL( const CMemSpyEngineHelperSysMemTrackerCycle& /*aCycle*/ ) |
355 { |
328 { |
356 // Stopping SWMT does not work directly from this function. |
329 // Stopping SWMT does not work directly from this function. |
357 // It has to be made asynchronously. |
330 // It has to be made asynchronously. |
358 // iStopTimerCallBack = new (ELeave) CAsyncCallBack( TCallBack( CMemSpyViewHeapTracking::AsyncStopTimerCallback, this ), CActive::EPriorityStandard ); |
331 iStopTimerCallBack = new (ELeave) CAsyncCallBack( TCallBack( CMemSpyViewHeapTracking::AsyncStopTimerCallback, this ), CActive::EPriorityStandard ); |
359 // iStopTimerCallBack->CallBack(); |
332 iStopTimerCallBack->CallBack(); |
360 } |
333 } |
361 |
334 |
362 |
335 |
363 TInt CMemSpyViewHeapTracking::IndexByViewType( TMemSpyViewType aType ) |
336 TInt CMemSpyViewHeapTracking::IndexByViewTypeL( TMemSpyViewType aType ) |
364 { |
337 { |
365 // Get current config |
338 // Get current config |
366 TMemSpyEngineHelperSysMemTrackerConfig config; |
339 TMemSpyEngineHelperSysMemTrackerConfig config; |
367 |
340 |
368 GetSwmtConfig( config ); |
341 GetSwmtConfigL( config ); |
369 |
342 |
370 TInt index = 0; |
343 TInt index = 0; |
371 // |
344 // |
372 switch( aType ) |
345 switch( aType ) |
373 { |
346 { |
424 break; |
397 break; |
425 } |
398 } |
426 default: User::Leave( KErrArgument ); |
399 default: User::Leave( KErrArgument ); |
427 } |
400 } |
428 // Push changes to SWMT |
401 // Push changes to SWMT |
429 SetSwmtConfig( aConfig ); |
402 SetSwmtConfigL( aConfig ); |
430 Settings().StoreSettingsL(); |
403 Settings().StoreSettingsL(); |
431 } |
404 } |
432 |
405 |
433 |
406 |
434 TInt CMemSpyViewHeapTracking::AsyncStopTimerCallback( TAny* aParam ) |
407 TInt CMemSpyViewHeapTracking::AsyncStopTimerCallback( TAny* aParam ) |
449 delete iStopTimerCallBack; |
422 delete iStopTimerCallBack; |
450 iStopTimerCallBack = NULL; |
423 iStopTimerCallBack = NULL; |
451 return KErrNone; |
424 return KErrNone; |
452 } |
425 } |
453 |
426 |
454 void CMemSpyViewHeapTracking::GetSwmtConfig( TMemSpyEngineHelperSysMemTrackerConfig& aConfig ) |
427 void CMemSpyViewHeapTracking::GetSwmtConfigL( TMemSpyEngineHelperSysMemTrackerConfig& aConfig ) |
455 { |
428 { |
456 TInt categories = 0; |
429 TInt categories = 0; |
457 iMemSpySession.GetSwmtCategoriesL( categories ); |
430 iMemSpySession.GetSwmtCategoriesL( categories ); |
458 aConfig.iEnabledCategories = categories; |
431 aConfig.iEnabledCategories = categories; |
459 |
432 |
472 TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode mode; |
445 TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode mode; |
473 iMemSpySession.GetSwmtMode( mode ); |
446 iMemSpySession.GetSwmtMode( mode ); |
474 aConfig.iMode = mode; |
447 aConfig.iMode = mode; |
475 } |
448 } |
476 |
449 |
477 void CMemSpyViewHeapTracking::SetSwmtConfig( TMemSpyEngineHelperSysMemTrackerConfig& aConfig ) |
450 void CMemSpyViewHeapTracking::SetSwmtConfigL( TMemSpyEngineHelperSysMemTrackerConfig& aConfig ) |
478 { |
451 { |
479 iMemSpySession.SetSwmtMode( aConfig.iMode ); |
452 iMemSpySession.SetSwmtMode( aConfig.iMode ); |
480 iMemSpySession.SetSwmtCategoriesL( aConfig.iEnabledCategories ); |
453 iMemSpySession.SetSwmtCategoriesL( aConfig.iEnabledCategories ); |
481 iMemSpySession.SetSwmtTimerIntervalL( aConfig.iTimerPeriod.Int() ); |
454 iMemSpySession.SetSwmtTimerIntervalL( aConfig.iTimerPeriod.Int() ); |
482 iMemSpySession.SetSwmtHeapDumpsEnabledL( aConfig.iDumpData ); |
455 iMemSpySession.SetSwmtHeapDumpsEnabledL( aConfig.iDumpData ); |
483 iMemSpySession.SetSwmtFilter( aConfig.iThreadNameFilter ); |
456 iMemSpySession.SetSwmtFilter( aConfig.iThreadNameFilter ); |
484 } |
457 } |
485 |
458 |
486 |
459 void CMemSpyViewHeapTracking::DumpNowL() |
|
460 { |
|
461 iState = EMemSpyViewHeapTrackingStateSingleOn; |
|
462 |
|
463 CMemSpySwmtDumpTracker* tracker = new (ELeave) CMemSpySwmtDumpTracker( iMemSpySession ); |
|
464 |
|
465 tracker->StartL(); |
|
466 } |
|
467 |
|
468 void CMemSpyViewHeapTracking::StartSwmtTimerL() |
|
469 { |
|
470 CMemSpySwmtStartTimerTracker* tracker = new (ELeave) CMemSpySwmtStartTimerTracker( iMemSpySession ); |
|
471 |
|
472 tracker->StartL(); |
|
473 } |