253
|
1 |
// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
|
0
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// @file basicwatcher.cpp
|
|
15 |
// @internalComponent
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
#include "BasicWatcher.h"
|
|
20 |
#include "testdebug.h"
|
253
|
21 |
#include "OstTraceDefinitions.h"
|
|
22 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
23 |
#include "BasicWatcherTraces.h"
|
|
24 |
#endif
|
0
|
25 |
|
|
26 |
namespace NUnitTesting_USBDI
|
|
27 |
{
|
|
28 |
|
|
29 |
CBasicWatcher::CBasicWatcher(const TCallBack& aCallBack,TInt aPriority)
|
|
30 |
: CActive(aPriority),
|
|
31 |
iCallBack(aCallBack),
|
|
32 |
iCompletionCode(KErrNone)
|
|
33 |
{
|
253
|
34 |
OstTraceFunctionEntryExt( CBASICWATCHER_CBASICWATCHER_ENTRY, this );
|
0
|
35 |
CActiveScheduler::Add(this);
|
253
|
36 |
OstTraceFunctionExit1( CBASICWATCHER_CBASICWATCHER_EXIT, this );
|
0
|
37 |
}
|
|
38 |
|
|
39 |
CBasicWatcher::~CBasicWatcher()
|
|
40 |
{
|
253
|
41 |
OstTraceFunctionEntry1( CBASICWATCHER_CBASICWATCHER_ENTRY_DUP01, this );
|
0
|
42 |
|
|
43 |
Cancel();
|
253
|
44 |
OstTraceFunctionExit1( CBASICWATCHER_CBASICWATCHER_EXIT_DUP01, this );
|
0
|
45 |
}
|
|
46 |
|
|
47 |
void CBasicWatcher::DoCancel()
|
|
48 |
{
|
253
|
49 |
OstTraceFunctionEntry1( CBASICWATCHER_DOCANCEL_ENTRY, this );
|
0
|
50 |
|
253
|
51 |
OstTrace0(TRACE_NORMAL, CBASICWATCHER_DOCANCEL, "Watch cancelled");
|
0
|
52 |
iStatus = KErrCancel;
|
253
|
53 |
OstTraceFunctionExit1( CBASICWATCHER_DOCANCEL_EXIT, this );
|
0
|
54 |
}
|
|
55 |
|
|
56 |
|
|
57 |
void CBasicWatcher::StartWatching()
|
|
58 |
{
|
253
|
59 |
OstTraceFunctionEntry1( CBASICWATCHER_STARTWATCHING_ENTRY, this );
|
0
|
60 |
|
|
61 |
if(iStatus != KRequestPending)
|
|
62 |
{
|
|
63 |
User::Panic(_L("iStatus has not been set to pending this will lead to E32USER-CBase Panic"),46);
|
|
64 |
}
|
|
65 |
SetActive();
|
253
|
66 |
OstTraceFunctionExit1( CBASICWATCHER_STARTWATCHING_EXIT, this );
|
0
|
67 |
}
|
|
68 |
|
|
69 |
|
|
70 |
void CBasicWatcher::RunL()
|
|
71 |
{
|
253
|
72 |
OstTraceFunctionEntry1( CBASICWATCHER_RUNL_ENTRY, this );
|
0
|
73 |
|
|
74 |
iCompletionCode = iStatus.Int();
|
|
75 |
User::LeaveIfError(iCallBack.CallBack());
|
253
|
76 |
OstTraceFunctionExit1( CBASICWATCHER_RUNL_EXIT, this );
|
0
|
77 |
}
|
|
78 |
|
|
79 |
|
|
80 |
TInt CBasicWatcher::RunError(TInt aError)
|
|
81 |
{
|
253
|
82 |
OstTraceFunctionEntryExt( CBASICWATCHER_RUNERROR_ENTRY, this );
|
0
|
83 |
|
253
|
84 |
OstTrace1(TRACE_NORMAL, CBASICWATCHER_RUNERROR, "Watcher code Left with %d",aError);
|
|
85 |
OstTraceFunctionExitExt( CBASICWATCHER_RUNERROR_EXIT, this, KErrNone );
|
0
|
86 |
return KErrNone;
|
|
87 |
}
|
|
88 |
|
|
89 |
}
|
|
90 |
|