1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2007-2009 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 the License "Eclipse Public License v1.0" |
4 // under the terms of the License "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". |
16 // |
16 // |
17 // |
17 // |
18 |
18 |
19 #include "BasicWatcher.h" |
19 #include "BasicWatcher.h" |
20 #include "testdebug.h" |
20 #include "testdebug.h" |
21 #include "OstTraceDefinitions.h" |
|
22 #ifdef OST_TRACE_COMPILER_IN_USE |
|
23 #include "BasicWatcherTraces.h" |
|
24 #endif |
|
25 |
21 |
26 namespace NUnitTesting_USBDI |
22 namespace NUnitTesting_USBDI |
27 { |
23 { |
28 |
24 |
29 CBasicWatcher::CBasicWatcher(const TCallBack& aCallBack,TInt aPriority) |
25 CBasicWatcher::CBasicWatcher(const TCallBack& aCallBack,TInt aPriority) |
30 : CActive(aPriority), |
26 : CActive(aPriority), |
31 iCallBack(aCallBack), |
27 iCallBack(aCallBack), |
32 iCompletionCode(KErrNone) |
28 iCompletionCode(KErrNone) |
33 { |
29 { |
34 OstTraceFunctionEntryExt( CBASICWATCHER_CBASICWATCHER_ENTRY, this ); |
|
35 CActiveScheduler::Add(this); |
30 CActiveScheduler::Add(this); |
36 OstTraceFunctionExit1( CBASICWATCHER_CBASICWATCHER_EXIT, this ); |
|
37 } |
31 } |
38 |
32 |
39 CBasicWatcher::~CBasicWatcher() |
33 CBasicWatcher::~CBasicWatcher() |
40 { |
34 { |
41 OstTraceFunctionEntry1( CBASICWATCHER_CBASICWATCHER_ENTRY_DUP01, this ); |
35 LOG_FUNC |
42 |
36 |
43 Cancel(); |
37 Cancel(); |
44 OstTraceFunctionExit1( CBASICWATCHER_CBASICWATCHER_EXIT_DUP01, this ); |
|
45 } |
38 } |
46 |
39 |
47 void CBasicWatcher::DoCancel() |
40 void CBasicWatcher::DoCancel() |
48 { |
41 { |
49 OstTraceFunctionEntry1( CBASICWATCHER_DOCANCEL_ENTRY, this ); |
42 LOG_FUNC |
50 |
43 |
51 OstTrace0(TRACE_NORMAL, CBASICWATCHER_DOCANCEL, "Watch cancelled"); |
44 RDebug::Printf("Watch cancelled"); |
52 iStatus = KErrCancel; |
45 iStatus = KErrCancel; |
53 OstTraceFunctionExit1( CBASICWATCHER_DOCANCEL_EXIT, this ); |
|
54 } |
46 } |
55 |
47 |
56 |
48 |
57 void CBasicWatcher::StartWatching() |
49 void CBasicWatcher::StartWatching() |
58 { |
50 { |
59 OstTraceFunctionEntry1( CBASICWATCHER_STARTWATCHING_ENTRY, this ); |
51 LOG_FUNC |
60 |
52 |
61 if(iStatus != KRequestPending) |
53 if(iStatus != KRequestPending) |
62 { |
54 { |
63 User::Panic(_L("iStatus has not been set to pending this will lead to E32USER-CBase Panic"),46); |
55 User::Panic(_L("iStatus has not been set to pending this will lead to E32USER-CBase Panic"),46); |
64 } |
56 } |
65 SetActive(); |
57 SetActive(); |
66 OstTraceFunctionExit1( CBASICWATCHER_STARTWATCHING_EXIT, this ); |
|
67 } |
58 } |
68 |
59 |
69 |
60 |
70 void CBasicWatcher::RunL() |
61 void CBasicWatcher::RunL() |
71 { |
62 { |
72 OstTraceFunctionEntry1( CBASICWATCHER_RUNL_ENTRY, this ); |
63 LOG_FUNC |
73 |
64 |
74 iCompletionCode = iStatus.Int(); |
65 iCompletionCode = iStatus.Int(); |
75 User::LeaveIfError(iCallBack.CallBack()); |
66 User::LeaveIfError(iCallBack.CallBack()); |
76 OstTraceFunctionExit1( CBASICWATCHER_RUNL_EXIT, this ); |
|
77 } |
67 } |
78 |
68 |
79 |
69 |
80 TInt CBasicWatcher::RunError(TInt aError) |
70 TInt CBasicWatcher::RunError(TInt aError) |
81 { |
71 { |
82 OstTraceFunctionEntryExt( CBASICWATCHER_RUNERROR_ENTRY, this ); |
72 LOG_FUNC |
83 |
73 |
84 OstTrace1(TRACE_NORMAL, CBASICWATCHER_RUNERROR, "Watcher code Left with %d",aError); |
74 RDebug::Printf("Watcher code Left with %d",aError); |
85 OstTraceFunctionExitExt( CBASICWATCHER_RUNERROR_EXIT, this, KErrNone ); |
|
86 return KErrNone; |
75 return KErrNone; |
87 } |
76 } |
88 |
77 |
89 } |
78 } |
90 |
79 |