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

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

Issue 7618039: PPB_URLRequestInfo::AppendFileToBody using sync ipc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 4 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_stream.h" 5 #include "net/base/upload_data_stream.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/threading/thread_restrictions.h"
9 #include "net/base/file_stream.h" 10 #include "net/base/file_stream.h"
10 #include "net/base/io_buffer.h" 11 #include "net/base/io_buffer.h"
11 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
12 13
13 namespace net { 14 namespace net {
14 15
15 bool UploadDataStream::merge_chunks_ = true; 16 bool UploadDataStream::merge_chunks_ = true;
16 17
17 UploadDataStream::~UploadDataStream() { 18 UploadDataStream::~UploadDataStream() {
18 } 19 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 102 }
102 next_element_remaining_ = element.GetContentLength(); 103 next_element_remaining_ = element.GetContentLength();
103 next_element_stream_.reset(element.NewFileStreamForReading()); 104 next_element_stream_.reset(element.NewFileStreamForReading());
104 } 105 }
105 106
106 int rv = 0; 107 int rv = 0;
107 int count = 108 int count =
108 static_cast<int>(std::min(next_element_remaining_, 109 static_cast<int>(std::min(next_element_remaining_,
109 static_cast<uint64>(size_remaining))); 110 static_cast<uint64>(size_remaining)));
110 if (count > 0) { 111 if (count > 0) {
112 // Temporarily allow until fix: http://crbug.com/72001.
113 base::ThreadRestrictions::ScopedAllowIO allow_io;
michaeln 2011/08/15 18:12:11 Was this just missing before or does something abo
kinuko 2011/08/16 04:00:53 In my testing whenever I try uploading a file with
darin (slow to review) 2011/08/16 17:28:36 Yeah, I'd expect that this is needed. I'm not sur
111 if (next_element_stream_.get()) 114 if (next_element_stream_.get())
112 rv = next_element_stream_->Read(buf_->data() + buf_len_, count, NULL); 115 rv = next_element_stream_->Read(buf_->data() + buf_len_, count, NULL);
113 if (rv <= 0) { 116 if (rv <= 0) {
114 // If there's less data to read than we initially observed, then 117 // If there's less data to read than we initially observed, then
115 // pad with zero. Otherwise the server will hang waiting for the 118 // pad with zero. Otherwise the server will hang waiting for the
116 // rest of the data. 119 // rest of the data.
117 memset(buf_->data() + buf_len_, 0, count); 120 memset(buf_->data() + buf_len_, 0, count);
118 rv = count; 121 rv = count;
119 } 122 }
120 buf_len_ += rv; 123 buf_len_ += rv;
(...skipping 30 matching lines...) Expand all
151 bool UploadDataStream::IsOnLastChunk() const { 154 bool UploadDataStream::IsOnLastChunk() const {
152 const std::vector<UploadData::Element>& elements = *data_->elements(); 155 const std::vector<UploadData::Element>& elements = *data_->elements();
153 DCHECK(data_->is_chunked()); 156 DCHECK(data_->is_chunked());
154 return (eof_ || 157 return (eof_ ||
155 (!elements.empty() && 158 (!elements.empty() &&
156 next_element_ == elements.size() && 159 next_element_ == elements.size() &&
157 elements.back().is_last_chunk())); 160 elements.back().is_last_chunk()));
158 } 161 }
159 162
160 } // namespace net 163 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698