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

Side by Side Diff: net/base/upload_file_element_reader.cc

Issue 140733002: Revert 244982 "Revert 244857 "net: Remove classes which were use..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: rebase Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « net/base/upload_file_element_reader.h ('k') | net/base/upload_file_element_reader_unittest.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 #include "net/base/upload_file_element_reader.h" 5 #include "net/base/upload_file_element_reader.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/task_runner_util.h" 10 #include "base/task_runner_util.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 UploadFileElementReader::ScopedOverridingContentLengthForTests:: 240 UploadFileElementReader::ScopedOverridingContentLengthForTests::
241 ScopedOverridingContentLengthForTests(uint64 value) { 241 ScopedOverridingContentLengthForTests(uint64 value) {
242 overriding_content_length = value; 242 overriding_content_length = value;
243 } 243 }
244 244
245 UploadFileElementReader::ScopedOverridingContentLengthForTests:: 245 UploadFileElementReader::ScopedOverridingContentLengthForTests::
246 ~ScopedOverridingContentLengthForTests() { 246 ~ScopedOverridingContentLengthForTests() {
247 overriding_content_length = 0; 247 overriding_content_length = 0;
248 } 248 }
249 249
250 UploadFileElementReaderSync::UploadFileElementReaderSync(
251 const base::FilePath& path,
252 uint64 range_offset,
253 uint64 range_length,
254 const base::Time& expected_modification_time)
255 : path_(path),
256 range_offset_(range_offset),
257 range_length_(range_length),
258 expected_modification_time_(expected_modification_time),
259 content_length_(0),
260 bytes_remaining_(0) {
261 }
262
263 UploadFileElementReaderSync::~UploadFileElementReaderSync() {
264 }
265
266 int UploadFileElementReaderSync::Init(const CompletionCallback& callback) {
267 bytes_remaining_ = 0;
268 content_length_ = 0;
269 file_stream_.reset();
270
271 const int result = InitInternal(path_, range_offset_, range_length_,
272 expected_modification_time_,
273 &file_stream_, &content_length_);
274 bytes_remaining_ = GetContentLength();
275 return result;
276 }
277
278 uint64 UploadFileElementReaderSync::GetContentLength() const {
279 return content_length_;
280 }
281
282 uint64 UploadFileElementReaderSync::BytesRemaining() const {
283 return bytes_remaining_;
284 }
285
286 int UploadFileElementReaderSync::Read(IOBuffer* buf,
287 int buf_length,
288 const CompletionCallback& callback) {
289 const int result = ReadInternal(buf, buf_length, BytesRemaining(),
290 file_stream_.get());
291 if (result > 0) {
292 DCHECK_GE(bytes_remaining_, static_cast<uint64>(result));
293 bytes_remaining_ -= result;
294 }
295 return result;
296 }
297
298 } // namespace net 250 } // namespace net
OLDNEW
« no previous file with comments | « net/base/upload_file_element_reader.h ('k') | net/base/upload_file_element_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698