1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/dbms/tdbms/t_dbfail.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,121 @@
1.4 +// Copyright (c) 1998-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 T_DBFAIL_H
1.20 +#define T_DBFAIL_H
1.21 +
1.22 +GLREF_D RTest test;
1.23 +GLREF_D RDbs TheDbs;
1.24 +GLREF_D RDbNamedDatabase TheDatabase;
1.25 +
1.26 +GLREF_C void Connect();
1.27 +GLREF_C void Disconnect();
1.28 +GLREF_C void PrepareDbFmtString();
1.29 +GLREF_C void TestOpen2();
1.30 +GLREF_C void Origins2();
1.31 +
1.32 +class THeapFail
1.33 + {
1.34 +public:
1.35 + virtual void Mark() const =0;
1.36 + virtual void Fail(TInt aCount) const =0;
1.37 + virtual void Reset() const =0;
1.38 + virtual void Check() const =0;
1.39 + };
1.40 +
1.41 +class TContext
1.42 + {
1.43 +public:
1.44 + virtual void OpenDbL() const =0;
1.45 + };
1.46 +
1.47 +class TFail
1.48 + {
1.49 +private:
1.50 + void Test(const THeapFail& aHeap,const TContext* aContext);
1.51 + virtual void RunL()
1.52 + {
1.53 + }
1.54 + virtual void End()
1.55 + {
1.56 + }
1.57 +
1.58 +public:
1.59 + inline void Test(const THeapFail& aHeap,const TContext& aContext)
1.60 + {
1.61 + Test(aHeap,&aContext);
1.62 + }
1.63 + inline void Test(const THeapFail& aHeap)
1.64 + {
1.65 + Test(aHeap,0);
1.66 + }
1.67 + };
1.68 +
1.69 +class TClientHeap : public THeapFail
1.70 + {
1.71 +public:
1.72 + TClientHeap()
1.73 + {
1.74 + }
1.75 +
1.76 +private:
1.77 + void Mark() const
1.78 + {
1.79 + User::__DbgMarkStart(RHeap::EUser);
1.80 + }
1.81 + void Fail(TInt aCount) const
1.82 + {
1.83 + User::__DbgSetAllocFail(RHeap::EUser,RHeap::EFailNext,aCount);
1.84 + }
1.85 + void Reset() const
1.86 + {
1.87 + User::__DbgSetAllocFail(RHeap::EUser,RHeap::ENone,1);
1.88 + }
1.89 + void Check() const
1.90 + {
1.91 + User::__DbgMarkEnd(RHeap::EUser,0);
1.92 + }
1.93 +
1.94 + };
1.95 +
1.96 +class TServerHeap : public THeapFail
1.97 + {
1.98 +public:
1.99 + TServerHeap()
1.100 + {
1.101 + }
1.102 +
1.103 +private:
1.104 + void Mark() const
1.105 + {
1.106 + }
1.107 + void Fail(TInt aCount) const
1.108 + {
1.109 + TheDbs.SetHeapFailure(RHeap::EFailNext,aCount);
1.110 + }
1.111 + void Reset() const
1.112 + {
1.113 + TheDbs.SetHeapFailure(RHeap::ENone,0);
1.114 + }
1.115 + void Check() const
1.116 + {
1.117 + }
1.118 +
1.119 + };
1.120 +
1.121 +GLREF_D TClientHeap KClientHeap;
1.122 +GLREF_D TServerHeap KServerHeap;
1.123 +
1.124 +#endif//T_DBFAIL_H