sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef SQLCOMPACTENTRY_H sl@0: #define SQLCOMPACTENTRY_H sl@0: sl@0: #include "SqlCompact.h" sl@0: sl@0: //Forward declarations sl@0: class CSqlCompactTestActive; sl@0: class CSqlCompactTimer; sl@0: sl@0: //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: #ifdef _DEBUG sl@0: #define SQLCOMPACTENTRY_INVARIANT() Invariant() sl@0: #else sl@0: #define SQLCOMPACTENTRY_INVARIANT() void(0) sl@0: #endif sl@0: sl@0: /** sl@0: Every CSqlCompactEntry maintains a connection to the database that has to be compacted in background mode. sl@0: When the number of the free pages reaches or is above the threshold, the background compaction will be activated sl@0: and performed in steps. sl@0: sl@0: @see MSqlCompactConn sl@0: @see CSqlCompactTimer sl@0: sl@0: @internalComponent sl@0: */ sl@0: NONSHARABLE_CLASS(CSqlCompactEntry) : public CBase sl@0: { sl@0: friend class CSqlCompactTestActive; sl@0: sl@0: public: sl@0: static CSqlCompactEntry* NewLC(const TDesC& aFullName, TSqlCompactConnFactoryL aConnFactoryL, sl@0: const TSqlCompactSettings& aSettings, CSqlCompactTimer& aTimer); sl@0: TInt AddRef(); sl@0: TInt Release(); sl@0: TInt Compact(); sl@0: const TDesC& FullName() const; sl@0: void Invariant() const; sl@0: sl@0: private: sl@0: CSqlCompactEntry(const TSqlCompactSettings& aSettings, CSqlCompactTimer& aTimer); sl@0: virtual ~CSqlCompactEntry(); sl@0: void ConstructL(const TDesC& aFullName, TSqlCompactConnFactoryL aConnFactoryL); sl@0: void ResetState(); sl@0: MSqlCompactConn& Connection(); sl@0: static void FreePageCallback(void* aThis, TInt aFreePageCount); sl@0: sl@0: public: sl@0: TSglQueLink iLink; sl@0: sl@0: private: sl@0: RBuf iFullName; sl@0: TSqlCompactSettings iSettings; sl@0: CSqlCompactTimer& iTimer; sl@0: MSqlCompactConn* iConnection; sl@0: TInt iRefCounter; sl@0: enum TState sl@0: { sl@0: EInactive, sl@0: EInProgress sl@0: }; sl@0: TState iState; sl@0: TInt iPageCount; sl@0: TBool iFreePageCallbackDisabled; sl@0: sl@0: }; sl@0: sl@0: #endif//SQLCOMPACTENTRY_H