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

Side by Side Diff: net/spdy/spdy_http_stream.cc

Issue 2022053002: Introduce error handling in SpdyHttpStream on UploadDataStream::Read() failure. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments + moving ReadErrorUploadDataStream back to unnamed naspace Created 4 years, 6 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
« no previous file with comments | « net/spdy/spdy_http_stream.h ('k') | net/spdy/spdy_http_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/spdy/spdy_http_stream.h" 5 #include "net/spdy/spdy_http_stream.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <list> 8 #include <list>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 return; 446 return;
447 } 447 }
448 448
449 // Read the data from the request body stream. 449 // Read the data from the request body stream.
450 const int rv = request_info_->upload_data_stream 450 const int rv = request_info_->upload_data_stream
451 ->Read(request_body_buf_.get(), 451 ->Read(request_body_buf_.get(),
452 request_body_buf_->size(), 452 request_body_buf_->size(),
453 base::Bind(&SpdyHttpStream::OnRequestBodyReadCompleted, 453 base::Bind(&SpdyHttpStream::OnRequestBodyReadCompleted,
454 weak_factory_.GetWeakPtr())); 454 weak_factory_.GetWeakPtr()));
455 455
456 if (rv != ERR_IO_PENDING) { 456 if (rv != ERR_IO_PENDING)
457 // ERR_IO_PENDING is the only possible error.
458 CHECK_GE(rv, 0);
459 OnRequestBodyReadCompleted(rv); 457 OnRequestBodyReadCompleted(rv);
460 } 458 }
459
460 void SpdyHttpStream::ResetStreamInternal() {
461 spdy_session_->ResetStream(stream()->stream_id(), RST_STREAM_INTERNAL_ERROR,
462 std::string());
461 } 463 }
462 464
463 void SpdyHttpStream::OnRequestBodyReadCompleted(int status) { 465 void SpdyHttpStream::OnRequestBodyReadCompleted(int status) {
466 if (status < 0) {
467 DCHECK_NE(ERR_IO_PENDING, status);
468 base::ThreadTaskRunnerHandle::Get()->PostTask(
469 FROM_HERE, base::Bind(&SpdyHttpStream::ResetStreamInternal,
470 weak_factory_.GetWeakPtr()));
471
472 // Call the |request_callback| with received error.
473 if (!request_callback_.is_null())
474 DoRequestCallback(status);
475 return;
476 }
477
464 CHECK_GE(status, 0); 478 CHECK_GE(status, 0);
465 request_body_buf_size_ = status; 479 request_body_buf_size_ = status;
466 const bool eof = request_info_->upload_data_stream->IsEOF(); 480 const bool eof = request_info_->upload_data_stream->IsEOF();
467 // Only the final frame may have a length of 0. 481 // Only the final frame may have a length of 0.
468 if (eof) { 482 if (eof) {
469 CHECK_GE(request_body_buf_size_, 0); 483 CHECK_GE(request_body_buf_size_, 0);
470 // Call the cb only after all data is sent. 484 // Call the cb only after all data is sent.
471 if (!request_callback_.is_null()) 485 if (!request_callback_.is_null())
472 DoRequestCallback(OK); 486 DoRequestCallback(OK);
473 } else { 487 } else {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 details->connection_info = HttpResponseInfo::CONNECTION_INFO_HTTP2; 606 details->connection_info = HttpResponseInfo::CONNECTION_INFO_HTTP2;
593 return; 607 return;
594 } 608 }
595 609
596 void SpdyHttpStream::SetPriority(RequestPriority priority) { 610 void SpdyHttpStream::SetPriority(RequestPriority priority) {
597 // TODO(akalin): Plumb this through to |stream_request_| and 611 // TODO(akalin): Plumb this through to |stream_request_| and
598 // |stream_|. 612 // |stream_|.
599 } 613 }
600 614
601 } // namespace net 615 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_http_stream.h ('k') | net/spdy/spdy_http_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698