1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sql/SRC/Server/Compact/SqlCompactEntry.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,85 @@
1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef SQLCOMPACTENTRY_H
1.20 +#define SQLCOMPACTENTRY_H
1.21 +
1.22 +#include "SqlCompact.h"
1.23 +
1.24 +//Forward declarations
1.25 +class CSqlCompactTestActive;
1.26 +class CSqlCompactTimer;
1.27 +
1.28 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1.29 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1.30 +
1.31 +#ifdef _DEBUG
1.32 +#define SQLCOMPACTENTRY_INVARIANT() Invariant()
1.33 +#else
1.34 +#define SQLCOMPACTENTRY_INVARIANT() void(0)
1.35 +#endif
1.36 +
1.37 +/**
1.38 +Every CSqlCompactEntry maintains a connection to the database that has to be compacted in background mode.
1.39 +When the number of the free pages reaches or is above the threshold, the background compaction will be activated
1.40 +and performed in steps.
1.41 +
1.42 +@see MSqlCompactConn
1.43 +@see CSqlCompactTimer
1.44 +
1.45 +@internalComponent
1.46 +*/
1.47 +NONSHARABLE_CLASS(CSqlCompactEntry) : public CBase
1.48 + {
1.49 + friend class CSqlCompactTestActive;
1.50 +
1.51 +public:
1.52 + static CSqlCompactEntry* NewLC(const TDesC& aFullName, TSqlCompactConnFactoryL aConnFactoryL,
1.53 + const TSqlCompactSettings& aSettings, CSqlCompactTimer& aTimer);
1.54 + TInt AddRef();
1.55 + TInt Release();
1.56 + TInt Compact();
1.57 + const TDesC& FullName() const;
1.58 + void Invariant() const;
1.59 +
1.60 +private:
1.61 + CSqlCompactEntry(const TSqlCompactSettings& aSettings, CSqlCompactTimer& aTimer);
1.62 + virtual ~CSqlCompactEntry();
1.63 + void ConstructL(const TDesC& aFullName, TSqlCompactConnFactoryL aConnFactoryL);
1.64 + void ResetState();
1.65 + MSqlCompactConn& Connection();
1.66 + static void FreePageCallback(void* aThis, TInt aFreePageCount);
1.67 +
1.68 +public:
1.69 + TSglQueLink iLink;
1.70 +
1.71 +private:
1.72 + RBuf iFullName;
1.73 + TSqlCompactSettings iSettings;
1.74 + CSqlCompactTimer& iTimer;
1.75 + MSqlCompactConn* iConnection;
1.76 + TInt iRefCounter;
1.77 + enum TState
1.78 + {
1.79 + EInactive,
1.80 + EInProgress
1.81 + };
1.82 + TState iState;
1.83 + TInt iPageCount;
1.84 + TBool iFreePageCallbackDisabled;
1.85 +
1.86 + };
1.87 +
1.88 +#endif//SQLCOMPACTENTRY_H