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_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ |
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ |
7 | 7 |
8 #include "content/browser/download/download_file.h" | 8 #include "content/browser/download/download_file.h" |
9 | 9 |
10 #include <stddef.h> | 10 #include <stddef.h> |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 // Rename file_ based on |parameters|. | 177 // Rename file_ based on |parameters|. |
178 void RenameWithRetryInternal(std::unique_ptr<RenameParameters> parameters); | 178 void RenameWithRetryInternal(std::unique_ptr<RenameParameters> parameters); |
179 | 179 |
180 // Send an update on our progress. | 180 // Send an update on our progress. |
181 void SendUpdate(); | 181 void SendUpdate(); |
182 | 182 |
183 // Called before the data is written to disk. | 183 // Called before the data is written to disk. |
184 void WillWriteToDisk(size_t data_len); | 184 void WillWriteToDisk(size_t data_len); |
185 | 185 |
| 186 // For a given SourceStream object and the bytes available to write, determine |
| 187 // the actual number of bytes it can write to the disk. For parallel |
| 188 // downloading, if the first disk IO writes to a location that is already |
| 189 // written by another stream, the current stream should stop writing. Returns |
| 190 // true if the stream can write no more data and should be finished, returns |
| 191 // false otherwise. |
| 192 bool CalculateBytesToWrite(SourceStream* source_stream, |
| 193 size_t bytes_available_to_write, |
| 194 size_t* bytes_to_write); |
| 195 |
186 // Called when there's some activity on the byte stream that needs to be | 196 // Called when there's some activity on the byte stream that needs to be |
187 // handled. | 197 // handled. |
188 void StreamActive(SourceStream* source_stream); | 198 void StreamActive(SourceStream* source_stream); |
189 | 199 |
190 // Register callback and start to read data from the stream. | 200 // Register callback and start to read data from the stream. |
191 void RegisterAndActivateStream(SourceStream* source_stream); | 201 void RegisterAndActivateStream(SourceStream* source_stream); |
192 | 202 |
193 // Adds a new slice to |received_slices_| and update the existing entries in | 203 // Adds a new slice to |received_slices_| and update the existing entries in |
194 // |source_streams_| as their lengths will change. | 204 // |source_streams_| as their lengths will change. |
195 // TODO(qinmin): add a test for this function. | 205 // TODO(qinmin): add a test for this function. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 | 254 |
245 base::WeakPtr<DownloadDestinationObserver> observer_; | 255 base::WeakPtr<DownloadDestinationObserver> observer_; |
246 base::WeakPtrFactory<DownloadFileImpl> weak_factory_; | 256 base::WeakPtrFactory<DownloadFileImpl> weak_factory_; |
247 | 257 |
248 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl); | 258 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl); |
249 }; | 259 }; |
250 | 260 |
251 } // namespace content | 261 } // namespace content |
252 | 262 |
253 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ | 263 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ |
OLD | NEW |