| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_server.h" | 5 #include "net/tools/quic/quic_simple_server.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 const char kSourceAddressTokenSecret[] = "secret"; | 29 const char kSourceAddressTokenSecret[] = "secret"; |
| 30 | 30 |
| 31 // Allocate some extra space so we can send an error if the client goes over | 31 // Allocate some extra space so we can send an error if the client goes over |
| 32 // the limit. | 32 // the limit. |
| 33 const int kReadBufferSize = 2 * kMaxPacketSize; | 33 const int kReadBufferSize = 2 * kMaxPacketSize; |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
| 36 | 36 |
| 37 QuicSimpleServer::QuicSimpleServer(std::unique_ptr<ProofSource> proof_source, | 37 QuicSimpleServer::QuicSimpleServer( |
| 38 const QuicConfig& config, | 38 std::unique_ptr<ProofSource> proof_source, |
| 39 const QuicVersionVector& supported_versions) | 39 const QuicConfig& config, |
| 40 const QuicCryptoServerConfig::ConfigOptions& crypto_config_options, |
| 41 const QuicVersionVector& supported_versions) |
| 40 : version_manager_(supported_versions), | 42 : version_manager_(supported_versions), |
| 41 helper_( | 43 helper_( |
| 42 new QuicChromiumConnectionHelper(&clock_, QuicRandom::GetInstance())), | 44 new QuicChromiumConnectionHelper(&clock_, QuicRandom::GetInstance())), |
| 43 alarm_factory_(new QuicChromiumAlarmFactory( | 45 alarm_factory_(new QuicChromiumAlarmFactory( |
| 44 base::ThreadTaskRunnerHandle::Get().get(), | 46 base::ThreadTaskRunnerHandle::Get().get(), |
| 45 &clock_)), | 47 &clock_)), |
| 46 config_(config), | 48 config_(config), |
| 49 crypto_config_options_(crypto_config_options), |
| 47 crypto_config_(kSourceAddressTokenSecret, | 50 crypto_config_(kSourceAddressTokenSecret, |
| 48 QuicRandom::GetInstance(), | 51 QuicRandom::GetInstance(), |
| 49 std::move(proof_source)), | 52 std::move(proof_source)), |
| 50 read_pending_(false), | 53 read_pending_(false), |
| 51 synchronous_read_count_(0), | 54 synchronous_read_count_(0), |
| 52 read_buffer_(new IOBufferWithSize(kReadBufferSize)), | 55 read_buffer_(new IOBufferWithSize(kReadBufferSize)), |
| 53 weak_factory_(this) { | 56 weak_factory_(this) { |
| 54 Initialize(); | 57 Initialize(); |
| 55 } | 58 } |
| 56 | 59 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 69 kInitialStreamFlowControlWindow); | 72 kInitialStreamFlowControlWindow); |
| 70 } | 73 } |
| 71 if (config_.GetInitialSessionFlowControlWindowToSend() == | 74 if (config_.GetInitialSessionFlowControlWindowToSend() == |
| 72 kMinimumFlowControlSendWindow) { | 75 kMinimumFlowControlSendWindow) { |
| 73 config_.SetInitialSessionFlowControlWindowToSend( | 76 config_.SetInitialSessionFlowControlWindowToSend( |
| 74 kInitialSessionFlowControlWindow); | 77 kInitialSessionFlowControlWindow); |
| 75 } | 78 } |
| 76 | 79 |
| 77 std::unique_ptr<CryptoHandshakeMessage> scfg(crypto_config_.AddDefaultConfig( | 80 std::unique_ptr<CryptoHandshakeMessage> scfg(crypto_config_.AddDefaultConfig( |
| 78 helper_->GetRandomGenerator(), helper_->GetClock(), | 81 helper_->GetRandomGenerator(), helper_->GetClock(), |
| 79 QuicCryptoServerConfig::ConfigOptions())); | 82 crypto_config_options_)); |
| 80 } | 83 } |
| 81 | 84 |
| 82 QuicSimpleServer::~QuicSimpleServer() {} | 85 QuicSimpleServer::~QuicSimpleServer() {} |
| 83 | 86 |
| 84 int QuicSimpleServer::Listen(const IPEndPoint& address) { | 87 int QuicSimpleServer::Listen(const IPEndPoint& address) { |
| 85 std::unique_ptr<UDPServerSocket> socket( | 88 std::unique_ptr<UDPServerSocket> socket( |
| 86 new UDPServerSocket(&net_log_, NetLog::Source())); | 89 new UDPServerSocket(&net_log_, NetLog::Source())); |
| 87 | 90 |
| 88 socket->AllowAddressReuse(); | 91 socket->AllowAddressReuse(); |
| 89 | 92 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } | 185 } |
| 183 | 186 |
| 184 QuicReceivedPacket packet(read_buffer_->data(), result, | 187 QuicReceivedPacket packet(read_buffer_->data(), result, |
| 185 helper_->GetClock()->Now(), false); | 188 helper_->GetClock()->Now(), false); |
| 186 dispatcher_->ProcessPacket(server_address_, client_address_, packet); | 189 dispatcher_->ProcessPacket(server_address_, client_address_, packet); |
| 187 | 190 |
| 188 StartReading(); | 191 StartReading(); |
| 189 } | 192 } |
| 190 | 193 |
| 191 } // namespace net | 194 } // namespace net |
| OLD | NEW |