| Index: net/http/http_stream_parser.cc
|
| diff --git a/net/http/http_stream_parser.cc b/net/http/http_stream_parser.cc
|
| index 820c1ba008adec361627178b6e26e4f3c63a27d2..4b3449c7d67ce734ef8bd4cbd6bcc2474d65fcce 100644
|
| --- a/net/http/http_stream_parser.cc
|
| +++ b/net/http/http_stream_parser.cc
|
| @@ -110,23 +110,18 @@ bool ShouldTryReadingOnUploadError(int error_code) {
|
| class HttpStreamParser::SeekableIOBuffer : public IOBuffer {
|
| public:
|
| explicit SeekableIOBuffer(int capacity)
|
| - : IOBuffer(capacity),
|
| - real_data_(data_),
|
| - capacity_(capacity),
|
| - size_(0),
|
| - used_(0) {
|
| - }
|
| + : IOBuffer(capacity),
|
| + real_data_(data_),
|
| + capacity_(capacity),
|
| + size_(0),
|
| + used_(0) {}
|
|
|
| // DidConsume() changes the |data_| pointer so that |data_| always points
|
| // to the first unconsumed byte.
|
| - void DidConsume(int bytes) {
|
| - SetOffset(used_ + bytes);
|
| - }
|
| + void DidConsume(int bytes) { SetOffset(used_ + bytes); }
|
|
|
| // Returns the number of unconsumed bytes.
|
| - int BytesRemaining() const {
|
| - return size_ - used_;
|
| - }
|
| + int BytesRemaining() const { return size_ - used_; }
|
|
|
| // Seeks to an arbitrary point in the buffer. The notion of bytes consumed
|
| // and remaining are updated appropriately.
|
| @@ -158,7 +153,9 @@ class HttpStreamParser::SeekableIOBuffer : public IOBuffer {
|
|
|
| // Returns the capacity of the buffer. The capacity is the size used when
|
| // the object is created.
|
| - int capacity() const { return capacity_; };
|
| + int capacity() const {
|
| + return capacity_;
|
| + };
|
|
|
| private:
|
| virtual ~SeekableIOBuffer() {
|
| @@ -212,11 +209,10 @@ int HttpStreamParser::SendRequest(const std::string& request_line,
|
| DCHECK(!callback.is_null());
|
| DCHECK(response);
|
|
|
| - net_log_.AddEvent(
|
| - NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS,
|
| - base::Bind(&HttpRequestHeaders::NetLogCallback,
|
| - base::Unretained(&headers),
|
| - &request_line));
|
| + net_log_.AddEvent(NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS,
|
| + base::Bind(&HttpRequestHeaders::NetLogCallback,
|
| + base::Unretained(&headers),
|
| + &request_line));
|
|
|
| DVLOG(1) << __FUNCTION__ << "()"
|
| << " request_line = \"" << request_line << "\""
|
| @@ -266,8 +262,8 @@ int HttpStreamParser::SendRequest(const std::string& request_line,
|
|
|
| size_t todo = request_->upload_data_stream->size();
|
| while (todo) {
|
| - int consumed = request_->upload_data_stream
|
| - ->Read(request_headers_.get(), todo, CompletionCallback());
|
| + int consumed = request_->upload_data_stream->Read(
|
| + request_headers_.get(), todo, CompletionCallback());
|
| DCHECK_GT(consumed, 0); // Read() won't fail if not chunked.
|
| request_headers_->DidConsume(consumed);
|
| todo -= consumed;
|
| @@ -277,12 +273,11 @@ int HttpStreamParser::SendRequest(const std::string& request_line,
|
| request_headers_->SetOffset(0);
|
| did_merge = true;
|
|
|
| - net_log_.AddEvent(
|
| - NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_BODY,
|
| - base::Bind(&NetLogSendRequestBodyCallback,
|
| - request_->upload_data_stream->size(),
|
| - false, /* not chunked */
|
| - true /* merged */));
|
| + net_log_.AddEvent(NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_BODY,
|
| + base::Bind(&NetLogSendRequestBodyCallback,
|
| + request_->upload_data_stream->size(),
|
| + false, /* not chunked */
|
| + true /* merged */));
|
| }
|
|
|
| if (!did_merge) {
|
| @@ -335,7 +330,8 @@ void HttpStreamParser::Close(bool not_reusable) {
|
| connection_->Reset();
|
| }
|
|
|
| -int HttpStreamParser::ReadResponseBody(IOBuffer* buf, int buf_len,
|
| +int HttpStreamParser::ReadResponseBody(IOBuffer* buf,
|
| + int buf_len,
|
| const CompletionCallback& callback) {
|
| DCHECK(io_state_ == STATE_NONE || io_state_ == STATE_DONE);
|
| DCHECK(callback_.is_null());
|
| @@ -433,8 +429,8 @@ int HttpStreamParser::DoSendHeaders() {
|
| response_->request_time = base::Time::Now();
|
|
|
| io_state_ = STATE_SEND_HEADERS_COMPLETE;
|
| - return connection_->socket()
|
| - ->Write(request_headers_.get(), bytes_remaining, io_callback_);
|
| + return connection_->socket()->Write(
|
| + request_headers_.get(), bytes_remaining, io_callback_);
|
| }
|
|
|
| int HttpStreamParser::DoSendHeadersComplete(int result) {
|
| @@ -459,15 +455,14 @@ int HttpStreamParser::DoSendHeadersComplete(int result) {
|
|
|
| if (request_->upload_data_stream != NULL &&
|
| (request_->upload_data_stream->is_chunked() ||
|
| - // !IsEOF() indicates that the body wasn't merged.
|
| - (request_->upload_data_stream->size() > 0 &&
|
| + // !IsEOF() indicates that the body wasn't merged.
|
| + (request_->upload_data_stream->size() > 0 &&
|
| !request_->upload_data_stream->IsEOF()))) {
|
| - net_log_.AddEvent(
|
| - NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_BODY,
|
| - base::Bind(&NetLogSendRequestBodyCallback,
|
| - request_->upload_data_stream->size(),
|
| - request_->upload_data_stream->is_chunked(),
|
| - false /* not merged */));
|
| + net_log_.AddEvent(NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_BODY,
|
| + base::Bind(&NetLogSendRequestBodyCallback,
|
| + request_->upload_data_stream->size(),
|
| + request_->upload_data_stream->is_chunked(),
|
| + false /* not merged */));
|
| io_state_ = STATE_SEND_BODY;
|
| return OK;
|
| }
|
| @@ -479,10 +474,10 @@ int HttpStreamParser::DoSendHeadersComplete(int result) {
|
| int HttpStreamParser::DoSendBody() {
|
| if (request_body_send_buf_->BytesRemaining() > 0) {
|
| io_state_ = STATE_SEND_BODY_COMPLETE;
|
| - return connection_->socket()
|
| - ->Write(request_body_send_buf_.get(),
|
| - request_body_send_buf_->BytesRemaining(),
|
| - io_callback_);
|
| + return connection_->socket()->Write(
|
| + request_body_send_buf_.get(),
|
| + request_body_send_buf_->BytesRemaining(),
|
| + io_callback_);
|
| }
|
|
|
| if (request_->upload_data_stream->is_chunked() && sent_last_chunk_) {
|
| @@ -558,8 +553,8 @@ int HttpStreamParser::DoReadHeaders() {
|
| // See if the user is passing in an IOBuffer with a NULL |data_|.
|
| CHECK(read_buf_->data());
|
|
|
| - return connection_->socket()
|
| - ->Read(read_buf_.get(), read_buf_->RemainingCapacity(), io_callback_);
|
| + return connection_->socket()->Read(
|
| + read_buf_.get(), read_buf_->RemainingCapacity(), io_callback_);
|
| }
|
|
|
| int HttpStreamParser::DoReadHeadersComplete(int result) {
|
| @@ -638,8 +633,8 @@ int HttpStreamParser::DoReadBody() {
|
| return 0;
|
|
|
| DCHECK_EQ(0, read_buf_->offset());
|
| - return connection_->socket()
|
| - ->Read(user_read_buf_.get(), user_read_buf_len_, io_callback_);
|
| + return connection_->socket()->Read(
|
| + user_read_buf_.get(), user_read_buf_len_, io_callback_);
|
| }
|
|
|
| int HttpStreamParser::DoReadBodyComplete(int result) {
|
| @@ -723,7 +718,8 @@ int HttpStreamParser::DoReadBodyComplete(int result) {
|
|
|
| if (save_amount) {
|
| received_bytes_ -= save_amount;
|
| - memcpy(read_buf_->StartOfBuffer(), user_read_buf_->data() + result,
|
| + memcpy(read_buf_->StartOfBuffer(),
|
| + user_read_buf_->data() + result,
|
| save_amount);
|
| }
|
| read_buf_->set_offset(save_amount);
|
| @@ -797,7 +793,7 @@ int HttpStreamParser::HandleReadHeaderResult(int result) {
|
|
|
| read_buf_->set_offset(read_buf_->offset() + result);
|
| DCHECK_LE(read_buf_->offset(), read_buf_->capacity());
|
| - DCHECK_GE(result, 0);
|
| + DCHECK_GE(result, 0);
|
|
|
| int end_of_header_offset = ParseResponseHeaders();
|
|
|
| @@ -885,8 +881,8 @@ int HttpStreamParser::DoParseResponseHeaders(int end_offset) {
|
|
|
| if (response_header_start_offset_ >= 0) {
|
| received_bytes_ += end_offset;
|
| - headers = new HttpResponseHeaders(HttpUtil::AssembleRawHeaders(
|
| - read_buf_->StartOfBuffer(), end_offset));
|
| + headers = new HttpResponseHeaders(
|
| + HttpUtil::AssembleRawHeaders(read_buf_->StartOfBuffer(), end_offset));
|
| } else {
|
| // Enough data was read -- there is no status line.
|
| headers = new HttpResponseHeaders(std::string("HTTP/0.9 200 OK"));
|
| @@ -1027,9 +1023,8 @@ int HttpStreamParser::EncodeChunk(const base::StringPiece& payload,
|
|
|
| char* cursor = output;
|
| // Add the header.
|
| - const int num_chars = base::snprintf(output, output_size,
|
| - "%X\r\n",
|
| - static_cast<int>(payload.size()));
|
| + const int num_chars = base::snprintf(
|
| + output, output_size, "%X\r\n", static_cast<int>(payload.size()));
|
| cursor += num_chars;
|
| // Add the payload if any.
|
| if (payload.size() > 0) {
|
|
|