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

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

Issue 17382012: [SPDY] Refactor SpdyStream's handling of response headers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More updates from rebase Created 7 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 | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_proxy_client_socket.h ('k') | net/spdy/spdy_session.h » ('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_proxy_client_socket.h" 5 #include "net/spdy/spdy_proxy_client_socket.h"
6 6
7 #include <algorithm> // min 7 #include <algorithm> // min
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 432
433 // SpdyStream::Delegate methods: 433 // SpdyStream::Delegate methods:
434 // Called when SYN frame has been sent. 434 // Called when SYN frame has been sent.
435 // Returns true if no more data to be sent after SYN frame. 435 // Returns true if no more data to be sent after SYN frame.
436 void SpdyProxyClientSocket::OnRequestHeadersSent() { 436 void SpdyProxyClientSocket::OnRequestHeadersSent() {
437 DCHECK_EQ(next_state_, STATE_SEND_REQUEST_COMPLETE); 437 DCHECK_EQ(next_state_, STATE_SEND_REQUEST_COMPLETE);
438 438
439 OnIOComplete(OK); 439 OnIOComplete(OK);
440 } 440 }
441 441
442 int SpdyProxyClientSocket::OnResponseHeadersReceived( 442 SpdyResponseHeadersStatus SpdyProxyClientSocket::OnResponseHeadersUpdated(
443 const SpdyHeaderBlock& response, 443 const SpdyHeaderBlock& response_headers) {
444 base::Time response_time,
445 int status) {
446 // If we've already received the reply, existing headers are too late. 444 // If we've already received the reply, existing headers are too late.
447 // TODO(mbelshe): figure out a way to make HEADERS frames useful after the 445 // TODO(mbelshe): figure out a way to make HEADERS frames useful after the
448 // initial response. 446 // initial response.
449 if (next_state_ != STATE_READ_REPLY_COMPLETE) 447 if (next_state_ != STATE_READ_REPLY_COMPLETE)
450 return OK; 448 return RESPONSE_HEADERS_ARE_COMPLETE;
451 449
452 // Save the response 450 // Save the response
453 if (!SpdyHeadersToHttpResponse( 451 if (!SpdyHeadersToHttpResponse(
454 response, spdy_stream_->GetProtocolVersion(), &response_)) 452 response_headers, spdy_stream_->GetProtocolVersion(), &response_))
455 return ERR_INCOMPLETE_SPDY_HEADERS; 453 return RESPONSE_HEADERS_ARE_INCOMPLETE;
456 454
457 OnIOComplete(status); 455 OnIOComplete(OK);
458 return OK; 456 return RESPONSE_HEADERS_ARE_COMPLETE;
459 } 457 }
460 458
461 // Called when data is received or on EOF (if |buffer| is NULL). 459 // Called when data is received or on EOF (if |buffer| is NULL).
462 int SpdyProxyClientSocket::OnDataReceived(scoped_ptr<SpdyBuffer> buffer) { 460 void SpdyProxyClientSocket::OnDataReceived(scoped_ptr<SpdyBuffer> buffer) {
463 if (buffer) { 461 if (buffer) {
464 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_RECEIVED, 462 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_RECEIVED,
465 buffer->GetRemainingSize(), 463 buffer->GetRemainingSize(),
466 buffer->GetRemainingData()); 464 buffer->GetRemainingData());
467 read_buffer_queue_.Enqueue(buffer.Pass()); 465 read_buffer_queue_.Enqueue(buffer.Pass());
468 } else { 466 } else {
469 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_RECEIVED, 0, NULL); 467 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_RECEIVED, 0, NULL);
470 } 468 }
471 469
472 if (!read_callback_.is_null()) { 470 if (!read_callback_.is_null()) {
473 int rv = PopulateUserReadBuffer(user_buffer_->data(), user_buffer_len_); 471 int rv = PopulateUserReadBuffer(user_buffer_->data(), user_buffer_len_);
474 CompletionCallback c = read_callback_; 472 CompletionCallback c = read_callback_;
475 read_callback_.Reset(); 473 read_callback_.Reset();
476 user_buffer_ = NULL; 474 user_buffer_ = NULL;
477 user_buffer_len_ = 0; 475 user_buffer_len_ = 0;
478 c.Run(rv); 476 c.Run(rv);
479 } 477 }
480 return OK;
481 } 478 }
482 479
483 void SpdyProxyClientSocket::OnDataSent() { 480 void SpdyProxyClientSocket::OnDataSent() {
484 DCHECK(!write_callback_.is_null()); 481 DCHECK(!write_callback_.is_null());
485 482
486 int rv = write_buffer_len_; 483 int rv = write_buffer_len_;
487 write_buffer_len_ = 0; 484 write_buffer_len_ = 0;
488 ResetAndReturn(&write_callback_).Run(rv); 485 ResetAndReturn(&write_callback_).Run(rv);
489 } 486 }
490 487
(...skipping 23 matching lines...) Expand all
514 } else if (!read_callback_.is_null()) { 511 } else if (!read_callback_.is_null()) {
515 // If we have a read_callback_, the we need to make sure we call it back. 512 // If we have a read_callback_, the we need to make sure we call it back.
516 OnDataReceived(scoped_ptr<SpdyBuffer>()); 513 OnDataReceived(scoped_ptr<SpdyBuffer>());
517 } 514 }
518 // This may have been deleted by read_callback_, so check first. 515 // This may have been deleted by read_callback_, so check first.
519 if (weak_ptr.get() && !write_callback.is_null()) 516 if (weak_ptr.get() && !write_callback.is_null())
520 write_callback.Run(ERR_CONNECTION_CLOSED); 517 write_callback.Run(ERR_CONNECTION_CLOSED);
521 } 518 }
522 519
523 } // namespace net 520 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_proxy_client_socket.h ('k') | net/spdy/spdy_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698