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

Unified Diff: net/base/upload_data_stream.cc

Issue 10878082: net: Move file operation code from UploadData to UploadDataStream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: _ Created 8 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 side-by-side diff with in-line comments
Download patch
Index: net/base/upload_data_stream.cc
diff --git a/net/base/upload_data_stream.cc b/net/base/upload_data_stream.cc
index 239053f2785106e553f9991b72e50c93c46224af..12afc496946d304a39545693026b57801877f6a5 100644
--- a/net/base/upload_data_stream.cc
+++ b/net/base/upload_data_stream.cc
@@ -34,10 +34,14 @@ UploadDataStream::~UploadDataStream() {
int UploadDataStream::Init() {
DCHECK(!initialized_successfully_);
-
+ std::vector<UploadElement>* elements = upload_data_->elements_mutable();
{
base::ThreadRestrictions::ScopedAllowIO allow_io;
- total_size_ = upload_data_->GetContentLengthSync();
+ total_size_ = 0;
+ if (!is_chunked()) {
+ for (size_t i = 0; i < elements->size(); ++i)
+ total_size_ += (*elements)[i].GetContentLength();
+ }
}
// If the underlying file has been changed and the expected file
@@ -45,9 +49,8 @@ int UploadDataStream::Init() {
// modification time from WebKit is based on time_t precision. So we
// have to convert both to time_t to compare. This check is used for
// sliced files.
- const std::vector<UploadElement>& elements = *upload_data_->elements();
- for (size_t i = 0; i < elements.size(); ++i) {
- const UploadElement& element = elements[i];
+ for (size_t i = 0; i < elements->size(); ++i) {
+ const UploadElement& element = (*elements)[i];
if (element.type() == UploadElement::TYPE_FILE &&
!element.expected_file_modification_time().is_null()) {
// Temporarily allow until fix: http://crbug.com/72001.
@@ -63,7 +66,8 @@ int UploadDataStream::Init() {
// Reset the offset, as upload_data_ may already be read (i.e. UploadData
// can be reused for a new UploadDataStream).
- upload_data_->ResetOffset();
+ for (size_t i = 0; i < elements->size(); ++i)
+ (*elements)[i].ResetOffset();
initialized_successfully_ = true;
return OK;

Powered by Google App Engine
This is Rietveld 408576698