blob: bea957c86bf7c02ef6f786f6ad4b6aaf1ec12331 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/tools/quic/quic_server_session.h"
#include "base/logging.h"
#include "net/quic/reliable_quic_stream.h"
#include "net/tools/quic/quic_spdy_server_stream.h"
namespace net {
namespace tools {
QuicServerSession::QuicServerSession(
const QuicConfig& config,
QuicConnection* connection,
QuicSessionOwner* owner)
: QuicSession(connection, config, true),
owner_(owner) {
}
QuicServerSession::~QuicServerSession() {
}
void QuicServerSession::InitializeSession(
const QuicCryptoServerConfig& crypto_config) {
crypto_stream_.reset(CreateQuicCryptoServerStream(crypto_config));
}
QuicCryptoServerStream* QuicServerSession::CreateQuicCryptoServerStream(
const QuicCryptoServerConfig& crypto_config) {
return new QuicCryptoServerStream(crypto_config, this);
}
void QuicServerSession::OnConnectionClosed(QuicErrorCode error,
bool from_peer) {
QuicSession::OnConnectionClosed(error, from_peer);
owner_->OnConnectionClosed(connection()->guid(), error);
}
bool QuicServerSession::ShouldCreateIncomingReliableStream(QuicStreamId id) {
if (id % 2 == 0) {
DLOG(INFO) << "Invalid incoming even stream_id:" << id;
connection()->SendConnectionClose(QUIC_INVALID_STREAM_ID);
return false;
}
if (GetNumOpenStreams() >= get_max_open_streams()) {
DLOG(INFO) << "Failed to create a new incoming stream with id:" << id
<< " Already " << GetNumOpenStreams() << " open.";
connection()->SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS);
return false;
}
return true;
}
ReliableQuicStream* QuicServerSession::CreateIncomingReliableStream(
QuicStreamId id) {
if (!ShouldCreateIncomingReliableStream(id)) {
return NULL;
}
return new QuicSpdyServerStream(id, this);
}
ReliableQuicStream* QuicServerSession::CreateOutgoingReliableStream() {
DLOG(ERROR) << "Server push not yet supported";
return NULL;
}
QuicCryptoServerStream* QuicServerSession::GetCryptoStream() {
return crypto_stream_.get();
}
} // namespace tools
} // namespace net
|