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

Side by Side Diff: net/base/upload_file_element_reader.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
« no previous file with comments | « net/base/mock_file_stream.cc ('k') | net/url_request/url_request_file_job.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/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
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
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
OLDNEW
« no previous file with comments | « net/base/mock_file_stream.cc ('k') | net/url_request/url_request_file_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698