imagehandlingutilities/thumbnailmanager/thumbnailclient/src/thumbnailrequestqueue.cpp
equal
deleted
inserted
replaced
17 |
17 |
18 |
18 |
19 #include "thumbnailrequestqueue.h" |
19 #include "thumbnailrequestqueue.h" |
20 #include "thumbnailrequestactive.h" |
20 #include "thumbnailrequestactive.h" |
21 #include "thumbnaillog.h" |
21 #include "thumbnaillog.h" |
|
22 #include "OstTraceDefinitions.h" |
|
23 #ifdef OST_TRACE_COMPILER_IN_USE |
|
24 #include "thumbnailrequestqueueTraces.h" |
|
25 #endif |
|
26 |
22 |
27 |
23 |
28 |
24 // ======== MEMBER FUNCTIONS ======== |
29 // ======== MEMBER FUNCTIONS ======== |
25 |
30 |
26 // --------------------------------------------------------------------------- |
31 // --------------------------------------------------------------------------- |
65 // --------------------------------------------------------------------------- |
70 // --------------------------------------------------------------------------- |
66 // |
71 // |
67 CThumbnailRequestQueue::~CThumbnailRequestQueue() |
72 CThumbnailRequestQueue::~CThumbnailRequestQueue() |
68 { |
73 { |
69 TN_DEBUG1( "CThumbnailRequestQueue::~CThumbnailRequestQueue()"); |
74 TN_DEBUG1( "CThumbnailRequestQueue::~CThumbnailRequestQueue()"); |
|
75 OstTrace0( TRACE_NORMAL, CTHUMBNAILREQUESTQUEUE_CTHUMBNAILREQUESTQUEUE, "CThumbnailRequestQueue::~CThumbnailRequestQueue" ); |
70 |
76 |
71 iRequests.ResetAndDestroy(); |
77 iRequests.ResetAndDestroy(); |
72 |
78 |
73 TN_DEBUG1( "CThumbnailRequestQueue::~CThumbnailRequestQueue() - All requests deleted"); |
79 TN_DEBUG1( "CThumbnailRequestQueue::~CThumbnailRequestQueue() - All requests deleted"); |
|
80 OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILREQUESTQUEUE_CTHUMBNAILREQUESTQUEUE, "CThumbnailRequestQueue::~CThumbnailRequestQueue - All requests deleted" ); |
74 } |
81 } |
75 |
82 |
76 |
83 |
77 // --------------------------------------------------------------------------- |
84 // --------------------------------------------------------------------------- |
78 // CThumbnailRequestQueue::Process() |
85 // CThumbnailRequestQueue::Process() |
80 // --------------------------------------------------------------------------- |
87 // --------------------------------------------------------------------------- |
81 // |
88 // |
82 void CThumbnailRequestQueue::Process() |
89 void CThumbnailRequestQueue::Process() |
83 { |
90 { |
84 TN_DEBUG1( "CThumbnailRequestQueue::Process()"); |
91 TN_DEBUG1( "CThumbnailRequestQueue::Process()"); |
|
92 OstTrace0( TRACE_NORMAL, CTHUMBNAILREQUESTQUEUE_PROCESS, "CThumbnailRequestQueue::Process" ); |
85 |
93 |
86 while ( (iActiveRequests < KMaxClientRequests) && |
94 while ( (iActiveRequests < KMaxClientRequests) && |
87 (iRequests.Count() > iActiveRequests) ) |
95 (iRequests.Count() > iActiveRequests) ) |
88 { |
96 { |
89 CThumbnailRequestActive* selectedRequest = NULL; |
97 CThumbnailRequestActive* selectedRequest = NULL; |
99 if( request && !request->RequestCompleted() && !request->IsRequestActive() ) |
107 if( request && !request->RequestCompleted() && !request->IsRequestActive() ) |
100 { |
108 { |
101 TN_DEBUG4( "CThumbnailRequestQueue::Process() - candidate at %d, id = %d, (0x%08x)", i, |
109 TN_DEBUG4( "CThumbnailRequestQueue::Process() - candidate at %d, id = %d, (0x%08x)", i, |
102 request->RequestId(), |
110 request->RequestId(), |
103 request); |
111 request); |
|
112 OstTrace1( TRACE_NORMAL, DUP4_CTHUMBNAILREQUESTQUEUE_PROCESS, "CThumbnailRequestQueue::Process;request->RequestId()=%u", request->RequestId() ); |
|
113 OstTrace1( TRACE_NORMAL, DUP5_CTHUMBNAILREQUESTQUEUE_PROCESS, "CThumbnailRequestQueue::Process;request=%o", request ); |
|
114 |
104 reqPriority = request->Priority(); |
115 reqPriority = request->Priority(); |
105 if ( reqPriority > priority ) |
116 if ( reqPriority > priority ) |
106 { |
117 { |
107 priority = reqPriority; |
118 priority = reqPriority; |
108 selectedRequest = request; |
119 selectedRequest = request; |
112 |
123 |
113 // activate selected |
124 // activate selected |
114 if ( selectedRequest ) |
125 if ( selectedRequest ) |
115 { |
126 { |
116 TN_DEBUG1( "CThumbnailRequestQueue::Process() - starting next request"); |
127 TN_DEBUG1( "CThumbnailRequestQueue::Process() - starting next request"); |
|
128 OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILREQUESTQUEUE_PROCESS, "CThumbnailRequestQueue::Process - starting next request" ); |
117 |
129 |
118 iActiveRequests++; |
130 iActiveRequests++; |
119 |
131 |
120 TRAPD(err, selectedRequest->StartL()); |
132 TRAPD(err, selectedRequest->StartL()); |
121 if (err != KErrNone) |
133 if (err != KErrNone) |
122 { |
134 { |
123 TN_DEBUG1( "CThumbnailRequestQueue::Process() - starting request failed"); |
135 TN_DEBUG1( "CThumbnailRequestQueue::Process() - starting request failed"); |
|
136 OstTrace0( TRACE_NORMAL, DUP2_CTHUMBNAILREQUESTQUEUE_PROCESS, "CThumbnailRequestQueue::Process - starting request failed" ); |
124 |
137 |
125 selectedRequest->StartError(err); |
138 selectedRequest->StartError(err); |
126 } |
139 } |
127 } |
140 } |
128 else |
141 else |
131 } |
144 } |
132 } |
145 } |
133 |
146 |
134 TN_DEBUG3( "CThumbnailRequestQueue::Process() end - requests: %d, active requests: %d", |
147 TN_DEBUG3( "CThumbnailRequestQueue::Process() end - requests: %d, active requests: %d", |
135 iRequests.Count(), iActiveRequests ); |
148 iRequests.Count(), iActiveRequests ); |
|
149 OstTraceExt2( TRACE_NORMAL, DUP3_CTHUMBNAILREQUESTQUEUE_PROCESS, "CThumbnailRequestQueue::Process;iRequests.Count()=%d;iActiveRequests=%d", iRequests.Count(), iActiveRequests ); |
136 } |
150 } |
137 |
151 |
138 |
152 |
139 // --------------------------------------------------------------------------- |
153 // --------------------------------------------------------------------------- |
140 // CThumbnailRequestQueue::AddRequestL() |
154 // CThumbnailRequestQueue::AddRequestL() |
146 RemoveCompleted(NULL); |
160 RemoveCompleted(NULL); |
147 iRequests.AppendL( aRequest ); |
161 iRequests.AppendL( aRequest ); |
148 |
162 |
149 TN_DEBUG3( "CThumbnailRequestQueue::AddRequestL() end - requests: %d, active requests: %d", |
163 TN_DEBUG3( "CThumbnailRequestQueue::AddRequestL() end - requests: %d, active requests: %d", |
150 iRequests.Count(), iActiveRequests ); |
164 iRequests.Count(), iActiveRequests ); |
|
165 OstTraceExt2( TRACE_NORMAL, CTHUMBNAILREQUESTQUEUE_ADDREQUESTL, "CThumbnailRequestQueue::AddRequestL;iRequests.Count()=%d;iActiveRequests=%d", iRequests.Count(), iActiveRequests ); |
151 } |
166 } |
152 |
167 |
153 void CThumbnailRequestQueue::RemoveCompleted( CThumbnailRequestActive* aRequestAO) |
168 void CThumbnailRequestQueue::RemoveCompleted( CThumbnailRequestActive* aRequestAO) |
154 { |
169 { |
155 //process completed queue and remove finished tasks |
170 //process completed queue and remove finished tasks |
160 // remove completed task if it's not active anymore and not this |
175 // remove completed task if it's not active anymore and not this |
161 if ( request->RequestCompleted() && !request->IsRequestActive() && aRequestAO != request) |
176 if ( request->RequestCompleted() && !request->IsRequestActive() && aRequestAO != request) |
162 { |
177 { |
163 // delete completed task |
178 // delete completed task |
164 TN_DEBUG3( "CThumbnailRequestQueue::RemoveCompleted() - deleted id = %d (0x%08x)", request->RequestId(), request); |
179 TN_DEBUG3( "CThumbnailRequestQueue::RemoveCompleted() - deleted id = %d (0x%08x)", request->RequestId(), request); |
|
180 OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILREQUESTQUEUE_REMOVECOMPLETED, "CThumbnailRequestQueue::RemoveCompleted;request=%o", request ); |
|
181 OstTrace1( TRACE_NORMAL, DUP2_CTHUMBNAILREQUESTQUEUE_REMOVECOMPLETED, "CThumbnailRequestQueue::RemoveCompleted;request->RequestId()=%u", request->RequestId() ); |
|
182 |
165 delete request; |
183 delete request; |
166 request = NULL; |
184 request = NULL; |
167 iRequests.Remove( i ); |
185 iRequests.Remove( i ); |
168 } |
186 } |
169 } |
187 } |
173 iRequests.Compress(); |
191 iRequests.Compress(); |
174 } |
192 } |
175 |
193 |
176 TN_DEBUG3( "CThumbnailRequestQueue::RemoveCompleted() end - requests: %d, active requests: %d", |
194 TN_DEBUG3( "CThumbnailRequestQueue::RemoveCompleted() end - requests: %d, active requests: %d", |
177 iRequests.Count(), iActiveRequests ); |
195 iRequests.Count(), iActiveRequests ); |
|
196 OstTraceExt2( TRACE_NORMAL, DUP3_CTHUMBNAILREQUESTQUEUE_REMOVECOMPLETED, "CThumbnailRequestQueue::RemoveCompleted;iRequests.Count()=%d;iActiveRequests=%d", iRequests.Count(), iActiveRequests ); |
178 } |
197 } |
179 |
198 |
180 |
199 |
181 // --------------------------------------------------------------------------- |
200 // --------------------------------------------------------------------------- |
182 // CThumbnailRequestQueue::CancelRequest() |
201 // CThumbnailRequestQueue::CancelRequest() |
184 // --------------------------------------------------------------------------- |
203 // --------------------------------------------------------------------------- |
185 // |
204 // |
186 TInt CThumbnailRequestQueue::CancelRequest( const TThumbnailRequestId aRequestId ) |
205 TInt CThumbnailRequestQueue::CancelRequest( const TThumbnailRequestId aRequestId ) |
187 { |
206 { |
188 TN_DEBUG2( "CThumbnailRequestQueue::CancelRequest() - request ID: %d", aRequestId); |
207 TN_DEBUG2( "CThumbnailRequestQueue::CancelRequest() - request ID: %d", aRequestId); |
|
208 OstTrace1( TRACE_NORMAL, CTHUMBNAILREQUESTQUEUE_CANCELREQUEST, "CThumbnailRequestQueue::CancelRequest;aRequestId=%u", aRequestId ); |
189 |
209 |
190 TInt res = KErrNotFound; |
210 TInt res = KErrNotFound; |
191 |
211 |
192 for ( TInt i = iRequests.Count(); --i >= 0; ) |
212 for ( TInt i = iRequests.Count(); --i >= 0; ) |
193 { |
213 { |
198 { |
218 { |
199 // this doesn't yet actually cancel/complete the AO |
219 // this doesn't yet actually cancel/complete the AO |
200 iRequests[i]->AsyncCancel(); |
220 iRequests[i]->AsyncCancel(); |
201 |
221 |
202 TN_DEBUG2( "CThumbnailRequestQueue::CancelRequest() - canceled request ID: %d", aRequestId); |
222 TN_DEBUG2( "CThumbnailRequestQueue::CancelRequest() - canceled request ID: %d", aRequestId); |
|
223 OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILREQUESTQUEUE_CANCELREQUEST, "CThumbnailRequestQueue::CancelRequest;aRequestId=%u", aRequestId ); |
203 } |
224 } |
204 else |
225 else |
205 { |
226 { |
206 delete request; |
227 delete request; |
207 request = NULL; |
228 request = NULL; |
208 iRequests.Remove( i ); |
229 iRequests.Remove( i ); |
209 |
230 |
210 TN_DEBUG2( "CThumbnailRequestQueue::CancelRequest() - removed request ID: %d", aRequestId); |
231 TN_DEBUG2( "CThumbnailRequestQueue::CancelRequest() - removed request ID: %d", aRequestId); |
|
232 OstTrace1( TRACE_NORMAL, DUP2_CTHUMBNAILREQUESTQUEUE_CANCELREQUEST, "CThumbnailRequestQueue::CancelRequest;aRequestId=%u", aRequestId ); |
211 } |
233 } |
212 |
234 |
213 res = KErrNone; |
235 res = KErrNone; |
214 break; |
236 break; |
215 } |
237 } |
230 // |
252 // |
231 TInt CThumbnailRequestQueue::ChangePriority( const TThumbnailRequestId aRequestId, |
253 TInt CThumbnailRequestQueue::ChangePriority( const TThumbnailRequestId aRequestId, |
232 const TInt aNewPriority ) |
254 const TInt aNewPriority ) |
233 { |
255 { |
234 TN_DEBUG1( "CThumbnailRequestQueue::ChangePriority()"); |
256 TN_DEBUG1( "CThumbnailRequestQueue::ChangePriority()"); |
|
257 OstTrace0( TRACE_NORMAL, CTHUMBNAILREQUESTQUEUE_CHANGEPRIORITY, "CThumbnailRequestQueue::ChangePriority" ); |
235 |
258 |
236 TInt err = KErrNotFound; |
259 TInt err = KErrNotFound; |
237 const TInt count = iRequests.Count(); |
260 const TInt count = iRequests.Count(); |
238 |
261 |
239 for ( TInt i( 0 ); i < count; i++ ) |
262 for ( TInt i( 0 ); i < count; i++ ) |
257 // --------------------------------------------------------------------------- |
280 // --------------------------------------------------------------------------- |
258 // |
281 // |
259 void CThumbnailRequestQueue::RequestComplete(CThumbnailRequestActive* aRequestAO) |
282 void CThumbnailRequestQueue::RequestComplete(CThumbnailRequestActive* aRequestAO) |
260 { |
283 { |
261 TN_DEBUG2( "CThumbnailRequestQueue::RequestComplete(0x%08x)", aRequestAO); |
284 TN_DEBUG2( "CThumbnailRequestQueue::RequestComplete(0x%08x)", aRequestAO); |
|
285 OstTrace1( TRACE_NORMAL, CTHUMBNAILREQUESTQUEUE_REQUESTCOMPLETE, "CThumbnailRequestQueue::RequestComplete;aRequestAO=%o", aRequestAO ); |
262 |
286 |
263 iActiveRequests--; |
287 iActiveRequests--; |
264 if(iActiveRequests <= -1) |
288 if(iActiveRequests <= -1) |
265 { |
289 { |
266 iActiveRequests = 0; |
290 iActiveRequests = 0; |