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

Side by Side Diff: content/browser/android/url_request_content_job.cc

Issue 1148383003: Only support seeking file streams from the beginning of the file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Win DBG build by Pass()-ing file out of CreateForAsyncHandle. Created 5 years, 6 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
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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 "content/browser/android/url_request_content_job.h" 5 #include "content/browser/android/url_request_content_job.h"
6 6
7 #include "base/android/content_uri_utils.h" 7 #include "base/android/content_uri_utils.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, 170 NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED,
171 net::ERR_REQUEST_RANGE_NOT_SATISFIABLE)); 171 net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
172 return; 172 return;
173 } 173 }
174 174
175 remaining_bytes_ = byte_range_.last_byte_position() - 175 remaining_bytes_ = byte_range_.last_byte_position() -
176 byte_range_.first_byte_position() + 1; 176 byte_range_.first_byte_position() + 1;
177 DCHECK_GE(remaining_bytes_, 0); 177 DCHECK_GE(remaining_bytes_, 0);
178 178
179 if (remaining_bytes_ > 0 && byte_range_.first_byte_position() != 0) { 179 if (remaining_bytes_ > 0 && byte_range_.first_byte_position() != 0) {
180 int rv = stream_->Seek(base::File::FROM_BEGIN, 180 int rv = stream_->Seek(byte_range_.first_byte_position(),
181 byte_range_.first_byte_position(),
182 base::Bind(&URLRequestContentJob::DidSeek, 181 base::Bind(&URLRequestContentJob::DidSeek,
183 weak_ptr_factory_.GetWeakPtr())); 182 weak_ptr_factory_.GetWeakPtr()));
184 if (rv != net::ERR_IO_PENDING) { 183 if (rv != net::ERR_IO_PENDING) {
185 // stream_->Seek() failed, so pass an intentionally erroneous value 184 // stream_->Seek() failed, so pass an intentionally erroneous value
186 // into DidSeek(). 185 // into DidSeek().
187 DidSeek(-1); 186 DidSeek(-1);
188 } 187 }
189 } else { 188 } else {
190 // We didn't need to call stream_->Seek() at all, so we pass to DidSeek() 189 // We didn't need to call stream_->Seek() at all, so we pass to DidSeek()
191 // the value that would mean seek success. This way we skip the code 190 // the value that would mean seek success. This way we skip the code
(...skipping 27 matching lines...) Expand all
219 if (result == 0) { 218 if (result == 0) {
220 NotifyDone(net::URLRequestStatus()); 219 NotifyDone(net::URLRequestStatus());
221 } else if (result < 0) { 220 } else if (result < 0) {
222 NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, result)); 221 NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, result));
223 } 222 }
224 223
225 NotifyReadComplete(result); 224 NotifyReadComplete(result);
226 } 225 }
227 226
228 } // namespace content 227 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/messaging/native_process_launcher_win.cc ('k') | net/base/file_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698