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

Side by Side Diff: net/base/upload_data.cc

Issue 10408042: net: Fix a regression that broke file uploading with http authentication (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « net/base/upload_data.h ('k') | net/base/upload_data_stream_unittest.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_data.h" 5 #include "net/base/upload_data.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 107 }
108 108
109 NOTREACHED(); 109 NOTREACHED();
110 return 0; 110 return 0;
111 } 111 }
112 112
113 uint64 UploadData::Element::BytesRemaining() { 113 uint64 UploadData::Element::BytesRemaining() {
114 return GetContentLength() - offset_; 114 return GetContentLength() - offset_;
115 } 115 }
116 116
117 void UploadData::Element::ResetOffset() {
118 offset_ = 0;
119
120 // Delete the file stream if already opened, so we can reread the file from
121 // the beginning.
122 if (file_stream_) {
123 // Temporarily allow until fix: http://crbug.com/72001.
124 base::ThreadRestrictions::ScopedAllowIO allow_io;
125 file_stream_->CloseSync();
126 delete file_stream_;
127 file_stream_ = NULL;
128 }
wtc 2012/05/21 22:54:41 As a performance optimization, we can leave file_s
satorux1 2012/05/21 23:14:40 Thanks. I'm going to stick with my fix for now for
129 }
130
117 FileStream* UploadData::Element::OpenFileStream() { 131 FileStream* UploadData::Element::OpenFileStream() {
118 scoped_ptr<FileStream> file(new FileStream(NULL)); 132 scoped_ptr<FileStream> file(new FileStream(NULL));
119 int64 rv = file->OpenSync( 133 int64 rv = file->OpenSync(
120 file_path_, 134 file_path_,
121 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ); 135 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ);
122 if (rv != OK) { 136 if (rv != OK) {
123 // If the file can't be opened, we'll just upload an empty file. 137 // If the file can't be opened, we'll just upload an empty file.
124 DLOG(WARNING) << "Failed to open \"" << file_path_.value() 138 DLOG(WARNING) << "Failed to open \"" << file_path_.value()
125 << "\" for reading: " << rv; 139 << "\" for reading: " << rv;
126 return NULL; 140 return NULL;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 return; 299 return;
286 300
287 for (size_t i = 0; i < elements_.size(); ++i) 301 for (size_t i = 0; i < elements_.size(); ++i)
288 *content_length += elements_[i].GetContentLength(); 302 *content_length += elements_[i].GetContentLength();
289 } 303 }
290 304
291 UploadData::~UploadData() { 305 UploadData::~UploadData() {
292 } 306 }
293 307
294 } // namespace net 308 } // namespace net
OLDNEW
« no previous file with comments | « net/base/upload_data.h ('k') | net/base/upload_data_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698