persistentstorage/centralrepository/cenrepsrv/obsrvr_noc.cpp
branchRCL_3
changeset 24 cc28652e0254
parent 23 26645d81f48d
equal deleted inserted replaced
23:26645d81f48d 24:cc28652e0254
   702 	RHeap& myHeap = User::Heap();
   702 	RHeap& myHeap = User::Heap();
   703 	TInt firstSize = myHeap.Size();
   703 	TInt firstSize = myHeap.Size();
   704 	TInt biggestBlock;
   704 	TInt biggestBlock;
   705 	TInt firstAvail = myHeap.Available(biggestBlock);
   705 	TInt firstAvail = myHeap.Available(biggestBlock);
   706 	
   706 	
   707 	TRAPD(err, aRepository = CSharedRepository::NewL(aUid));
   707 	aRepository = CSharedRepository::NewL(aUid);
   708 #ifdef CACHE_OOM_TESTABILITY
   708 #ifdef CACHE_OOM_TESTABILITY
   709 	if ((err!=KErrNone)&&!iTrapOOMOnOpen)	
   709 	if ((aRepository==NULL)&&!iTrapOOMOnOpen)	
   710 		{
   710 		{
   711 		User::Leave(err);
   711 		User::Leave(KErrNoMemory);
   712 		}
   712 		}
   713 #endif	
   713 #endif	
   714 	if ((err!=KErrNone)&&TServerResources::iCacheManager->Enabled())
   714 	if ((aRepository==NULL)&&TServerResources::iCacheManager->Enabled())
   715 		{
   715 		{
   716 		// If cache enabled, try recovery by releasing the cache
   716 		// If cache enabled, try recovery by releasing the cache
   717 		TServerResources::iCacheManager->FlushCache(EFalse);
   717 		TServerResources::iCacheManager->FlushCache(EFalse);
   718 		// retry
   718 		// retry
   719 		aRepository = CSharedRepository::NewL(aUid);
   719 		aRepository = CSharedRepository::NewL(aUid);
   720 		err = KErrNone;
   720 		}
   721 		}
   721 	// If still no memory, return error
   722 	User::LeaveIfError(err);
   722 	if (aRepository==NULL)
   723 	CleanupStack::PushL(aRepository);
   723 		{
       
   724 		User::Leave(KErrNoMemory);
       
   725 		}
       
   726 	else // successfully created the object, so push it into the cleanup stack
       
   727 		{
       
   728 		CleanupStack::PushL(aRepository);
       
   729 		}
   724 		
   730 		
   725 	// Now that we have enough memory for the object and constructed it properly
   731 	// Now that we have enough memory for the object and constructed it properly
   726 	// we try to load it. We trap all errors, either from leaving functions or error code
   732 	// we try to load it. We trap all errors, either from leaving functions or error code
   727 	// returning functions and unify them (in all cases only one of these codes will
   733 	// returning functions and unify them (in all cases only one of these codes will
   728 	// contain a valid value and the other will be 0, and for our purposes we treat
   734 	// contain a valid value and the other will be 0, and for our purposes we treat