memspyui/source/MemSpyViewHeapTrackingResults.cpp
changeset 0 d6fe6244b863
equal deleted inserted replaced
-1:000000000000 0:d6fe6244b863
       
     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 #include "MemSpyViewHeapTrackingResults.h"
       
    19 
       
    20 // System includes
       
    21 #include <hal.h>
       
    22 #ifdef __EPOC32__
       
    23 #include <e32rom.h>
       
    24 #endif
       
    25 
       
    26 // Engine includes
       
    27 #include <memspy/engine/memspyengine.h>
       
    28 #include <memspy/engine/memspyenginehelpersysmemtrackercycle.h>
       
    29 #include <memspy/engine/memspyenginehelpersysmemtrackercyclechange.h>
       
    30 #include <memspy/engine/memspyenginehelpersysmemtrackerenums.h>
       
    31 #include <memspy/engine/memspyenginehelpersysmemtracker.h>
       
    32 #include <memspy/engine/memspyenginehelpersysmemtrackerconfig.h>
       
    33 #include <memspyui.rsg>
       
    34 
       
    35 // User includes
       
    36 #include "MemSpyUiUtils.h"
       
    37 #include "MemSpyContainer.h"
       
    38 #include "MemSpyViewHeapTracking.h"
       
    39 #include "MemSpyContainerObserver.h"
       
    40 
       
    41 
       
    42 CMemSpyViewHeapTrackingResults::CMemSpyViewHeapTrackingResults( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver )
       
    43 :   CMemSpyViewBase( aEngine, aObserver )
       
    44     {
       
    45     iEngine.HelperSysMemTracker().SetObserver( this );
       
    46     }
       
    47 
       
    48 
       
    49 CMemSpyViewHeapTrackingResults::~CMemSpyViewHeapTrackingResults()
       
    50     {
       
    51     iEngine.HelperSysMemTracker().RemoveObserver( this );
       
    52     }
       
    53 
       
    54 
       
    55 void CMemSpyViewHeapTrackingResults::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
       
    56     {
       
    57     _LIT( KTitle, "Results Summary" );
       
    58     SetTitleL( KTitle );
       
    59     //
       
    60     CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
       
    61 
       
    62     // Make sure the correct item is selected
       
    63     const TInt cycleNumber = ((TInt) aSelectionRune);
       
    64     const TInt maxCycle = iEngine.HelperSysMemTracker().MdcaCount();
       
    65     if  ( cycleNumber > 0 && cycleNumber <= maxCycle )
       
    66         {
       
    67         iListBox->SetCurrentItemIndex( cycleNumber - 1 );
       
    68         HandleListBoxItemSelectedL( cycleNumber );
       
    69         }
       
    70     }
       
    71 
       
    72 
       
    73 void CMemSpyViewHeapTrackingResults::RefreshL()
       
    74     {
       
    75     SetListBoxModelL();
       
    76     CMemSpyViewBase::RefreshL();
       
    77     }
       
    78 
       
    79 
       
    80 TMemSpyViewType CMemSpyViewHeapTrackingResults::ViewType() const
       
    81     {
       
    82     return EMemSpyViewTypeHeapTrackingResults;
       
    83     }
       
    84 
       
    85 
       
    86 CMemSpyViewBase* CMemSpyViewHeapTrackingResults::PrepareParentViewL()
       
    87     {
       
    88     CMemSpyViewHeapTracking* parent = new(ELeave) CMemSpyViewHeapTracking( iEngine, iObserver );
       
    89     CleanupStack::PushL( parent );
       
    90     parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() );
       
    91     CleanupStack::Pop( parent );
       
    92     //
       
    93     iEngine.HelperSysMemTracker().RemoveObserver( this );
       
    94     //
       
    95     return parent;
       
    96     }
       
    97 
       
    98 
       
    99 CMemSpyViewBase* CMemSpyViewHeapTrackingResults::PrepareChildViewL()
       
   100     {
       
   101     const TInt index = iListBox->CurrentItemIndex();
       
   102     //
       
   103     CMemSpyViewBase* child = NULL;
       
   104     if  ( index >= 0 )
       
   105         {
       
   106         const CMemSpyEngineHelperSysMemTrackerCycle* cycle = iEngine.HelperSysMemTracker().CompletedCycles()[ index ];
       
   107         //
       
   108         child = new(ELeave) CMemSpyViewHeapTrackingResultsCycleInfo( iEngine, iObserver, *cycle );
       
   109         CleanupStack::PushL( child );
       
   110         child->ConstructL( Rect(), *Parent() );
       
   111         CleanupStack::Pop( child );
       
   112         //
       
   113         iEngine.HelperSysMemTracker().RemoveObserver( this );
       
   114         }
       
   115     //
       
   116     return child;
       
   117     }
       
   118 
       
   119 
       
   120 void CMemSpyViewHeapTrackingResults::SetListBoxModelL()
       
   121     {
       
   122     CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
       
   123     MDesCArray* contents = &iEngine.HelperSysMemTracker();
       
   124     listbox->Model()->SetItemTextArray( contents );
       
   125     listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   126     }
       
   127 
       
   128 
       
   129 void CMemSpyViewHeapTrackingResults::HandleCyclesResetL()
       
   130     {
       
   131     CMemSpyViewBase::RefreshL();
       
   132     }
       
   133 
       
   134 
       
   135 void CMemSpyViewHeapTrackingResults::HandleCycleStartedL( const CMemSpyEngineHelperSysMemTrackerCycle& /*aCycle*/ )
       
   136     {
       
   137     }
       
   138 
       
   139 
       
   140 void CMemSpyViewHeapTrackingResults::HandleCycleFinishedL( const CMemSpyEngineHelperSysMemTrackerCycle& /*aCycle*/ )
       
   141     {
       
   142     SetListBoxCurrentItemIndexL( iEngine.HelperSysMemTracker().MdcaCount() - 1 );
       
   143     CMemSpyViewBase::RefreshL();
       
   144     }
       
   145 
       
   146 
       
   147 
       
   148 
       
   149 
       
   150 
       
   151 
       
   152 
       
   153 
       
   154 
       
   155 
       
   156 
       
   157 
       
   158 
       
   159 
       
   160 
       
   161 
       
   162 
       
   163 
       
   164 
       
   165 
       
   166 
       
   167 
       
   168 
       
   169 
       
   170 
       
   171 
       
   172 
       
   173 
       
   174 
       
   175 
       
   176 
       
   177 CMemSpyViewHeapTrackingResultsCycleInfo::CMemSpyViewHeapTrackingResultsCycleInfo( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, const CMemSpyEngineHelperSysMemTrackerCycle& aCycle )
       
   178 :   CMemSpyViewBase( aEngine, aObserver ), iCycle( aCycle )
       
   179     {
       
   180     iEngine.HelperSysMemTracker().SetObserver( this );
       
   181     }
       
   182 
       
   183 
       
   184 CMemSpyViewHeapTrackingResultsCycleInfo::~CMemSpyViewHeapTrackingResultsCycleInfo()
       
   185     {
       
   186     iEngine.HelperSysMemTracker().RemoveObserver( this );
       
   187     }
       
   188 
       
   189 
       
   190 void CMemSpyViewHeapTrackingResultsCycleInfo::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
       
   191     {
       
   192     _LIT( KTitleFormat, "Cycle Summary [%04d]" );
       
   193     TBuf<30> buf;
       
   194     buf.Format( KTitleFormat, iCycle.CycleNumber() );
       
   195     SetTitleL( buf );
       
   196     //
       
   197     CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
       
   198 
       
   199     // Make sure the correct item is selected
       
   200     const TInt index = ((TInt) aSelectionRune);
       
   201     iListBox->SetCurrentItemIndex( index );
       
   202     HandleListBoxItemSelectedL( index );
       
   203     }
       
   204 
       
   205 
       
   206 void CMemSpyViewHeapTrackingResultsCycleInfo::RefreshL()
       
   207     {
       
   208     SetListBoxModelL();
       
   209     CMemSpyViewBase::RefreshL();
       
   210     }
       
   211 
       
   212 
       
   213 TMemSpyViewType CMemSpyViewHeapTrackingResultsCycleInfo::ViewType() const
       
   214     {
       
   215     return EMemSpyViewTypeHeapTrackingResultsCycleInfo;
       
   216     }
       
   217 
       
   218 
       
   219 CMemSpyViewBase* CMemSpyViewHeapTrackingResultsCycleInfo::PrepareParentViewL()
       
   220     {
       
   221     CMemSpyViewHeapTrackingResults* parent = new(ELeave) CMemSpyViewHeapTrackingResults( iEngine, iObserver );
       
   222     CleanupStack::PushL( parent );
       
   223     parent->ConstructL( Rect(), *Parent(), (TAny*) iCycle.CycleNumber() );
       
   224     CleanupStack::Pop( parent );
       
   225     //
       
   226     iEngine.HelperSysMemTracker().RemoveObserver( this );
       
   227     //
       
   228     return parent;
       
   229     }
       
   230 
       
   231 
       
   232 void CMemSpyViewHeapTrackingResultsCycleInfo::SetListBoxModelL()
       
   233     {
       
   234     MDesCArray& model = const_cast< MDesCArray& >( static_cast< const MDesCArray&>( iCycle ) );
       
   235     //
       
   236     CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
       
   237     listbox->Model()->SetItemTextArray( &model );
       
   238     listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   239     }
       
   240 
       
   241 
       
   242 void CMemSpyViewHeapTrackingResultsCycleInfo::HandleCyclesResetL()
       
   243     {
       
   244     Container().NavigateToParentViewL();
       
   245     }
       
   246 
       
   247 
       
   248 void CMemSpyViewHeapTrackingResultsCycleInfo::HandleCycleStartedL( const CMemSpyEngineHelperSysMemTrackerCycle& /*aCycle*/ )
       
   249     {
       
   250     }
       
   251 
       
   252 
       
   253 void CMemSpyViewHeapTrackingResultsCycleInfo::HandleCycleFinishedL( const CMemSpyEngineHelperSysMemTrackerCycle& /*aCycle*/ )
       
   254     {
       
   255     }
       
   256 
       
   257 
       
   258 
       
   259 
       
   260 
       
   261 
       
   262 
       
   263 
       
   264 
       
   265 
       
   266 
       
   267 
       
   268 
       
   269 
       
   270 
       
   271 
       
   272 
       
   273 
       
   274 
       
   275 
       
   276 
       
   277 
       
   278 
       
   279 
       
   280 
       
   281 
       
   282 
       
   283 
       
   284 
       
   285 
       
   286 
       
   287 
       
   288 
       
   289 
       
   290 
       
   291 
       
   292 
       
   293 
       
   294 
       
   295 
       
   296 /*
       
   297 
       
   298 
       
   299 
       
   300 CMemSpyViewHeapTrackingResultsChangeDescriptor::CMemSpyViewHeapTrackingResultsChangeDescriptor( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, const CMemSpyEngineHelperSysMemTrackerCycle& aCycle, const CMemSpyEngineHelperSysMemTrackerCycleChange& aChangeDescriptor, TInt aIndex )
       
   301 :   CMemSpyViewBase( aEngine, aObserver ), iCycle( aCycle ), iChangeDescriptor( aChangeDescriptor ), iIndex( aIndex )
       
   302     {
       
   303     iEngine.HelperSysMemTracker().SetObserver( this );
       
   304     }
       
   305 
       
   306 
       
   307 CMemSpyViewHeapTrackingResultsChangeDescriptor::~CMemSpyViewHeapTrackingResultsChangeDescriptor()
       
   308     {
       
   309     iEngine.HelperSysMemTracker().RemoveObserver( this );
       
   310     }
       
   311 
       
   312 
       
   313 void CMemSpyViewHeapTrackingResultsChangeDescriptor::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune )
       
   314     {
       
   315     TBuf<30> buf;
       
   316     if  ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeHeapUser )
       
   317         {
       
   318         _LIT( KTitleFormat, "User Heap Change [%04d]" );
       
   319         buf.Format( KTitleFormat, iCycle.CycleNumber() );
       
   320         }
       
   321     else if ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeHeapKernel )
       
   322         {
       
   323         _LIT( KTitleFormat, "Kernel Heap Change [%04d]" );
       
   324         buf.Format( KTitleFormat, iCycle.CycleNumber() );
       
   325         }
       
   326     else if ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeChunk )
       
   327         {
       
   328         _LIT( KTitleFormat, "Chunk Change [%04d]" );
       
   329         buf.Format( KTitleFormat, iCycle.CycleNumber() );
       
   330         }
       
   331     else if ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeRamDrive )
       
   332         {
       
   333         _LIT( KTitleFormat, "RAM Drive Change [%04d]" );
       
   334         buf.Format( KTitleFormat, iCycle.CycleNumber() );
       
   335         }
       
   336     else if ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeStack )
       
   337         {
       
   338         _LIT( KTitleFormat, "Stack Change [%04d]" );
       
   339         buf.Format( KTitleFormat, iCycle.CycleNumber() );
       
   340         }
       
   341     else if ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeGlobalData )
       
   342         {
       
   343         _LIT( KTitleFormat, "Global Data Change [%04d]" );
       
   344         buf.Format( KTitleFormat, iCycle.CycleNumber() );
       
   345         }
       
   346     else if ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeCode )
       
   347         {
       
   348         _LIT( KTitleFormat, "RAM-Loaded Code Change [%04d]" );
       
   349         buf.Format( KTitleFormat, iCycle.CycleNumber() );
       
   350         }
       
   351     else if ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeHandle )
       
   352         {
       
   353         _LIT( KTitleFormat, "Handle Change [%04d]" );
       
   354         buf.Format( KTitleFormat, iCycle.CycleNumber() );
       
   355         }
       
   356     else if ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeOpenFile )
       
   357         {
       
   358         _LIT( KTitleFormat, "Open File Change [%04d]" );
       
   359         buf.Format( KTitleFormat, iCycle.CycleNumber() );
       
   360         }
       
   361     else if ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeDiskSpace )
       
   362         {
       
   363         _LIT( KTitleFormat, "Disk Space Change [%04d]" );
       
   364         buf.Format( KTitleFormat, iCycle.CycleNumber() );
       
   365         }
       
   366     else if ( iChangeDescriptor.Type() == EMemSpyEngineSysMemTrackerTypeBitmap )
       
   367         {
       
   368         _LIT( KTitleFormat, "Bitmap Change [%04d]" );
       
   369         buf.Format( KTitleFormat, iCycle.CycleNumber() );
       
   370         }
       
   371     //
       
   372     SetTitleL( buf );
       
   373     //
       
   374     CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune );
       
   375     }
       
   376 
       
   377 
       
   378 void CMemSpyViewHeapTrackingResultsChangeDescriptor::RefreshL()
       
   379     {
       
   380     SetListBoxModelL();
       
   381     CMemSpyViewBase::RefreshL();
       
   382     }
       
   383 
       
   384 
       
   385 TMemSpyViewType CMemSpyViewHeapTrackingResultsChangeDescriptor::ViewType() const
       
   386     {
       
   387     return EMemSpyViewTypeHeapTrackingResultsCycleChangeDescriptor;
       
   388     }
       
   389 
       
   390 
       
   391 CMemSpyViewBase* CMemSpyViewHeapTrackingResultsChangeDescriptor::PrepareParentViewL()
       
   392     {
       
   393     CMemSpyViewHeapTrackingResultsCycleInfo* parent = new(ELeave) CMemSpyViewHeapTrackingResultsCycleInfo( iEngine, iObserver, iCycle );
       
   394     CleanupStack::PushL( parent );
       
   395     parent->ConstructL( Rect(), *Parent(), (TAny*) iIndex );
       
   396     CleanupStack::Pop( parent );
       
   397     //
       
   398     iEngine.HelperSysMemTracker().RemoveObserver( this );
       
   399     //
       
   400     return parent;
       
   401     }
       
   402 
       
   403 
       
   404 void CMemSpyViewHeapTrackingResultsChangeDescriptor::SetListBoxModelL()
       
   405     {
       
   406     MDesCArray& model = const_cast< MDesCArray& >( static_cast< const MDesCArray&>( iChangeDescriptor ) );
       
   407     //
       
   408     CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox );
       
   409     listbox->Model()->SetItemTextArray( &model );
       
   410     listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   411     }
       
   412 
       
   413 
       
   414 void CMemSpyViewHeapTrackingResultsChangeDescriptor::HandleCyclesResetL()
       
   415     {
       
   416     CMemSpyViewHeapTrackingResults* mainResultsMenu = new(ELeave) CMemSpyViewHeapTrackingResults( iEngine, iObserver );
       
   417     CleanupStack::PushL( mainResultsMenu );
       
   418     mainResultsMenu->ConstructL( Rect(), *Parent() );
       
   419     CleanupStack::Pop( mainResultsMenu );
       
   420     //
       
   421     Container().SetNewActiveViewL( mainResultsMenu );
       
   422     }
       
   423 
       
   424 
       
   425 void CMemSpyViewHeapTrackingResultsChangeDescriptor::HandleCycleStartedL( const CMemSpyEngineHelperSysMemTrackerCycle& aCycle )
       
   426     {
       
   427     }
       
   428 
       
   429 
       
   430 void CMemSpyViewHeapTrackingResultsChangeDescriptor::HandleCycleFinishedL( const CMemSpyEngineHelperSysMemTrackerCycle& aCycle )
       
   431     {
       
   432     }
       
   433 */
       
   434