persistentstorage/centralrepository/cenrepsrv/obsrvr_noc.cpp
changeset 51 7d4490026038
parent 40 b8bdbc8f59c7
child 55 44f437012c90
equal deleted inserted replaced
40:b8bdbc8f59c7 51:7d4490026038
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
   718 		// retry
   718 		// retry
   719 		aRepository = CSharedRepository::NewL(aUid);
   719 		aRepository = CSharedRepository::NewL(aUid);
   720 		err = KErrNone;
   720 		err = KErrNone;
   721 		}
   721 		}
   722 	User::LeaveIfError(err);
   722 	User::LeaveIfError(err);
   723 	CleanupStack::PushL(aRepository);
       
   724 		
   723 		
   725 	// Now that we have enough memory for the object and constructed it properly
   724 	// 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
   725 	// 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
   726 	// 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
   727 	// contain a valid value and the other will be 0, and for our purposes we treat
   740 			if (TServerResources::iCacheManager->Enabled()) // cache enabled
   739 			if (TServerResources::iCacheManager->Enabled()) // cache enabled
   741 				{
   740 				{
   742 #ifdef CACHE_OOM_TESTABILITY
   741 #ifdef CACHE_OOM_TESTABILITY
   743 				if (!iTrapOOMOnOpen)	
   742 				if (!iTrapOOMOnOpen)	
   744 					{
   743 					{
       
   744 					delete aRepository;
       
   745 					aRepository = NULL;
   745 					User::Leave(KErrNoMemory);
   746 					User::Leave(KErrNoMemory);
   746 					}
   747 					}
   747 #endif	
   748 #endif	
   748 				// Flush cache
   749 				// Flush cache
   749 				TServerResources::iCacheManager->FlushCache(ETrue);
   750 				TServerResources::iCacheManager->FlushCache(ETrue);
   767 			}
   768 			}
   768 			break;
   769 			break;
   769 		}
   770 		}
   770 	}
   771 	}
   771 	// If unhandled, leave
   772 	// If unhandled, leave
       
   773 	if(unifiedErrorCode != KErrNone)
       
   774 		{
       
   775 		delete aRepository;
       
   776 		aRepository = NULL;
       
   777 		}
   772 	User::LeaveIfError(unifiedErrorCode);
   778 	User::LeaveIfError(unifiedErrorCode);
       
   779 	CleanupStack::PushL(aRepository);
   773 
   780 
   774 	// Otherwise, finalize calulations
   781 	// Otherwise, finalize calulations
   775 	TInt lastSize = myHeap.Size();
   782 	TInt lastSize = myHeap.Size();
   776 	TInt lastAvail = myHeap.Available(biggestBlock);
   783 	TInt lastAvail = myHeap.Available(biggestBlock);
   777 
   784