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

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

Issue 11364068: Add a QuicHttpStream class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move GetPeerAddress from QuicReliableClientStream to ReliableQuicStream 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
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_client_session.h" 5 #include "net/quic/quic_client_session.h"
6 6
7 #include "net/base/net_errors.h"
8
7 namespace net { 9 namespace net {
8 10
9 QuicClientSession::QuicClientSession(QuicConnection* connection) 11 QuicClientSession::QuicClientSession(QuicConnection* connection)
10 : QuicSession(connection, false), 12 : QuicSession(connection, false),
11 crypto_stream_(this) { 13 crypto_stream_(this) {
12 } 14 }
13 15
14 QuicClientSession::~QuicClientSession() { 16 QuicClientSession::~QuicClientSession() {
17 STLDeleteValues(&streams_);
15 } 18 }
16 19
17 QuicReliableClientStream* QuicClientSession::CreateOutgoingReliableStream() { 20 QuicReliableClientStream* QuicClientSession::CreateOutgoingReliableStream() {
18 if (!crypto_stream_.handshake_complete()) { 21 if (!crypto_stream_.handshake_complete()) {
19 DLOG(INFO) << "Crypto handshake not complete, no outgoing stream created."; 22 DLOG(INFO) << "Crypto handshake not complete, no outgoing stream created.";
20 return NULL; 23 return NULL;
21 } 24 }
22 if (GetNumOpenStreams() >= get_max_open_streams()) { 25 if (GetNumOpenStreams() >= get_max_open_streams()) {
23 DLOG(INFO) << "Failed to create a new outgoing stream. " 26 DLOG(INFO) << "Failed to create a new outgoing stream. "
24 << "Already " << GetNumOpenStreams() << " open."; 27 << "Already " << GetNumOpenStreams() << " open.";
25 return NULL; 28 return NULL;
26 } 29 }
27 QuicReliableClientStream* stream = 30 QuicReliableClientStream* stream =
28 new QuicReliableClientStream(GetNextStreamId(), this); 31 new QuicReliableClientStream(GetNextStreamId(), this);
32 streams_[stream->id()] = stream;
29 33
30 ActivateStream(stream); 34 ActivateStream(stream);
31 return stream; 35 return stream;
32 } 36 }
33 37
34 QuicCryptoClientStream* QuicClientSession::GetCryptoStream() { 38 QuicCryptoClientStream* QuicClientSession::GetCryptoStream() {
35 return &crypto_stream_; 39 return &crypto_stream_;
36 }; 40 };
37 41
38 void QuicClientSession::CryptoConnect() { 42 int QuicClientSession::CryptoConnect(const CompletionCallback& callback) {
39 CryptoHandshakeMessage message; 43 CryptoHandshakeMessage message;
40 message.tag = kCHLO; 44 message.tag = kCHLO;
41 crypto_stream_.SendHandshakeMessage(message); 45 crypto_stream_.SendHandshakeMessage(message);
46
47 if (IsCryptoHandshakeComplete()) {
48 return OK;
49 }
50
51 callback_ = callback;
52 return ERR_IO_PENDING;
42 } 53 }
43 54
44 ReliableQuicStream* QuicClientSession::CreateIncomingReliableStream( 55 ReliableQuicStream* QuicClientSession::CreateIncomingReliableStream(
45 QuicStreamId id) { 56 QuicStreamId id) {
46 DLOG(ERROR) << "Server push not supported"; 57 DLOG(ERROR) << "Server push not supported";
47 return NULL; 58 return NULL;
48 } 59 }
49 60
61 void QuicClientSession::CloseStream(QuicStreamId stream_id) {
62 QuicSession::CloseStream(stream_id);
63
64 StreamMap::iterator it = streams_.find(stream_id);
65 DCHECK(it != streams_.end());
66 if (it != streams_.end()) {
67 ReliableQuicStream* stream = it->second;
68 streams_.erase(it);
69 delete stream;
70 }
71 }
72
73 void QuicClientSession::OnCryptoHandshakeComplete(QuicErrorCode error) {
74 if (!callback_.is_null()) {
75 callback_.Run(error == QUIC_NO_ERROR ? OK : ERR_UNEXPECTED);
76 }
77 }
78
50 } // namespace net 79 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698