OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 NET_URL_REQUEST_URL_FETCHER_RESPONSE_WRITER_H_ | 5 #ifndef NET_URL_REQUEST_URL_FETCHER_RESPONSE_WRITER_H_ |
6 #define NET_URL_REQUEST_URL_FETCHER_RESPONSE_WRITER_H_ | 6 #define NET_URL_REQUEST_URL_FETCHER_RESPONSE_WRITER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 file_path_ = file_path; | 77 file_path_ = file_path; |
78 } | 78 } |
79 | 79 |
80 // URLFetcherResponseWriter overrides: | 80 // URLFetcherResponseWriter overrides: |
81 virtual int Initialize(const CompletionCallback& callback) OVERRIDE; | 81 virtual int Initialize(const CompletionCallback& callback) OVERRIDE; |
82 virtual int Write(IOBuffer* buffer, | 82 virtual int Write(IOBuffer* buffer, |
83 int num_bytes, | 83 int num_bytes, |
84 const CompletionCallback& callback) OVERRIDE; | 84 const CompletionCallback& callback) OVERRIDE; |
85 virtual int Finish(const CompletionCallback& callback) OVERRIDE; | 85 virtual int Finish(const CompletionCallback& callback) OVERRIDE; |
86 | 86 |
87 // Called when a write has been done. Continues writing if there are more | 87 // Called when a write has been done. |
88 // bytes to write. Otherwise, runs |callback|. | 88 void DidWrite(const CompletionCallback& callback, int result); |
89 void ContinueWrite(scoped_refptr<DrainableIOBuffer> buffer, | |
90 const CompletionCallback& callback, | |
91 int result); | |
92 | 89 |
93 // Drops ownership of the file at |file_path_|. | 90 // Drops ownership of the file at |file_path_|. |
94 // This class will not delete it or write to it again. | 91 // This class will not delete it or write to it again. |
95 void DisownFile(); | 92 void DisownFile(); |
96 | 93 |
97 // Closes the file if it is open. | 94 // Closes the file if it is open. |
98 // |callback| is run with the result upon completion. | 95 // |callback| is run with the result upon completion. |
99 void CloseFile(const CompletionCallback& callback); | 96 void CloseFile(const CompletionCallback& callback); |
100 | 97 |
101 // Closes the file if it is open and then delete it. | 98 // Closes the file if it is open and then delete it. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 // We always append to the file. Track the total number of bytes | 133 // We always append to the file. Track the total number of bytes |
137 // written, so that writes know the offset to give. | 134 // written, so that writes know the offset to give. |
138 int64 total_bytes_written_; | 135 int64 total_bytes_written_; |
139 | 136 |
140 DISALLOW_COPY_AND_ASSIGN(URLFetcherFileWriter); | 137 DISALLOW_COPY_AND_ASSIGN(URLFetcherFileWriter); |
141 }; | 138 }; |
142 | 139 |
143 } // namespace net | 140 } // namespace net |
144 | 141 |
145 #endif // NET_URL_REQUEST_URL_FETCHER_RESPONSE_WRITER_H_ | 142 #endif // NET_URL_REQUEST_URL_FETCHER_RESPONSE_WRITER_H_ |
OLD | NEW |