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

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

Issue 10836084: SPDY - Handle incomplete headers during server push. (Closed) Base URL: svn://chrome-svn/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 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/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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 // Save the response 482 // Save the response
483 if (!SpdyHeadersToHttpResponse( 483 if (!SpdyHeadersToHttpResponse(
484 response, spdy_stream_->GetProtocolVersion(), &response_)) 484 response, spdy_stream_->GetProtocolVersion(), &response_))
485 return ERR_INCOMPLETE_SPDY_HEADERS; 485 return ERR_INCOMPLETE_SPDY_HEADERS;
486 486
487 OnIOComplete(status); 487 OnIOComplete(status);
488 return OK; 488 return OK;
489 } 489 }
490 490
491 // Called when data is received. 491 // Called when data is received.
492 void SpdyProxyClientSocket::OnDataReceived(const char* data, int length) { 492 int SpdyProxyClientSocket::OnDataReceived(const char* data, int length) {
493 if (length > 0) { 493 if (length > 0) {
494 // Save the received data. 494 // Save the received data.
495 scoped_refptr<IOBuffer> io_buffer(new IOBuffer(length)); 495 scoped_refptr<IOBuffer> io_buffer(new IOBuffer(length));
496 memcpy(io_buffer->data(), data, length); 496 memcpy(io_buffer->data(), data, length);
497 read_buffer_.push_back( 497 read_buffer_.push_back(
498 make_scoped_refptr(new DrainableIOBuffer(io_buffer, length))); 498 make_scoped_refptr(new DrainableIOBuffer(io_buffer, length)));
499 } 499 }
500 500
501 if (!read_callback_.is_null()) { 501 if (!read_callback_.is_null()) {
502 int rv = PopulateUserReadBuffer(); 502 int rv = PopulateUserReadBuffer();
503 CompletionCallback c = read_callback_; 503 CompletionCallback c = read_callback_;
504 read_callback_.Reset(); 504 read_callback_.Reset();
505 user_buffer_ = NULL; 505 user_buffer_ = NULL;
506 c.Run(rv); 506 c.Run(rv);
507 } 507 }
508 return OK;
508 } 509 }
509 510
510 void SpdyProxyClientSocket::OnDataSent(int length) { 511 void SpdyProxyClientSocket::OnDataSent(int length) {
511 DCHECK(!write_callback_.is_null()); 512 DCHECK(!write_callback_.is_null());
512 513
513 write_bytes_outstanding_ -= length; 514 write_bytes_outstanding_ -= length;
514 515
515 DCHECK_GE(write_bytes_outstanding_, 0); 516 DCHECK_GE(write_bytes_outstanding_, 0);
516 517
517 if (write_bytes_outstanding_ == 0) { 518 if (write_bytes_outstanding_ == 0) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 } else if (!read_callback_.is_null()) { 553 } else if (!read_callback_.is_null()) {
553 // If we have a read_callback_, the we need to make sure we call it back. 554 // If we have a read_callback_, the we need to make sure we call it back.
554 OnDataReceived(NULL, 0); 555 OnDataReceived(NULL, 0);
555 } 556 }
556 // This may have been deleted by read_callback_, so check first. 557 // This may have been deleted by read_callback_, so check first.
557 if (weak_ptr && !write_callback.is_null()) 558 if (weak_ptr && !write_callback.is_null())
558 write_callback.Run(ERR_CONNECTION_CLOSED); 559 write_callback.Run(ERR_CONNECTION_CLOSED);
559 } 560 }
560 561
561 } // namespace net 562 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698