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

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

Issue 2770303002: Add a helper method to truncate SourceStream's length (Closed)
Patch Set: nit 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
« no previous file with comments | « no previous file | content/browser/download/download_file_impl.cc » ('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_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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 class CONTENT_EXPORT SourceStream { 99 class CONTENT_EXPORT SourceStream {
100 public: 100 public:
101 SourceStream(int64_t offset, 101 SourceStream(int64_t offset,
102 int64_t length, 102 int64_t length,
103 std::unique_ptr<ByteStreamReader> stream_reader); 103 std::unique_ptr<ByteStreamReader> stream_reader);
104 ~SourceStream(); 104 ~SourceStream();
105 105
106 // Called after successfully writing a buffer to disk. 106 // Called after successfully writing a buffer to disk.
107 void OnWriteBytesToDisk(int64_t bytes_write); 107 void OnWriteBytesToDisk(int64_t bytes_write);
108 108
109 // Given a data block that is already written, truncate the length of this
110 // object to avoid overwriting that block.
111 void TruncateLengthWithWrittenDataBlock(int64_t offset,
112 int64_t bytes_written);
113
109 ByteStreamReader* stream_reader() const { return stream_reader_.get(); } 114 ByteStreamReader* stream_reader() const { return stream_reader_.get(); }
110 int64_t offset() const { return offset_; } 115 int64_t offset() const { return offset_; }
111 int64_t length() const { return length_; } 116 int64_t length() const { return length_; }
112 void set_length(int64_t length) { length_ = length; } 117 void set_length(int64_t length) { length_ = length; }
113 int64_t bytes_written() const { return bytes_written_; } 118 int64_t bytes_written() const { return bytes_written_; }
114 bool is_finished() const { return finished_; } 119 bool is_finished() const { return finished_; }
115 void set_finished(bool finish) { finished_ = finish; } 120 void set_finished(bool finish) { finished_ = finish; }
116 size_t index() { return index_; } 121 size_t index() { return index_; }
117 void set_index(size_t index) { index_ = index; } 122 void set_index(size_t index) { index_ = index; }
118 123
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 269
265 base::WeakPtr<DownloadDestinationObserver> observer_; 270 base::WeakPtr<DownloadDestinationObserver> observer_;
266 base::WeakPtrFactory<DownloadFileImpl> weak_factory_; 271 base::WeakPtrFactory<DownloadFileImpl> weak_factory_;
267 272
268 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl); 273 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl);
269 }; 274 };
270 275
271 } // namespace content 276 } // namespace content
272 277
273 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ 278 #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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698