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 #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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 DCHECK(!callback.is_null()); | 112 DCHECK(!callback.is_null()); |
113 | 113 |
114 if (result < 0) { | 114 if (result < 0) { |
115 DLOG(WARNING) << "Failed to open \"" << path_.value() | 115 DLOG(WARNING) << "Failed to open \"" << path_.value() |
116 << "\" for reading: " << result; | 116 << "\" for reading: " << result; |
117 callback.Run(result); | 117 callback.Run(result); |
118 return; | 118 return; |
119 } | 119 } |
120 | 120 |
121 if (range_offset_) { | 121 if (range_offset_) { |
122 int result = file_stream_->Seek( | 122 int seek_result = file_stream_->Seek( |
123 base::File::FROM_BEGIN, range_offset_, | 123 base::File::FROM_BEGIN, range_offset_, |
124 base::Bind(&UploadFileElementReader::OnSeekCompleted, | 124 base::Bind(&UploadFileElementReader::OnSeekCompleted, |
125 weak_ptr_factory_.GetWeakPtr(), | 125 weak_ptr_factory_.GetWeakPtr(), callback)); |
126 callback)); | 126 DCHECK_GT(0, seek_result); |
127 DCHECK_GT(0, result); | 127 if (seek_result != ERR_IO_PENDING) |
128 if (result != ERR_IO_PENDING) | 128 callback.Run(seek_result); |
129 callback.Run(result); | |
130 } else { | 129 } else { |
131 OnSeekCompleted(callback, OK); | 130 OnSeekCompleted(callback, OK); |
132 } | 131 } |
133 } | 132 } |
134 | 133 |
135 void UploadFileElementReader::OnSeekCompleted( | 134 void UploadFileElementReader::OnSeekCompleted( |
136 const CompletionCallback& callback, | 135 const CompletionCallback& callback, |
137 int64 result) { | 136 int64 result) { |
138 DCHECK(!callback.is_null()); | 137 DCHECK(!callback.is_null()); |
139 | 138 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 ScopedOverridingContentLengthForTests(uint64 value) { | 211 ScopedOverridingContentLengthForTests(uint64 value) { |
213 overriding_content_length = value; | 212 overriding_content_length = value; |
214 } | 213 } |
215 | 214 |
216 UploadFileElementReader::ScopedOverridingContentLengthForTests:: | 215 UploadFileElementReader::ScopedOverridingContentLengthForTests:: |
217 ~ScopedOverridingContentLengthForTests() { | 216 ~ScopedOverridingContentLengthForTests() { |
218 overriding_content_length = 0; | 217 overriding_content_length = 0; |
219 } | 218 } |
220 | 219 |
221 } // namespace net | 220 } // namespace net |
OLD | NEW |