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