Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(808)

Side by Side Diff: content/browser/appcache/appcache_response.h

Issue 1315443003: ServiceWorkerWriteToCacheJob: refactor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_cache_writer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 void WriteInfo(HttpResponseInfoIOBuffer* info_buf, 212 // (virtual for testing)
213 const net::CompletionCallback& callback); 213 virtual void WriteInfo(HttpResponseInfoIOBuffer* info_buf,
214 const net::CompletionCallback& callback);
214 215
215 // Writes data to storage. Always returns the result of the write 216 // Writes data to storage. Always returns the result of the write
216 // asynchronously through the 'callback'. Returns the number of bytes written 217 // asynchronously through the 'callback'. Returns the number of bytes written
217 // or a net:: error code. Guaranteed to not perform partial writes. 218 // or a net:: error code. Guaranteed to not perform partial writes.
218 // The writer acquires a reference to the provided 'buf' until completion at 219 // The writer acquires a reference to the provided 'buf' until completion at
219 // which time the callback is invoked with either a negative error code or 220 // which time the callback is invoked with either a negative error code or
220 // the number of bytes written. The 'callback' is a required parameter. 221 // the number of bytes written. The 'callback' is a required parameter.
221 // The contents of 'buf' are not modified. 222 // The contents of 'buf' are not modified.
222 // Should only be called where there is no Write operation in progress. 223 // Should only be called where there is no Write operation in progress.
223 void WriteData(net::IOBuffer* buf, int buf_len, 224 // (virtual for testing)
224 const net::CompletionCallback& callback); 225 virtual void WriteData(net::IOBuffer* buf,
226 int buf_len,
227 const net::CompletionCallback& callback);
225 228
226 // Returns true if there is a write pending. 229 // Returns true if there is a write pending.
227 bool IsWritePending() { return IsIOPending(); } 230 bool IsWritePending() { return IsIOPending(); }
228 231
229 // Returns the amount written, info and data. 232 // Returns the amount written, info and data.
230 int64 amount_written() { return info_size_ + write_position_; } 233 int64 amount_written() { return info_size_ + write_position_; }
231 234
232 protected: 235 protected:
233 // Should only be constructed by the storage class and derivatives. 236 // Should only be constructed by the storage class and derivatives.
234 AppCacheResponseWriter(int64 response_id, 237 AppCacheResponseWriter(int64 response_id,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 void OnIOComplete(int result) override; 300 void OnIOComplete(int result) override;
298 void OnOpenEntryComplete() override; 301 void OnOpenEntryComplete() override;
299 302
300 int write_amount_; 303 int write_amount_;
301 base::WeakPtrFactory<AppCacheResponseMetadataWriter> weak_factory_; 304 base::WeakPtrFactory<AppCacheResponseMetadataWriter> weak_factory_;
302 }; 305 };
303 306
304 } // namespace content 307 } // namespace content
305 308
306 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_RESPONSE_H_ 309 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_RESPONSE_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_cache_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698