browserui/browser/BrowserAppSrc/BrowserAppEntryPoint.cpp
changeset 31 868cceedabd3
parent 22 d6f226a5ad2c
child 32 92a061761a7b
equal deleted inserted replaced
27:b57c5fc53578 31:868cceedabd3
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description: 
    14 * Description:
    15 *     Browser App Entry point
    15 *     Browser App Entry point
    16 *     
    16 *
    17 *
    17 *
    18 */
    18 */
    19 
    19 
    20 
    20 
    21 #include "BrowserApplication.h"
    21 #include "BrowserApplication.h"
    31 LOCAL_C CApaApplication* NewApplication( )
    31 LOCAL_C CApaApplication* NewApplication( )
    32     {
    32     {
    33     return new CBrowserApplication;
    33     return new CBrowserApplication;
    34     }
    34     }
    35 
    35 
    36 EXPORT_C TInt UserHeap::SetupThreadHeap(TBool, SStdEpocThreadCreateInfo& aInfo)
    36 // -----------------------------------------------------------------------------
    37 	{
    37 // SetupThreadHeap - Called for heap creation of thread in this process.
       
    38 // This approach used to keep correct heap for pointers held in static data objects
       
    39 // when they are destructed after E32Main() by OS.
       
    40 // -----------------------------------------------------------------------------
       
    41 EXPORT_C TInt UserHeap::SetupThreadHeap(TBool aSubThread, SStdEpocThreadCreateInfo& aInfo)
       
    42     {
    38     TInt r = KErrNone;
    43     TInt r = KErrNone;
    39     if (!aInfo.iAllocator && aInfo.iHeapInitialSize>0)
    44     if (!aInfo.iAllocator && aInfo.iHeapInitialSize>0)
    40 		{
    45         {
    41 		// new heap required
    46         // new heap required
    42 		RHeap* pH = NULL;
    47         RHeap* pH = NULL;
    43 		r = CreateThreadHeap(aInfo, pH);
    48         r = CreateThreadHeap(aInfo, pH);
    44 		if (r == KErrNone)
    49         if (r == KErrNone && !aSubThread)
    45 			{       // should happen for main thread, otherwise panic      
    50             {
    46 					RAllocator* oldAllocator = MemoryManager::SwitchToFastAllocator();
    51             // main thread - new allocator created and set as default heap      
    47 			}
    52             MemoryManager::CreateFastAllocator();
    48 		}
    53             }
    49 	else if (aInfo.iAllocator)
    54         }
    50 		{
    55     else if (aInfo.iAllocator)
    51 		// sharing a heap
    56         {
    52 		RAllocator* pA = aInfo.iAllocator;
    57         // sharing a heap
    53 		pA->Open();
    58         RAllocator* pA = aInfo.iAllocator;
    54 		User::SwitchAllocator(pA);
    59         pA->Open();
    55 		}
    60         User::SwitchAllocator(pA);
       
    61         }
    56 
    62 
    57     return r;
    63     return r;
    58 	}
    64     }
    59 
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // E32Main
       
    68 // -----------------------------------------------------------------------------
    60 GLDEF_C TInt E32Main()
    69 GLDEF_C TInt E32Main()
    61     {
    70     {
    62     ROomMonitorSession oomMs;
    71     ROomMonitorSession oomMs;
    63     TInt r = oomMs.Connect();
    72     TInt result = oomMs.Connect();
    64     if (r == KErrNone)
    73     if ( result == KErrNone )
    65         {
    74         {
    66         r = oomMs.RequestFreeMemory(KFreeMemoryTarget);
    75         result = oomMs.RequestFreeMemory( KFreeMemoryTarget );
    67         oomMs.Close();
    76         oomMs.Close();
    68         }
    77         }
       
    78 
       
    79     // initialize MemmoryManager
       
    80     MemoryManager::InitFastAllocator();    
    69     
    81     
    70 	return EikStart::RunApplication(NewApplication);
    82     // run application event loop
       
    83     return EikStart::RunApplication(NewApplication);
    71     }
    84     }
    72 
    85 
    73 //  End of File  
    86 //  End of File