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

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

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 | « net/base/upload_bytes_element_reader.cc ('k') | net/cert/cert_policy_enforcer.h » ('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/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/profiler/scoped_tracker.h" 10 #include "base/profiler/scoped_tracker.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 uint64 UploadFileElementReader::BytesRemaining() const { 72 uint64 UploadFileElementReader::BytesRemaining() const {
73 return bytes_remaining_; 73 return bytes_remaining_;
74 } 74 }
75 75
76 int UploadFileElementReader::Read(IOBuffer* buf, 76 int UploadFileElementReader::Read(IOBuffer* buf,
77 int buf_length, 77 int buf_length,
78 const CompletionCallback& callback) { 78 const CompletionCallback& callback) {
79 DCHECK(!callback.is_null()); 79 DCHECK(!callback.is_null());
80 80
81 uint64 num_bytes_to_read = 81 int num_bytes_to_read = static_cast<int>(
82 std::min(BytesRemaining(), static_cast<uint64>(buf_length)); 82 std::min(BytesRemaining(), static_cast<uint64>(buf_length)));
83 if (num_bytes_to_read == 0) 83 if (num_bytes_to_read == 0)
84 return 0; 84 return 0;
85 85
86 int result = file_stream_->Read( 86 int result = file_stream_->Read(
87 buf, num_bytes_to_read, 87 buf, num_bytes_to_read,
88 base::Bind(base::IgnoreResult(&UploadFileElementReader::OnReadCompleted), 88 base::Bind(base::IgnoreResult(&UploadFileElementReader::OnReadCompleted),
89 weak_ptr_factory_.GetWeakPtr(), 89 weak_ptr_factory_.GetWeakPtr(),
90 callback)); 90 callback));
91 // Even in async mode, FileStream::Read() may return the result synchronously. 91 // Even in async mode, FileStream::Read() may return the result synchronously.
92 if (result != ERR_IO_PENDING) 92 if (result != ERR_IO_PENDING)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 133 }
134 134
135 void UploadFileElementReader::OnSeekCompleted( 135 void UploadFileElementReader::OnSeekCompleted(
136 const CompletionCallback& callback, 136 const CompletionCallback& callback,
137 int64 result) { 137 int64 result) {
138 DCHECK(!callback.is_null()); 138 DCHECK(!callback.is_null());
139 139
140 if (result < 0) { 140 if (result < 0) {
141 DLOG(WARNING) << "Failed to seek \"" << path_.value() 141 DLOG(WARNING) << "Failed to seek \"" << path_.value()
142 << "\" to offset: " << range_offset_ << " (" << result << ")"; 142 << "\" to offset: " << range_offset_ << " (" << result << ")";
143 callback.Run(result); 143 callback.Run(static_cast<int>(result));
144 return; 144 return;
145 } 145 }
146 146
147 base::File::Info* file_info = new base::File::Info; 147 base::File::Info* file_info = new base::File::Info;
148 bool posted = base::PostTaskAndReplyWithResult( 148 bool posted = base::PostTaskAndReplyWithResult(
149 task_runner_.get(), 149 task_runner_.get(),
150 FROM_HERE, 150 FROM_HERE,
151 base::Bind(&base::GetFileInfo, path_, file_info), 151 base::Bind(&base::GetFileInfo, path_, file_info),
152 base::Bind(&UploadFileElementReader::OnGetFileInfoCompleted, 152 base::Bind(&UploadFileElementReader::OnGetFileInfoCompleted,
153 weak_ptr_factory_.GetWeakPtr(), 153 weak_ptr_factory_.GetWeakPtr(),
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 ScopedOverridingContentLengthForTests(uint64 value) { 209 ScopedOverridingContentLengthForTests(uint64 value) {
210 overriding_content_length = value; 210 overriding_content_length = value;
211 } 211 }
212 212
213 UploadFileElementReader::ScopedOverridingContentLengthForTests:: 213 UploadFileElementReader::ScopedOverridingContentLengthForTests::
214 ~ScopedOverridingContentLengthForTests() { 214 ~ScopedOverridingContentLengthForTests() {
215 overriding_content_length = 0; 215 overriding_content_length = 0;
216 } 216 }
217 217
218 } // namespace net 218 } // namespace net
OLDNEW
« no previous file with comments | « net/base/upload_bytes_element_reader.cc ('k') | net/cert/cert_policy_enforcer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698