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

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

Issue 15936003: [SPDY] Refactor SpdyStream::Delegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 return read_buffer_queue_.Dequeue(data, len); 219 return read_buffer_queue_.Dequeue(data, len);
220 } 220 }
221 221
222 int SpdyProxyClientSocket::Write(IOBuffer* buf, int buf_len, 222 int SpdyProxyClientSocket::Write(IOBuffer* buf, int buf_len,
223 const CompletionCallback& callback) { 223 const CompletionCallback& callback) {
224 DCHECK(write_callback_.is_null()); 224 DCHECK(write_callback_.is_null());
225 if (next_state_ != STATE_OPEN) 225 if (next_state_ != STATE_OPEN)
226 return ERR_SOCKET_NOT_CONNECTED; 226 return ERR_SOCKET_NOT_CONNECTED;
227 227
228 DCHECK(spdy_stream_); 228 DCHECK(spdy_stream_);
229 spdy_stream_->SendStreamData(buf, buf_len, MORE_DATA_TO_SEND); 229 spdy_stream_->SendData(buf, buf_len, MORE_DATA_TO_SEND);
230 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_SENT, 230 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_SENT,
231 buf_len, buf->data()); 231 buf_len, buf->data());
232 write_callback_ = callback; 232 write_callback_ = callback;
233 write_buffer_len_ = buf_len; 233 write_buffer_len_ = buf_len;
234 return ERR_IO_PENDING; 234 return ERR_IO_PENDING;
235 } 235 }
236 236
237 bool SpdyProxyClientSocket::SetReceiveBufferSize(int32 size) { 237 bool SpdyProxyClientSocket::SetReceiveBufferSize(int32 size) {
238 // Since this StreamSocket sits on top of a shared SpdySession, it 238 // Since this StreamSocket sits on top of a shared SpdySession, it
239 // is not safe for callers to set change this underlying socket. 239 // is not safe for callers to set change this underlying socket.
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 // Ignore response to avoid letting the proxy impersonate the target 428 // Ignore response to avoid letting the proxy impersonate the target
429 // server. (See http://crbug.com/137891.) 429 // server. (See http://crbug.com/137891.)
430 LogBlockedTunnelResponse(); 430 LogBlockedTunnelResponse();
431 return ERR_TUNNEL_CONNECTION_FAILED; 431 return ERR_TUNNEL_CONNECTION_FAILED;
432 } 432 }
433 } 433 }
434 434
435 // SpdyStream::Delegate methods: 435 // SpdyStream::Delegate methods:
436 // Called when SYN frame has been sent. 436 // Called when SYN frame has been sent.
437 // Returns true if no more data to be sent after SYN frame. 437 // Returns true if no more data to be sent after SYN frame.
438 void SpdyProxyClientSocket::OnSendRequestHeadersComplete() { 438 void SpdyProxyClientSocket::OnRequestHeadersSent() {
439 DCHECK_EQ(next_state_, STATE_SEND_REQUEST_COMPLETE); 439 DCHECK_EQ(next_state_, STATE_SEND_REQUEST_COMPLETE);
440 440
441 OnIOComplete(OK); 441 OnIOComplete(OK);
442 } 442 }
443 443
444 void SpdyProxyClientSocket::OnSendBody() { 444 int SpdyProxyClientSocket::OnResponseHeadersReceived(
445 // Because we use |spdy_stream_| via STATE_OPEN (ala WebSockets)
446 // OnSendBody() must never be called.
447 CHECK(false);
448 }
449
450 void SpdyProxyClientSocket::OnSendBodyComplete() {
451 // Because we use |spdy_stream_| via STATE_OPEN (ala WebSockets)
452 // OnSendBodyComplete() must never be called.
453 CHECK(false);
Ryan Hamilton 2013/05/28 21:57:13 YES!!!
454 }
455
456 int SpdyProxyClientSocket::OnResponseReceived(
457 const SpdyHeaderBlock& response, 445 const SpdyHeaderBlock& response,
458 base::Time response_time, 446 base::Time response_time,
459 int status) { 447 int status) {
460 // If we've already received the reply, existing headers are too late. 448 // If we've already received the reply, existing headers are too late.
461 // TODO(mbelshe): figure out a way to make HEADERS frames useful after the 449 // TODO(mbelshe): figure out a way to make HEADERS frames useful after the
462 // initial response. 450 // initial response.
463 if (next_state_ != STATE_READ_REPLY_COMPLETE) 451 if (next_state_ != STATE_READ_REPLY_COMPLETE)
464 return OK; 452 return OK;
465 453
466 // Save the response 454 // Save the response
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 } else if (!read_callback_.is_null()) { 516 } else if (!read_callback_.is_null()) {
529 // If we have a read_callback_, the we need to make sure we call it back. 517 // If we have a read_callback_, the we need to make sure we call it back.
530 OnDataReceived(scoped_ptr<SpdyBuffer>()); 518 OnDataReceived(scoped_ptr<SpdyBuffer>());
531 } 519 }
532 // This may have been deleted by read_callback_, so check first. 520 // This may have been deleted by read_callback_, so check first.
533 if (weak_ptr && !write_callback.is_null()) 521 if (weak_ptr && !write_callback.is_null())
534 write_callback.Run(ERR_CONNECTION_CLOSED); 522 write_callback.Run(ERR_CONNECTION_CLOSED);
535 } 523 }
536 524
537 } // namespace net 525 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698