OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_RESPONSE_H_ | 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_RESPONSE_H_ |
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_RESPONSE_H_ | 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_RESPONSE_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 void OnRawIOComplete(int result); | 127 void OnRawIOComplete(int result); |
128 }; | 128 }; |
129 | 129 |
130 // Reads existing response data from storage. If the object is deleted | 130 // Reads existing response data from storage. If the object is deleted |
131 // and there is a read in progress, the implementation will return | 131 // and there is a read in progress, the implementation will return |
132 // immediately but will take care of any side effect of cancelling the | 132 // immediately but will take care of any side effect of cancelling the |
133 // operation. In other words, instances are safe to delete at will. | 133 // operation. In other words, instances are safe to delete at will. |
134 class CONTENT_EXPORT AppCacheResponseReader | 134 class CONTENT_EXPORT AppCacheResponseReader |
135 : public AppCacheResponseIO { | 135 : public AppCacheResponseIO { |
136 public: | 136 public: |
137 virtual ~AppCacheResponseReader(); | 137 ~AppCacheResponseReader() override; |
138 | 138 |
139 // Reads http info from storage. Always returns the result of the read | 139 // Reads http info from storage. Always returns the result of the read |
140 // asynchronously through the 'callback'. Returns the number of bytes read | 140 // asynchronously through the 'callback'. Returns the number of bytes read |
141 // or a net:: error code. Guaranteed to not perform partial reads of | 141 // or a net:: error code. Guaranteed to not perform partial reads of |
142 // the info data. The reader acquires a reference to the 'info_buf' until | 142 // the info data. The reader acquires a reference to the 'info_buf' until |
143 // completion at which time the callback is invoked with either a negative | 143 // completion at which time the callback is invoked with either a negative |
144 // error code or the number of bytes read. The 'info_buf' argument should | 144 // error code or the number of bytes read. The 'info_buf' argument should |
145 // contain a NULL http_info when ReadInfo is called. The 'callback' is a | 145 // contain a NULL http_info when ReadInfo is called. The 'callback' is a |
146 // required parameter. | 146 // required parameter. |
147 // Should only be called where there is no Read operation in progress. | 147 // Should only be called where there is no Read operation in progress. |
(...skipping 22 matching lines...) Expand all Loading... |
170 | 170 |
171 protected: | 171 protected: |
172 friend class AppCacheStorageImpl; | 172 friend class AppCacheStorageImpl; |
173 friend class content::MockAppCacheStorage; | 173 friend class content::MockAppCacheStorage; |
174 | 174 |
175 // Should only be constructed by the storage class and derivatives. | 175 // Should only be constructed by the storage class and derivatives. |
176 AppCacheResponseReader(int64 response_id, | 176 AppCacheResponseReader(int64 response_id, |
177 int64 group_id, | 177 int64 group_id, |
178 AppCacheDiskCacheInterface* disk_cache); | 178 AppCacheDiskCacheInterface* disk_cache); |
179 | 179 |
180 virtual void OnIOComplete(int result) override; | 180 void OnIOComplete(int result) override; |
181 void ContinueReadInfo(); | 181 void ContinueReadInfo(); |
182 void ContinueReadData(); | 182 void ContinueReadData(); |
183 void OpenEntryIfNeededAndContinue(); | 183 void OpenEntryIfNeededAndContinue(); |
184 void OnOpenEntryComplete(AppCacheDiskCacheInterface::Entry** entry, int rv); | 184 void OnOpenEntryComplete(AppCacheDiskCacheInterface::Entry** entry, int rv); |
185 | 185 |
186 int range_offset_; | 186 int range_offset_; |
187 int range_length_; | 187 int range_length_; |
188 int read_position_; | 188 int read_position_; |
189 net::CompletionCallback open_callback_; | 189 net::CompletionCallback open_callback_; |
190 base::WeakPtrFactory<AppCacheResponseReader> weak_factory_; | 190 base::WeakPtrFactory<AppCacheResponseReader> weak_factory_; |
191 }; | 191 }; |
192 | 192 |
193 // Writes new response data to storage. If the object is deleted | 193 // Writes new response data to storage. If the object is deleted |
194 // and there is a write in progress, the implementation will return | 194 // and there is a write in progress, the implementation will return |
195 // immediately but will take care of any side effect of cancelling the | 195 // immediately but will take care of any side effect of cancelling the |
196 // operation. In other words, instances are safe to delete at will. | 196 // operation. In other words, instances are safe to delete at will. |
197 class CONTENT_EXPORT AppCacheResponseWriter | 197 class CONTENT_EXPORT AppCacheResponseWriter |
198 : public AppCacheResponseIO { | 198 : public AppCacheResponseIO { |
199 public: | 199 public: |
200 virtual ~AppCacheResponseWriter(); | 200 ~AppCacheResponseWriter() override; |
201 | 201 |
202 // Writes the http info to storage. Always returns the result of the write | 202 // Writes the http info to storage. Always returns the result of the write |
203 // asynchronously through the 'callback'. Returns the number of bytes written | 203 // asynchronously through the 'callback'. Returns the number of bytes written |
204 // or a net:: error code. The writer acquires a reference to the 'info_buf' | 204 // or a net:: error code. The writer acquires a reference to the 'info_buf' |
205 // until completion at which time the callback is invoked with either a | 205 // until completion at which time the callback is invoked with either a |
206 // negative error code or the number of bytes written. The 'callback' is a | 206 // negative error code or the number of bytes written. The 'callback' is a |
207 // required parameter. The contents of 'info_buf' are not modified. | 207 // required parameter. The contents of 'info_buf' are not modified. |
208 // Should only be called where there is no Write operation in progress. | 208 // Should only be called where there is no Write operation in progress. |
209 void WriteInfo(HttpResponseInfoIOBuffer* info_buf, | 209 void WriteInfo(HttpResponseInfoIOBuffer* info_buf, |
210 const net::CompletionCallback& callback); | 210 const net::CompletionCallback& callback); |
(...skipping 25 matching lines...) Expand all Loading... |
236 friend class AppCacheStorageImpl; | 236 friend class AppCacheStorageImpl; |
237 friend class content::MockAppCacheStorage; | 237 friend class content::MockAppCacheStorage; |
238 | 238 |
239 enum CreationPhase { | 239 enum CreationPhase { |
240 NO_ATTEMPT, | 240 NO_ATTEMPT, |
241 INITIAL_ATTEMPT, | 241 INITIAL_ATTEMPT, |
242 DOOM_EXISTING, | 242 DOOM_EXISTING, |
243 SECOND_ATTEMPT | 243 SECOND_ATTEMPT |
244 }; | 244 }; |
245 | 245 |
246 virtual void OnIOComplete(int result) override; | 246 void OnIOComplete(int result) override; |
247 void ContinueWriteInfo(); | 247 void ContinueWriteInfo(); |
248 void ContinueWriteData(); | 248 void ContinueWriteData(); |
249 void CreateEntryIfNeededAndContinue(); | 249 void CreateEntryIfNeededAndContinue(); |
250 void OnCreateEntryComplete(AppCacheDiskCacheInterface::Entry** entry, int rv); | 250 void OnCreateEntryComplete(AppCacheDiskCacheInterface::Entry** entry, int rv); |
251 | 251 |
252 int info_size_; | 252 int info_size_; |
253 int write_position_; | 253 int write_position_; |
254 int write_amount_; | 254 int write_amount_; |
255 CreationPhase creation_phase_; | 255 CreationPhase creation_phase_; |
256 net::CompletionCallback create_callback_; | 256 net::CompletionCallback create_callback_; |
257 base::WeakPtrFactory<AppCacheResponseWriter> weak_factory_; | 257 base::WeakPtrFactory<AppCacheResponseWriter> weak_factory_; |
258 }; | 258 }; |
259 | 259 |
260 } // namespace content | 260 } // namespace content |
261 | 261 |
262 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_RESPONSE_H_ | 262 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_RESPONSE_H_ |
OLD | NEW |