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

Side by Side Diff: net/http/http_stream_parser.cc

Issue 10834178: net: Return size of upload as well as position from HttpTransaction::GetUploadProgress() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 3 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) 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/http/http_stream_parser.h" 5 #include "net/http/http_stream_parser.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 if (response_->headers->IsChunkEncoded()) { 870 if (response_->headers->IsChunkEncoded()) {
871 chunked_decoder_.reset(new HttpChunkedDecoder()); 871 chunked_decoder_.reset(new HttpChunkedDecoder());
872 } else { 872 } else {
873 response_body_length_ = response_->headers->GetContentLength(); 873 response_body_length_ = response_->headers->GetContentLength();
874 // If response_body_length_ is still -1, then we have to wait 874 // If response_body_length_ is still -1, then we have to wait
875 // for the server to close the connection. 875 // for the server to close the connection.
876 } 876 }
877 } 877 }
878 } 878 }
879 879
880 uint64 HttpStreamParser::GetUploadProgress() const { 880 UploadProgress HttpStreamParser::GetUploadProgress() const {
881 if (!request_body_.get()) 881 if (!request_body_.get())
882 return 0; 882 return UploadProgress();
883 883
884 return request_body_->position(); 884 return UploadProgress(request_body_->position(), request_body_->size());
885 } 885 }
886 886
887 HttpResponseInfo* HttpStreamParser::GetResponseInfo() { 887 HttpResponseInfo* HttpStreamParser::GetResponseInfo() {
888 return response_; 888 return response_;
889 } 889 }
890 890
891 bool HttpStreamParser::IsResponseBodyComplete() const { 891 bool HttpStreamParser::IsResponseBodyComplete() const {
892 if (chunked_decoder_.get()) 892 if (chunked_decoder_.get())
893 return chunked_decoder_->reached_eof(); 893 return chunked_decoder_->reached_eof();
894 if (response_body_length_ != -1) 894 if (response_body_length_ != -1)
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 request_body->IsInMemory() && 969 request_body->IsInMemory() &&
970 request_body->size() > 0) { 970 request_body->size() > 0) {
971 size_t merged_size = request_headers.size() + request_body->size(); 971 size_t merged_size = request_headers.size() + request_body->size();
972 if (merged_size <= kMaxMergedHeaderAndBodySize) 972 if (merged_size <= kMaxMergedHeaderAndBodySize)
973 return true; 973 return true;
974 } 974 }
975 return false; 975 return false;
976 } 976 }
977 977
978 } // namespace net 978 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698