browserui/browser/BrowserAppSrc/BrowserAppEntryPoint.cpp
changeset 51 48e827313edd
parent 37 481242ead638
child 53 f427d27b98d8
equal deleted inserted replaced
37:481242ead638 51:48e827313edd
     1 /*
       
     2 * Copyright (c) 2002 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 the License "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 *     Browser App Entry point
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #include "BrowserApplication.h"
       
    22 #include <e32std.h>
       
    23 #include <u32std.h>
       
    24 #include <eikapp.h>
       
    25 #include <eikstart.h>
       
    26 #include <MemoryManager.h>
       
    27 #include <OOMMonitorSession.h>
       
    28 
       
    29 const int KFreeMemoryTarget = 6000000;
       
    30 
       
    31 LOCAL_C CApaApplication* NewApplication( )
       
    32     {
       
    33     return new CBrowserApplication;
       
    34     }
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    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     {
       
    43     TInt r = KErrNone;
       
    44     if (!aInfo.iAllocator && aInfo.iHeapInitialSize>0)
       
    45         {
       
    46         // new heap required
       
    47         RHeap* pH = NULL;
       
    48         r = CreateThreadHeap(aInfo, pH);
       
    49         if (r == KErrNone && !aSubThread)
       
    50             {
       
    51             // main thread - new allocator created and set as default heap      
       
    52             MemoryManager::CreateFastAllocator();
       
    53             }
       
    54         }
       
    55     else if (aInfo.iAllocator)
       
    56         {
       
    57         // sharing a heap
       
    58         RAllocator* pA = aInfo.iAllocator;
       
    59         pA->Open();
       
    60         User::SwitchAllocator(pA);
       
    61         }
       
    62 
       
    63     return r;
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // E32Main
       
    68 // -----------------------------------------------------------------------------
       
    69 GLDEF_C TInt E32Main()
       
    70     {
       
    71     ROomMonitorSession oomMs;
       
    72     TInt result = oomMs.Connect();
       
    73     if ( result == KErrNone )
       
    74         {
       
    75         result = oomMs.RequestFreeMemory( KFreeMemoryTarget );
       
    76         oomMs.Close();
       
    77         }
       
    78 
       
    79     // initialize MemmoryManager
       
    80     MemoryManager::InitFastAllocator();    
       
    81     
       
    82     // run application event loop
       
    83     return EikStart::RunApplication(NewApplication);
       
    84     }
       
    85 
       
    86 //  End of File