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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 public: | 202 public: |
203 ~AppCacheResponseWriter() override; | 203 ~AppCacheResponseWriter() override; |
204 | 204 |
205 // Writes the http info to storage. Always returns the result of the write | 205 // Writes the http info to storage. Always returns the result of the write |
206 // asynchronously through the 'callback'. Returns the number of bytes written | 206 // asynchronously through the 'callback'. Returns the number of bytes written |
207 // or a net:: error code. The writer acquires a reference to the 'info_buf' | 207 // or a net:: error code. The writer acquires a reference to the 'info_buf' |
208 // until completion at which time the callback is invoked with either a | 208 // until completion at which time the callback is invoked with either a |
209 // negative error code or the number of bytes written. The 'callback' is a | 209 // negative error code or the number of bytes written. The 'callback' is a |
210 // required parameter. The contents of 'info_buf' are not modified. | 210 // required parameter. The contents of 'info_buf' are not modified. |
211 // Should only be called where there is no Write operation in progress. | 211 // Should only be called where there is no Write operation in progress. |
212 // (virtual for testing) | 212 void WriteInfo(HttpResponseInfoIOBuffer* info_buf, |
213 virtual void WriteInfo(HttpResponseInfoIOBuffer* info_buf, | 213 const net::CompletionCallback& callback); |
214 const net::CompletionCallback& callback); | |
215 | 214 |
216 // Writes data to storage. Always returns the result of the write | 215 // Writes data to storage. Always returns the result of the write |
217 // asynchronously through the 'callback'. Returns the number of bytes written | 216 // asynchronously through the 'callback'. Returns the number of bytes written |
218 // or a net:: error code. Guaranteed to not perform partial writes. | 217 // or a net:: error code. Guaranteed to not perform partial writes. |
219 // The writer acquires a reference to the provided 'buf' until completion at | 218 // The writer acquires a reference to the provided 'buf' until completion at |
220 // which time the callback is invoked with either a negative error code or | 219 // which time the callback is invoked with either a negative error code or |
221 // the number of bytes written. The 'callback' is a required parameter. | 220 // the number of bytes written. The 'callback' is a required parameter. |
222 // The contents of 'buf' are not modified. | 221 // The contents of 'buf' are not modified. |
223 // Should only be called where there is no Write operation in progress. | 222 // Should only be called where there is no Write operation in progress. |
224 // (virtual for testing) | 223 void WriteData(net::IOBuffer* buf, int buf_len, |
225 virtual void WriteData(net::IOBuffer* buf, | 224 const net::CompletionCallback& callback); |
226 int buf_len, | |
227 const net::CompletionCallback& callback); | |
228 | 225 |
229 // Returns true if there is a write pending. | 226 // Returns true if there is a write pending. |
230 bool IsWritePending() { return IsIOPending(); } | 227 bool IsWritePending() { return IsIOPending(); } |
231 | 228 |
232 // Returns the amount written, info and data. | 229 // Returns the amount written, info and data. |
233 int64 amount_written() { return info_size_ + write_position_; } | 230 int64 amount_written() { return info_size_ + write_position_; } |
234 | 231 |
235 protected: | 232 protected: |
236 // Should only be constructed by the storage class and derivatives. | 233 // Should only be constructed by the storage class and derivatives. |
237 AppCacheResponseWriter(int64 response_id, | 234 AppCacheResponseWriter(int64 response_id, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 void OnIOComplete(int result) override; | 297 void OnIOComplete(int result) override; |
301 void OnOpenEntryComplete() override; | 298 void OnOpenEntryComplete() override; |
302 | 299 |
303 int write_amount_; | 300 int write_amount_; |
304 base::WeakPtrFactory<AppCacheResponseMetadataWriter> weak_factory_; | 301 base::WeakPtrFactory<AppCacheResponseMetadataWriter> weak_factory_; |
305 }; | 302 }; |
306 | 303 |
307 } // namespace content | 304 } // namespace content |
308 | 305 |
309 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_RESPONSE_H_ | 306 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_RESPONSE_H_ |
OLD | NEW |