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

Side by Side Diff: net/quic/quic_reliable_client_stream.cc

Issue 11364068: Add a QuicHttpStream class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: NET_EXPORT_PRIVATE Created 8 years 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/quic/quic_reliable_client_stream.h ('k') | net/quic/quic_reliable_client_stream_test.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/quic/quic_reliable_client_stream.h" 5 #include "net/quic/quic_reliable_client_stream.h"
6 6
7 #include "net/base/net_errors.h" 7 #include "net/base/net_errors.h"
8 #include "net/quic/quic_session.h"
8 9
9 namespace net { 10 namespace net {
10 11
11 QuicReliableClientStream::QuicReliableClientStream(QuicStreamId id, 12 QuicReliableClientStream::QuicReliableClientStream(QuicStreamId id,
12 QuicSession* session) 13 QuicSession* session)
13 : ReliableQuicStream(id, session) { 14 : ReliableQuicStream(id, session),
15 delegate_(NULL) {
14 } 16 }
15 17
16 QuicReliableClientStream::~QuicReliableClientStream() { 18 QuicReliableClientStream::~QuicReliableClientStream() {
19 if (delegate_) {
20 delegate_->OnClose(error());
21 }
17 } 22 }
18 23
19 uint32 QuicReliableClientStream::ProcessData(const char* data, 24 uint32 QuicReliableClientStream::ProcessData(const char* data,
20 uint32 data_len) { 25 uint32 data_len) {
26 // TODO(rch): buffer data if we don't have a delegate.
27 DCHECK(delegate_);
21 int rv = delegate_->OnDataReceived(data, data_len); 28 int rv = delegate_->OnDataReceived(data, data_len);
22 if (rv != OK) { 29 if (rv != OK) {
23 DLOG(ERROR) << "Delegate refused data, rv: " << rv; 30 DLOG(ERROR) << "Delegate refused data, rv: " << rv;
24 Close(QUIC_BAD_APPLICATION_PAYLOAD); 31 Close(QUIC_BAD_APPLICATION_PAYLOAD);
25 return 0; 32 return 0;
26 } 33 }
27 return data_len; 34 return data_len;
28 } 35 }
29 36
30 void QuicReliableClientStream::TerminateFromPeer(bool half_close) { 37 void QuicReliableClientStream::TerminateFromPeer(bool half_close) {
31 delegate_->OnClose(error()); 38 if (delegate_) {
39 delegate_->OnClose(error());
40 delegate_ = NULL;
41 }
32 } 42 }
33 43
34 void QuicReliableClientStream::SetDelegate( 44 void QuicReliableClientStream::SetDelegate(
35 QuicReliableClientStream::Delegate* delegate) { 45 QuicReliableClientStream::Delegate* delegate) {
46 DCHECK((!delegate_ && delegate) || (delegate_ && !delegate));
36 delegate_ = delegate; 47 delegate_ = delegate;
37 } 48 }
38 49
39 } // namespace net 50 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_reliable_client_stream.h ('k') | net/quic/quic_reliable_client_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698