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

Unified Diff: net/base/upload_file_element_reader.cc

Issue 39203004: [Net] Fix error handling on wrong file in UploadData (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win test fix Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: net/base/upload_file_element_reader.cc
diff --git a/net/base/upload_file_element_reader.cc b/net/base/upload_file_element_reader.cc
index d1f2a12ac8cd13c6d5037032f13cdd98baf2ea03..223306a0c39255fdafe8d28b0971de3ffc21485e 100644
--- a/net/base/upload_file_element_reader.cc
+++ b/net/base/upload_file_element_reader.cc
@@ -28,6 +28,9 @@ int InitInternal(const base::FilePath& path,
const base::Time& expected_modification_time,
scoped_ptr<FileStream, FileStreamDeleter>* out_file_stream,
uint64* out_content_length) {
+ out_file_stream->reset();
+ *out_content_length = 0;
+
scoped_ptr<FileStream> file_stream(new FileStream(NULL));
int64 rv = file_stream->OpenSync(
path, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ);
@@ -35,19 +38,18 @@ int InitInternal(const base::FilePath& path,
// If the file can't be opened, we'll just upload an empty file.
hashimoto 2013/10/29 04:08:59 This comment is obsolete.
tzik 2013/10/29 05:48:02 Done.
DLOG(WARNING) << "Failed to open \"" << path.value()
<< "\" for reading: " << rv;
- file_stream.reset();
+ return rv;
} else if (range_offset) {
rv = file_stream->SeekSync(FROM_BEGIN, range_offset);
if (rv < 0) {
DLOG(WARNING) << "Failed to seek \"" << path.value()
<< "\" to offset: " << range_offset << " (" << rv << ")";
- file_stream.reset();
+ return rv;
}
}
int64 length = 0;
- if (file_stream.get() &&
- file_util::GetFileSize(path, &length) &&
+ if (file_util::GetFileSize(path, &length) &&
hashimoto 2013/10/29 04:08:59 Shouldn't we return an error when GetFileSize fail
tzik 2013/10/29 05:48:02 Done.
range_offset < static_cast<uint64>(length)) {
// Compensate for the offset.
length = std::min(length - range_offset, range_length);
« no previous file with comments | « no previous file | net/base/upload_file_element_reader_unittest.cc » ('j') | net/spdy/spdy_network_transaction_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698