62 }; |
61 }; |
63 |
62 |
64 /** |
63 /** |
65 * Two-phased constructor. |
64 * Two-phased constructor. |
66 * @since 3.1 |
65 * @since 3.1 |
67 * @param |
66 * @param |
68 * @param |
67 * @param |
69 * @return CHttpCacheEntry object. |
68 * @return CHttpCacheEntry object. |
70 */ |
69 */ |
71 static CHttpCacheEntry* NewL( const TDesC8& aUrl, |
70 static CHttpCacheEntry* NewL( const TDesC8& aUrl, |
72 CHttpCacheEvictionHandler& aEvictionHandler ); |
71 CHttpCacheEvictionHandler& aEvictionHandler ); |
73 |
72 |
74 /** |
73 /** |
75 * Two-phased constructor. |
74 * Two-phased constructor. |
76 * @since 3.1 |
75 * @since 3.1 |
77 * @param |
76 * @param |
78 * @param |
77 * @param |
79 * @return CHttpCacheEntry object. |
78 * @return CHttpCacheEntry object. |
80 */ |
79 */ |
81 static CHttpCacheEntry* NewLC( const TDesC8& aUrl, |
80 static CHttpCacheEntry* NewLC( const TDesC8& aUrl, |
82 CHttpCacheEvictionHandler& aEvictionHandler ); |
81 CHttpCacheEvictionHandler& aEvictionHandler ); |
83 |
82 |
84 /** |
83 /** |
85 * Destructor. |
84 * Destructor. |
86 */ |
85 */ |
87 virtual ~CHttpCacheEntry(); |
86 virtual ~CHttpCacheEntry(); |
88 |
87 |
89 public: // new functions |
88 public: // new functions |
90 |
89 |
91 /** |
90 /** |
92 * |
91 * |
93 * @since 3.1 |
92 * @since 3.1 |
94 * @param |
93 * @param |
95 * @return |
94 * @return |
96 */ |
95 */ |
97 void SetState( TCacheEntryState aState ); |
96 void SetState( TCacheEntryState aState ); |
98 |
97 |
99 /** |
98 /** |
100 * |
99 * |
101 * @since 3.1 |
100 * @since 3.1 |
102 * @param |
101 * @param |
103 * @return |
102 * @return |
104 */ |
103 */ |
105 inline TCacheEntryState State() { return iState; } |
104 inline TCacheEntryState State() { return iState; } |
106 |
105 |
107 /** |
106 /** |
108 * |
107 * |
109 * @since 3.1 |
108 * @since 3.1 |
110 * @param |
109 * @param |
111 * @return |
110 * @return |
112 */ |
111 */ |
113 void SetFileNameL( const TFileName& aFileName ); |
112 void SetFileNameL( const TFileName& aFileName ); |
114 |
113 |
115 /** |
114 /** |
116 * |
115 * |
117 * @since 3.1 |
116 * @since 3.1 |
118 * @param |
117 * @param |
119 * @return |
118 * @return |
120 */ |
119 */ |
121 const TDesC& Filename() const { return *iFileName; } |
120 const TDesC& Filename() const { return *iFileName; } |
122 |
121 |
123 /** |
122 /** |
124 * |
123 * |
125 * @since 3.1 |
124 * @since 3.1 |
126 * @param |
125 * @param |
127 * @return |
126 * @return |
128 */ |
127 */ |
129 inline const TDesC8& Url() const { return *iUrl; } |
128 inline const TDesC8& Url() const { return *iUrl; } |
130 |
129 |
131 /** |
130 /** |
132 * |
131 * |
133 * @since 3.1 |
132 * @since 3.1 |
134 * @param |
133 * @param |
135 * @return |
134 * @return |
136 */ |
135 */ |
137 inline TInt64 LastAccessed() const { return iLastAccessed; } |
136 inline TInt64 LastAccessed() const { return iLastAccessed; } |
138 |
137 |
139 /** |
138 /** |
140 * |
139 * |
141 * @since 3.1 |
140 * @since 3.1 |
142 * @param |
141 * @param |
143 * @return |
142 * @return |
144 */ |
143 */ |
145 void Accessed(); |
144 void Accessed(); |
146 |
145 |
147 /** |
146 /** |
148 * |
147 * |
149 * @since 3.1 |
148 * @since 3.1 |
150 * @param |
149 * @param |
151 * @return |
150 * @return |
152 */ |
151 */ |
153 inline TUint16 Ref() const { return iRef; } |
152 inline TUint16 Ref() const { return iRef; } |
154 |
153 |
155 /** |
154 /** |
156 * |
155 * |
157 * @since 3.1 |
156 * @since 3.1 |
158 * @param |
157 * @param |
159 * @return |
158 * @return |
160 */ |
159 */ |
161 inline TUint BodySize() const { return iBodySize; } |
160 inline TUint BodySize() const { return iBodySize; } |
162 |
161 |
163 /** |
162 /** |
164 * |
163 * |
165 * @since 3.1 |
164 * @since 3.1 |
166 * @param |
165 * @param |
167 * @return |
166 * @return |
168 */ |
167 */ |
169 void SetBodySize( TUint aSize ); |
168 void SetBodySize( TUint aSize ); |
170 |
169 |
171 /** |
170 /** |
172 * |
171 * |
173 * @since 3.1 |
172 * @since 3.1 |
174 * @param |
173 * @param |
175 * @return |
174 * @return |
176 */ |
175 */ |
177 inline TUint16 HeaderSize() const { return iHeaderSize; } |
176 inline TUint16 HeaderSize() const { return iHeaderSize; } |
178 |
177 |
179 /** |
178 /** |
180 * |
179 * |
181 * @since 3.1 |
180 * @since 3.1 |
182 * @param |
181 * @param |
183 * @return |
182 * @return |
184 */ |
183 */ |
185 inline void SetHeaderSize( TUint16 aHeaderSize ) { iHeaderSize = aHeaderSize; } |
184 inline void SetHeaderSize( TUint16 aHeaderSize ) { iHeaderSize = aHeaderSize; } |
186 |
185 |
187 /** |
186 /** |
188 * |
187 * |
189 * @since 7.1 |
188 * @since 7.1 |
190 * @param |
189 * @param |
191 * @return |
190 * @return |
192 */ |
191 */ |
193 inline RFile& HeaderFile() { return iHeaderFile; } |
192 void CreateHeaderBufferL( TInt aHeaderBufferSize ); |
194 |
193 |
195 /** |
194 /** |
196 * |
195 * |
197 * @since 7.1 |
196 * @since 7.1 |
198 * @param |
197 * @param |
199 * @return |
198 * @return |
200 */ |
199 */ |
201 inline RFile& BodyFile() { return iBodyFile; } |
200 void CreateHeaderBufferL( const TDesC8& aHeaderData ); |
202 |
201 |
203 /** |
202 /** |
204 * |
203 * |
205 * @since 7.1 |
204 * @since 7.1 |
206 * @param |
205 * @param |
207 * @return |
206 * @return |
208 */ |
207 */ |
209 TPtr8 CacheBuffer(); |
208 TDesC8& HeaderData(); |
210 |
209 |
211 /** |
210 /** |
212 * |
211 * |
213 * @since 7.1 |
212 * @since 3.1 |
214 * @param |
213 * @param |
215 * @return |
214 * @return |
216 */ |
|
217 void SetCacheBufferL( TInt aCacheBufferSize ); |
|
218 |
|
219 /** |
|
220 * |
|
221 * @since 3.1 |
|
222 * @param |
|
223 * @return |
|
224 */ |
215 */ |
225 inline TBool Protected() const { return iProtected; } |
216 inline TBool Protected() const { return iProtected; } |
226 |
217 |
227 /** |
218 /** |
228 * |
219 * |
229 * @since 3.1 |
220 * @since 3.1 |
230 * @param |
221 * @param |
231 * @return |
222 * @return |
232 */ |
223 */ |
233 void SetProtected(); |
224 void SetProtected(); |
234 |
225 |
235 /** |
226 /** |
236 * |
227 * |
237 * @since 3.1 |
228 * @since 3.1 |
238 * @param |
229 * @param |
239 * @return |
230 * @return |
240 */ |
231 */ |
241 TInt Internalize( RFileReadStream& aReadStream ); |
232 TInt Internalize( RReadStream& aReadStream, const TDesC& aDirectory ); |
242 |
233 |
243 /** |
234 /** |
244 * |
235 * |
245 * @since 3.1 |
236 * @since 7.1 |
246 * @param |
237 * @param |
247 * @return |
238 * @return |
248 */ |
239 */ |
249 TInt Externalize( RFileWriteStream& aWriteStream ); |
240 void InternalizeL( RReadStream& aReadStream, const TDesC& aDirectory ); |
250 |
241 |
251 /** |
242 /** |
252 * |
243 * |
253 * @since 3.1 |
244 * @since 3.1 |
254 * @param |
245 * @param |
255 * @return |
246 * @return |
|
247 */ |
|
248 TInt Externalize( RWriteStream& aWriteStream, const TDesC& aDirectory ); |
|
249 |
|
250 /** |
|
251 * |
|
252 * @since 3.1 |
|
253 * @param |
|
254 * @return |
|
255 */ |
|
256 void ExternalizeL( RWriteStream& aWriteStream, const TDesC& aDirectory ); |
|
257 |
|
258 /** |
|
259 * |
|
260 * @since 3.1 |
|
261 * @param |
|
262 * @return |
256 */ |
263 */ |
257 void Accessed(TInt64 aLastAccessed, TUint16 aRef); |
264 void Accessed(TInt64 aLastAccessed, TUint16 aRef); |
258 |
265 |
259 /** |
266 /** |
260 * |
267 * |
261 * @since 7.1 |
268 * @since 7.1 |
262 * @param |
269 * @param |
263 * @return |
270 * @return |
264 */ |
271 */ |
265 inline TBool BodyFileDeleteNeeded() { return iBodyFileDeleteNeeded; } |
272 inline TBool BodyFileDeleteNeeded() { return iBodyFileDeleteNeeded; } |
266 |
273 |
267 /** |
274 /** |
268 * |
275 * |
269 * @since 7.1 |
276 * @since 7.1 |
270 * @param |
277 * @param |
271 * @return |
278 * @return |
272 */ |
279 */ |
273 inline void SetBodyFileDeleteNeeded( TBool aBodyFileDeleteNeeded ) |
280 inline void SetBodyFileDeleteNeeded( TBool aBodyFileDeleteNeeded ) |
274 { |
281 { |
275 iBodyFileDeleteNeeded = aBodyFileDeleteNeeded; |
282 iBodyFileDeleteNeeded = aBodyFileDeleteNeeded; |
276 } |
283 } |
277 |
284 /** |
278 /** |
285 * |
279 * |
286 * @since 7.1 |
280 * @since 7.1 |
287 * @param |
281 * @param |
288 * @return |
282 * @return |
289 * |
283 */ |
290 */ |
284 TBool CacheFilesOpened() { return iCacheFilesOpened; } |
291 void UnsetEvictionCandidate() { iEvictionCandidate = EFalse; }; // this only exists because when EvictL removes an item from the eviction candidate list, it can't tell the entry that this has happened and so the entry then goes on to attempt to remove itself later when it's being deleted. |
285 |
292 |
286 /** |
293 public : |
287 * |
|
288 * @since 7.1 |
|
289 * @param |
|
290 * @return |
|
291 */ |
|
292 void SetCacheFilesOpened( TBool aCacheFilesOpened ); |
|
293 |
|
294 public : |
|
295 |
294 |
296 // support linked list |
295 // support linked list |
297 static const TInt iOffset; |
296 static const TInt iOffset; |
298 |
297 |
299 private: |
298 private: |
300 |
299 |
301 /** |
300 /** |
302 * Construct. |
301 * Construct. |
303 * @since 3.1 |
302 * @since 3.1 |
304 * @param |
303 * @param |
305 * @param |
304 * @param |
306 * @return CHttpCacheEntry object. |
305 * @return CHttpCacheEntry object. |
307 */ |
306 */ |
308 CHttpCacheEntry( CHttpCacheEvictionHandler& aEvictionHandler ); |
307 CHttpCacheEntry( CHttpCacheEvictionHandler& aEvictionHandler ); |
309 |
308 |
310 /** |
309 /** |
311 * By default Symbian 2nd phase constructor is private. |
310 * By default Symbian 2nd phase constructor is private. |
312 */ |
311 */ |
313 void ConstructL( const TDesC8& aUrl ); |
312 void ConstructL( const TDesC8& aUrl ); |
|
313 |
|
314 /** |
|
315 * |
|
316 * @since 7.1 |
|
317 * @param |
|
318 * @return |
|
319 */ |
|
320 void SetCacheBufferL( TInt aCacheBufferSize ); |
|
321 |
|
322 public: |
|
323 // from MHttpCacheStreamWriteSource |
|
324 virtual RFile& BodyFile(); |
|
325 virtual void BodyWriteInProgress(); |
|
326 virtual void BodyWriteComplete(); |
|
327 virtual CSegmentedHeapBuffer& BodyData(); |
|
328 |
|
329 enum TWriteStateBits |
|
330 { |
|
331 EFileOk = 0x01, |
|
332 EHeaderDataCached = 0x02, |
|
333 ENewHeaderData = 0x04, |
|
334 EBodyDataCached = 0x08, |
|
335 EDelayedWriteAllowed = 0x10, |
|
336 EDelayedWriteInProgress = 0x20, |
|
337 EBodyDataPartiallyWritten = 0x40 |
|
338 }; |
|
339 |
|
340 inline TBool FileOk() const { return (iWriteState & EFileOk); } |
|
341 inline TBool BodyDataCached() const { return (iWriteState & EBodyDataCached); } |
|
342 inline TBool DelayedWriteAllowed() const { return (iWriteState & EDelayedWriteAllowed); } |
|
343 inline TBool DelayedWriteInProgress() const { return (iWriteState & EDelayedWriteInProgress); } |
|
344 inline TBool BodyDataPartiallyWritten() const { return (iWriteState & EBodyDataPartiallyWritten); } |
|
345 |
|
346 inline void SetFileOk(TBool aBit) { (aBit ? iWriteState |= EFileOk : iWriteState &= ~EFileOk); } |
|
347 void SetBodyDataCached(TBool aBit) { (aBit ? iWriteState |= EBodyDataCached : iWriteState &= ~EBodyDataCached); if(!aBit){ iCacheBuffer->Reset(); } } |
|
348 void SetDelayedWriteAllowed(TBool aBit) { (aBit ? iWriteState |= EDelayedWriteAllowed : iWriteState &= ~EDelayedWriteAllowed); } |
|
349 void SetDelayedWriteInProgress(TBool aBit) { (aBit ? iWriteState |= EDelayedWriteInProgress : iWriteState &= ~EDelayedWriteInProgress); } |
|
350 void SetBodyDataPartiallyWritten(TBool aBit){ (aBit ? iWriteState |= EBodyDataPartiallyWritten : iWriteState &= ~EBodyDataPartiallyWritten); } |
|
351 |
|
352 void WriteBodyDataAsync(TRequestStatus& aStatus); |
|
353 void CancelBodyWrite(); |
314 |
354 |
315 private: // Data |
355 private: // Data |
316 |
356 |
317 // |
357 // |
318 HBufC8* iUrl; // owned |
358 HBufC8* iUrl; // owned |