|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Definition of CHttpCacheEntry |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CHTTPCACHEENTRY_H |
|
19 #define CHTTPCACHEENTRY_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <e32base.h> |
|
23 |
|
24 // CONSTANTS |
|
25 |
|
26 // MACROS |
|
27 |
|
28 // DATA TYPES |
|
29 |
|
30 // FUNCTION PROTOTYPES |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class RHTTPTransaction; |
|
34 class MHTTPDataSupplier; |
|
35 class RFileWriteStream; |
|
36 class RFileReadStream; |
|
37 class CHttpCacheEvictionHandler; |
|
38 class CHttpCacheStreamHandler; |
|
39 |
|
40 // CLASS DECLARATION |
|
41 |
|
42 /** |
|
43 * |
|
44 * @lib |
|
45 * @since 3.1 |
|
46 */ |
|
47 class CHttpCacheEntry : public CBase |
|
48 { |
|
49 public: // Constructors and destructor |
|
50 |
|
51 enum TCacheEntryState |
|
52 { |
|
53 ECacheUninitialized, |
|
54 ECacheInitialized, |
|
55 ECacheRequesting, |
|
56 ECacheResponding, |
|
57 ECacheComplete, |
|
58 ECacheDestroyed |
|
59 }; |
|
60 |
|
61 /** |
|
62 * Two-phased constructor. |
|
63 * @since 3.1 |
|
64 * @param |
|
65 * @param |
|
66 * @return CHttpCacheEntry object. |
|
67 */ |
|
68 static CHttpCacheEntry* NewL( const TDesC8& aUrl, |
|
69 CHttpCacheEvictionHandler& aEvictionHandler ); |
|
70 |
|
71 /** |
|
72 * Two-phased constructor. |
|
73 * @since 3.1 |
|
74 * @param |
|
75 * @param |
|
76 * @return CHttpCacheEntry object. |
|
77 */ |
|
78 static CHttpCacheEntry* NewLC( const TDesC8& aUrl, |
|
79 CHttpCacheEvictionHandler& aEvictionHandler ); |
|
80 |
|
81 /** |
|
82 * Destructor. |
|
83 */ |
|
84 virtual ~CHttpCacheEntry(); |
|
85 |
|
86 public: // new functions |
|
87 |
|
88 /** |
|
89 * |
|
90 * @since 3.1 |
|
91 * @param |
|
92 * @return |
|
93 */ |
|
94 void SetState( TCacheEntryState aState ); |
|
95 |
|
96 /** |
|
97 * |
|
98 * @since 3.1 |
|
99 * @param |
|
100 * @return |
|
101 */ |
|
102 inline TCacheEntryState State() { return iState; } |
|
103 |
|
104 /** |
|
105 * |
|
106 * @since 3.1 |
|
107 * @param |
|
108 * @return |
|
109 */ |
|
110 void SetFileNameL( const TFileName& aFileName ); |
|
111 |
|
112 /** |
|
113 * |
|
114 * @since 3.1 |
|
115 * @param |
|
116 * @return |
|
117 */ |
|
118 const TDesC& Filename() const { return *iFileName; } |
|
119 |
|
120 /** |
|
121 * |
|
122 * @since 3.1 |
|
123 * @param |
|
124 * @return |
|
125 */ |
|
126 inline const TDesC8& Url() const { return *iUrl; } |
|
127 |
|
128 /** |
|
129 * |
|
130 * @since 3.1 |
|
131 * @param |
|
132 * @return |
|
133 */ |
|
134 inline TInt64 LastAccessed() const { return iLastAccessed; } |
|
135 |
|
136 /** |
|
137 * |
|
138 * @since 3.1 |
|
139 * @param |
|
140 * @return |
|
141 */ |
|
142 void Accessed(); |
|
143 |
|
144 /** |
|
145 * |
|
146 * @since 3.1 |
|
147 * @param |
|
148 * @return |
|
149 */ |
|
150 inline TUint16 Ref() const { return iRef; } |
|
151 |
|
152 /** |
|
153 * |
|
154 * @since 3.1 |
|
155 * @param |
|
156 * @return |
|
157 */ |
|
158 inline TUint Size() const { return iSize; } |
|
159 |
|
160 /** |
|
161 * |
|
162 * @since 3.1 |
|
163 * @param |
|
164 * @return |
|
165 */ |
|
166 void SetSize( TUint aSize ); |
|
167 |
|
168 /** |
|
169 * |
|
170 * @since 3.1 |
|
171 * @param |
|
172 * @return |
|
173 */ |
|
174 inline TUint16 HeaderSize() const { return iHeaderSize; } |
|
175 |
|
176 /** |
|
177 * |
|
178 * @since 3.1 |
|
179 * @param |
|
180 * @return |
|
181 */ |
|
182 inline void SetHeaderSize( TUint16 aHeaderSize ) { iHeaderSize = aHeaderSize; } |
|
183 |
|
184 /** |
|
185 * |
|
186 * @since 3.1 |
|
187 * @param |
|
188 * @return |
|
189 */ |
|
190 inline TBool Protected() const { return iProtected; } |
|
191 |
|
192 /** |
|
193 * |
|
194 * @since 3.1 |
|
195 * @param |
|
196 * @return |
|
197 */ |
|
198 void SetProtected(); |
|
199 |
|
200 /** |
|
201 * |
|
202 * @since 3.1 |
|
203 * @param |
|
204 * @return |
|
205 */ |
|
206 TInt Internalize( RFileReadStream& aReadStream ); |
|
207 |
|
208 /** |
|
209 * |
|
210 * @since 3.1 |
|
211 * @param |
|
212 * @return |
|
213 */ |
|
214 TInt Externalize( RFileWriteStream& aWriteStream ); |
|
215 |
|
216 /** |
|
217 * |
|
218 * @since 3.1 |
|
219 * @param |
|
220 * @return |
|
221 */ |
|
222 void Accessed(TInt64 aLastAccessed, TUint16 aRef); |
|
223 |
|
224 public : |
|
225 |
|
226 // support linked list |
|
227 static const TInt iOffset; |
|
228 |
|
229 private: |
|
230 |
|
231 /** |
|
232 * Construct. |
|
233 * @since 3.1 |
|
234 * @param |
|
235 * @param |
|
236 * @return CHttpCacheEntry object. |
|
237 */ |
|
238 CHttpCacheEntry( CHttpCacheEvictionHandler& aEvictionHandler ); |
|
239 |
|
240 /** |
|
241 * By default Symbian 2nd phase constructor is private. |
|
242 */ |
|
243 void ConstructL( const TDesC8& aUrl ); |
|
244 |
|
245 private: // Data |
|
246 |
|
247 // |
|
248 HBufC8* iUrl; // owned |
|
249 // if empty, then use url to get filename |
|
250 HBufC* iFileName; // owned |
|
251 // |
|
252 TCacheEntryState iState; |
|
253 // |
|
254 TInt64 iLastAccessed; |
|
255 // ref counter |
|
256 TUint16 iRef; |
|
257 // content size |
|
258 TUint iSize; |
|
259 // header size |
|
260 TUint16 iHeaderSize; |
|
261 // protected content like css, script |
|
262 TUint8 iProtected; |
|
263 // |
|
264 TSglQueLink iSlink; |
|
265 // |
|
266 CHttpCacheEvictionHandler* iEvictionHandler; // not owned |
|
267 // Etrue if added to the eviction table |
|
268 TUint8 iVictim; |
|
269 }; |
|
270 |
|
271 #endif // CHTTPCACHEENTRY_H |
|
272 |
|
273 // End of File |