OLD | NEW |
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/tools/quic/quic_simple_dispatcher.h" | 5 #include "net/tools/quic/quic_simple_dispatcher.h" |
6 | 6 |
7 #include "net/tools/quic/quic_simple_server_session.h" | 7 #include "net/tools/quic/quic_simple_server_session.h" |
8 | 8 |
9 namespace net { | 9 namespace net { |
10 | 10 |
11 QuicSimpleDispatcher::QuicSimpleDispatcher( | 11 QuicSimpleDispatcher::QuicSimpleDispatcher( |
12 const QuicConfig& config, | 12 const QuicConfig& config, |
13 const QuicCryptoServerConfig* crypto_config, | 13 const QuicCryptoServerConfig* crypto_config, |
14 QuicVersionManager* version_manager, | 14 QuicVersionManager* version_manager, |
15 std::unique_ptr<QuicConnectionHelperInterface> helper, | 15 std::unique_ptr<QuicConnectionHelperInterface> helper, |
16 std::unique_ptr<QuicCryptoServerStream::Helper> session_helper, | 16 std::unique_ptr<QuicCryptoServerStream::Helper> session_helper, |
17 std::unique_ptr<QuicAlarmFactory> alarm_factory, | 17 std::unique_ptr<QuicAlarmFactory> alarm_factory, |
18 QuicHttpResponseCache* response_cache) | 18 QuicHttpResponseCache* response_cache) |
19 : QuicDispatcher(config, | 19 : QuicDispatcher(config, |
20 crypto_config, | 20 crypto_config, |
21 version_manager, | 21 version_manager, |
22 std::move(helper), | 22 std::move(helper), |
23 std::move(session_helper), | 23 std::move(session_helper), |
24 std::move(alarm_factory)), | 24 std::move(alarm_factory)), |
| 25 push_promise_sent_(0), |
25 response_cache_(response_cache) {} | 26 response_cache_(response_cache) {} |
26 | 27 |
27 QuicSimpleDispatcher::~QuicSimpleDispatcher() {} | 28 QuicSimpleDispatcher::~QuicSimpleDispatcher() {} |
28 | 29 |
29 int QuicSimpleDispatcher::GetRstErrorCount( | 30 int QuicSimpleDispatcher::GetRstErrorCount( |
30 QuicRstStreamErrorCode error_code) const { | 31 QuicRstStreamErrorCode error_code) const { |
31 auto it = rst_error_map_.find(error_code); | 32 auto it = rst_error_map_.find(error_code); |
32 if (it == rst_error_map_.end()) { | 33 if (it == rst_error_map_.end()) { |
33 return 0; | 34 return 0; |
34 } else { | 35 } else { |
35 return it->second; | 36 return it->second; |
36 } | 37 } |
37 } | 38 } |
38 | 39 |
39 void QuicSimpleDispatcher::OnRstStreamReceived( | 40 void QuicSimpleDispatcher::OnRstStreamReceived( |
40 const QuicRstStreamFrame& frame) { | 41 const QuicRstStreamFrame& frame) { |
41 auto it = rst_error_map_.find(frame.error_code); | 42 auto it = rst_error_map_.find(frame.error_code); |
42 if (it == rst_error_map_.end()) { | 43 if (it == rst_error_map_.end()) { |
43 rst_error_map_.insert(std::make_pair(frame.error_code, 1)); | 44 rst_error_map_.insert(std::make_pair(frame.error_code, 1)); |
44 } else { | 45 } else { |
45 it->second++; | 46 it->second++; |
46 } | 47 } |
47 } | 48 } |
48 | 49 |
| 50 void QuicSimpleDispatcher::OnPushPromiseSent() { |
| 51 push_promise_sent_++; |
| 52 } |
| 53 |
49 QuicServerSessionBase* QuicSimpleDispatcher::CreateQuicSession( | 54 QuicServerSessionBase* QuicSimpleDispatcher::CreateQuicSession( |
50 QuicConnectionId connection_id, | 55 QuicConnectionId connection_id, |
51 const QuicSocketAddress& client_address) { | 56 const QuicSocketAddress& client_address) { |
52 // The QuicServerSessionBase takes ownership of |connection| below. | 57 // The QuicServerSessionBase takes ownership of |connection| below. |
53 QuicConnection* connection = new QuicConnection( | 58 QuicConnection* connection = new QuicConnection( |
54 connection_id, client_address, helper(), alarm_factory(), | 59 connection_id, client_address, helper(), alarm_factory(), |
55 CreatePerConnectionWriter(), | 60 CreatePerConnectionWriter(), |
56 /* owns_writer= */ true, Perspective::IS_SERVER, GetSupportedVersions()); | 61 /* owns_writer= */ true, Perspective::IS_SERVER, GetSupportedVersions()); |
57 | 62 |
58 QuicServerSessionBase* session = new QuicSimpleServerSession( | 63 QuicServerSessionBase* session = new QuicSimpleServerSession( |
59 config(), connection, this, session_helper(), crypto_config(), | 64 config(), connection, this, session_helper(), crypto_config(), |
60 compressed_certs_cache(), response_cache_); | 65 compressed_certs_cache(), response_cache_); |
61 session->Initialize(); | 66 session->Initialize(); |
62 return session; | 67 return session; |
63 } | 68 } |
64 | 69 |
65 } // namespace net | 70 } // namespace net |
OLD | NEW |