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/task_runner_util.h" | 10 #include "base/task_runner_util.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 if (result < 0) { | 108 if (result < 0) { |
109 DLOG(WARNING) << "Failed to open \"" << path_.value() | 109 DLOG(WARNING) << "Failed to open \"" << path_.value() |
110 << "\" for reading: " << result; | 110 << "\" for reading: " << result; |
111 callback.Run(result); | 111 callback.Run(result); |
112 return; | 112 return; |
113 } | 113 } |
114 | 114 |
115 if (range_offset_) { | 115 if (range_offset_) { |
116 int seek_result = file_stream_->Seek( | 116 int seek_result = file_stream_->Seek( |
117 base::File::FROM_BEGIN, range_offset_, | 117 range_offset_, base::Bind(&UploadFileElementReader::OnSeekCompleted, |
118 base::Bind(&UploadFileElementReader::OnSeekCompleted, | 118 weak_ptr_factory_.GetWeakPtr(), callback)); |
119 weak_ptr_factory_.GetWeakPtr(), callback)); | |
120 DCHECK_GT(0, seek_result); | 119 DCHECK_GT(0, seek_result); |
121 if (seek_result != ERR_IO_PENDING) | 120 if (seek_result != ERR_IO_PENDING) |
122 callback.Run(seek_result); | 121 callback.Run(seek_result); |
123 } else { | 122 } else { |
124 OnSeekCompleted(callback, OK); | 123 OnSeekCompleted(callback, OK); |
125 } | 124 } |
126 } | 125 } |
127 | 126 |
128 void UploadFileElementReader::OnSeekCompleted( | 127 void UploadFileElementReader::OnSeekCompleted( |
129 const CompletionCallback& callback, | 128 const CompletionCallback& callback, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 ScopedOverridingContentLengthForTests(uint64_t value) { | 204 ScopedOverridingContentLengthForTests(uint64_t value) { |
206 overriding_content_length = value; | 205 overriding_content_length = value; |
207 } | 206 } |
208 | 207 |
209 UploadFileElementReader::ScopedOverridingContentLengthForTests:: | 208 UploadFileElementReader::ScopedOverridingContentLengthForTests:: |
210 ~ScopedOverridingContentLengthForTests() { | 209 ~ScopedOverridingContentLengthForTests() { |
211 overriding_content_length = 0; | 210 overriding_content_length = 0; |
212 } | 211 } |
213 | 212 |
214 } // namespace net | 213 } // namespace net |
OLD | NEW |