browserui/browser/BrowserAppSrc/BrowserAppEntryPoint.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 07 Jan 2010 12:48:02 +0200
changeset 32 92a061761a7b
parent 31 868cceedabd3
child 63 4baee4f15982
permissions -rw-r--r--
Revision: 200951 Kit: 201001

/*
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*     Browser App Entry point
*
*
*/


#include "BrowserApplication.h"
#include <e32std.h>
#include <u32std.h>
#include <eikapp.h>
#include <eikstart.h>
#include <MemoryManager.h>
#include <OOMMonitorSession.h>

const int KFreeMemoryTarget = 6000000;

LOCAL_C CApaApplication* NewApplication( )
    {
    return new CBrowserApplication;
    }

// -----------------------------------------------------------------------------
// SetupThreadHeap - Called for heap creation of thread in this process.
// This approach used to keep correct heap for pointers held in static data objects
// when they are destructed after E32Main() by OS.
// -----------------------------------------------------------------------------
EXPORT_C TInt UserHeap::SetupThreadHeap(TBool aSubThread, SStdEpocThreadCreateInfo& aInfo)
    {
    TInt r = KErrNone;
    if (!aInfo.iAllocator && aInfo.iHeapInitialSize>0)
        {
        // new heap required
        RHeap* pH = NULL;
        r = CreateThreadHeap(aInfo, pH);
        if (r == KErrNone && !aSubThread)
            {
            // main thread - new allocator created and set as default heap      
            MemoryManager::CreateFastAllocator();
            }
        }
    else if (aInfo.iAllocator)
        {
        // sharing a heap
        RAllocator* pA = aInfo.iAllocator;
        pA->Open();
        User::SwitchAllocator(pA);
        }

    return r;
    }

// -----------------------------------------------------------------------------
// E32Main
// -----------------------------------------------------------------------------
GLDEF_C TInt E32Main()
    {
    ROomMonitorSession oomMs;
    TInt result = oomMs.Connect();
    if ( result == KErrNone )
        {
        result = oomMs.RequestFreeMemory( KFreeMemoryTarget );
        oomMs.Close();
        }

    // initialize MemmoryManager
    MemoryManager::InitFastAllocator();    
    
    // run application event loop
    return EikStart::RunApplication(NewApplication);
    }

//  End of File