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

Side by Side Diff: content/browser/download/download_file_impl.h

Issue 2744793003: Move the logic to determine how much data can be written to another function (Closed)
Patch Set: comments Created 3 years, 9 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
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_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
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 it has read, determine the
187 // actual number of bytes it can write to the disk. For parallel downloading,
188 // if the first disk IO writes to a location that is already written by
189 // another stream, the current stream should stop writing. Returns true if the
190 // stream can write no more data and should be finished, returns false
191 // otherwise.
192 bool CalculateBytesToWrite(SourceStream* source_stream,
193 size_t bytes_read,
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 251
242 base::WeakPtr<DownloadDestinationObserver> observer_; 252 base::WeakPtr<DownloadDestinationObserver> observer_;
243 base::WeakPtrFactory<DownloadFileImpl> weak_factory_; 253 base::WeakPtrFactory<DownloadFileImpl> weak_factory_;
244 254
245 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl); 255 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl);
246 }; 256 };
247 257
248 } // namespace content 258 } // namespace content
249 259
250 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ 260 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/download/download_file_impl.cc » ('j') | content/browser/download/download_file_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698