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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 | 179 |
180 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 int reading_metadata_size_; | |
189 net::CompletionCallback open_callback_; | 190 net::CompletionCallback open_callback_; |
190 base::WeakPtrFactory<AppCacheResponseReader> weak_factory_; | 191 base::WeakPtrFactory<AppCacheResponseReader> weak_factory_; |
191 }; | 192 }; |
192 | 193 |
193 // Writes new response data to storage. If the object is deleted | 194 // Writes new response data to storage. If the object is deleted |
194 // and there is a write in progress, the implementation will return | 195 // and there is a write in progress, the implementation will return |
195 // immediately but will take care of any side effect of cancelling the | 196 // immediately but will take care of any side effect of cancelling the |
196 // operation. In other words, instances are safe to delete at will. | 197 // operation. In other words, instances are safe to delete at will. |
197 class CONTENT_EXPORT AppCacheResponseWriter | 198 class CONTENT_EXPORT AppCacheResponseWriter |
198 : public AppCacheResponseIO { | 199 : public AppCacheResponseIO { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 void OnCreateEntryComplete(AppCacheDiskCacheInterface::Entry** entry, int rv); | 251 void OnCreateEntryComplete(AppCacheDiskCacheInterface::Entry** entry, int rv); |
251 | 252 |
252 int info_size_; | 253 int info_size_; |
253 int write_position_; | 254 int write_position_; |
254 int write_amount_; | 255 int write_amount_; |
255 CreationPhase creation_phase_; | 256 CreationPhase creation_phase_; |
256 net::CompletionCallback create_callback_; | 257 net::CompletionCallback create_callback_; |
257 base::WeakPtrFactory<AppCacheResponseWriter> weak_factory_; | 258 base::WeakPtrFactory<AppCacheResponseWriter> weak_factory_; |
258 }; | 259 }; |
259 | 260 |
261 // Writes metadata of the existing response to storage. If the object is deleted | |
262 // and there is a write in progress, the implementation will return | |
263 // immediately but will take care of any side effect of cancelling the | |
264 // operation. In other words, instances are safe to delete at will. | |
265 class CONTENT_EXPORT AppCacheResponseMetadataWriter | |
266 : public AppCacheResponseIO { | |
267 public: | |
268 ~AppCacheResponseMetadataWriter() override; | |
269 | |
270 // Writes metadata to storage. Always returns the result of the write | |
271 // asynchronously through the 'callback'. Returns the number of bytes written | |
272 // or a net:: error code. Guaranteed to not perform partial writes. | |
273 // The writer acquires a reference to the provided 'buf' until completion at | |
274 // which time the callback is invoked with either a negative error code or | |
275 // the number of bytes written. The 'callback' is a required parameter. | |
276 // The contents of 'buf' are not modified. | |
277 // Can't be called multiple times. | |
278 void WriteMetadata(net::IOBuffer* buf, | |
279 int buf_len, | |
280 const net::CompletionCallback& callback); | |
281 | |
282 // Returns true if there is a write pending. | |
283 bool IsWritePending() { return IsIOPending(); } | |
284 | |
285 protected: | |
286 friend class AppCacheStorageImpl; | |
287 friend class content::MockAppCacheStorage; | |
288 // Should only be constructed by the storage class and derivatives. | |
289 AppCacheResponseMetadataWriter(int64 response_id, | |
290 int64 group_id, | |
291 AppCacheDiskCacheInterface* disk_cache); | |
292 | |
293 private: | |
294 void OnIOComplete(int result) override; | |
295 void OpenEntry(); | |
296 void OnOpenEntryComplete(AppCacheDiskCacheInterface::Entry** entry, int rv); | |
297 | |
298 bool started_; | |
michaeln
2015/02/18 02:18:59
is this used?
horo
2015/02/18 03:33:44
deleted
| |
299 int write_amount_; | |
300 net::CompletionCallback open_callback_; | |
301 base::WeakPtrFactory<AppCacheResponseMetadataWriter> weak_factory_; | |
302 }; | |
303 | |
260 } // namespace content | 304 } // namespace content |
261 | 305 |
262 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_RESPONSE_H_ | 306 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_RESPONSE_H_ |
OLD | NEW |