| 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 // A toy server, which listens on a specified address for QUIC traffic and | 5 // A toy server, which listens on a specified address for QUIC traffic and |
| 6 // handles incoming responses. | 6 // handles incoming responses. |
| 7 | 7 |
| 8 #ifndef NET_QUIC_TOOLS_QUIC_SIMPLE_SERVER_H_ | 8 #ifndef NET_QUIC_TOOLS_QUIC_SIMPLE_SERVER_H_ |
| 9 #define NET_QUIC_TOOLS_QUIC_SIMPLE_SERVER_H_ | 9 #define NET_QUIC_TOOLS_QUIC_SIMPLE_SERVER_H_ |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 namespace tools { | 25 namespace tools { |
| 26 | 26 |
| 27 class QuicDispatcher; | 27 class QuicDispatcher; |
| 28 | 28 |
| 29 namespace test { | 29 namespace test { |
| 30 class QuicSimpleServerPeer; | 30 class QuicSimpleServerPeer; |
| 31 } // namespace test | 31 } // namespace test |
| 32 | 32 |
| 33 class QuicSimpleServer { | 33 class QuicSimpleServer { |
| 34 public: | 34 public: |
| 35 QuicSimpleServer(const QuicConfig& config, | 35 QuicSimpleServer(ProofSource* proof_source, |
| 36 const QuicConfig& config, |
| 36 const QuicVersionVector& supported_versions); | 37 const QuicVersionVector& supported_versions); |
| 37 | 38 |
| 38 virtual ~QuicSimpleServer(); | 39 virtual ~QuicSimpleServer(); |
| 39 | 40 |
| 40 // Start listening on the specified address. Returns an error code. | 41 // Start listening on the specified address. Returns an error code. |
| 41 int Listen(const IPEndPoint& address); | 42 int Listen(const IPEndPoint& address); |
| 42 | 43 |
| 43 // Server deletion is imminent. Start cleaning up. | 44 // Server deletion is imminent. Start cleaning up. |
| 44 void Shutdown(); | 45 void Shutdown(); |
| 45 | 46 |
| 46 // Start reading on the socket. On asynchronous reads, this registers | 47 // Start reading on the socket. On asynchronous reads, this registers |
| 47 // OnReadComplete as the callback, which will then call StartReading again. | 48 // OnReadComplete as the callback, which will then call StartReading again. |
| 48 void StartReading(); | 49 void StartReading(); |
| 49 | 50 |
| 50 // Called on reads that complete asynchronously. Dispatches the packet and | 51 // Called on reads that complete asynchronously. Dispatches the packet and |
| 51 // continues the read loop. | 52 // continues the read loop. |
| 52 void OnReadComplete(int result); | 53 void OnReadComplete(int result); |
| 53 | 54 |
| 54 void SetStrikeRegisterNoStartupPeriod() { | 55 void SetStrikeRegisterNoStartupPeriod() { |
| 55 crypto_config_.set_strike_register_no_startup_period(); | 56 crypto_config_.set_strike_register_no_startup_period(); |
| 56 } | 57 } |
| 57 | 58 |
| 58 // SetProofSource sets the ProofSource that will be used to verify the | |
| 59 // server's certificate, and takes ownership of |source|. | |
| 60 void SetProofSource(ProofSource* source) { | |
| 61 crypto_config_.SetProofSource(source); | |
| 62 } | |
| 63 | |
| 64 QuicDispatcher* dispatcher() { return dispatcher_.get(); } | 59 QuicDispatcher* dispatcher() { return dispatcher_.get(); } |
| 65 | 60 |
| 66 private: | 61 private: |
| 67 friend class test::QuicSimpleServerPeer; | 62 friend class test::QuicSimpleServerPeer; |
| 68 | 63 |
| 69 // Initialize the internal state of the server. | 64 // Initialize the internal state of the server. |
| 70 void Initialize(); | 65 void Initialize(); |
| 71 | 66 |
| 72 // Accepts data from the framer and demuxes clients to sessions. | 67 // Accepts data from the framer and demuxes clients to sessions. |
| 73 scoped_ptr<QuicDispatcher> dispatcher_; | 68 scoped_ptr<QuicDispatcher> dispatcher_; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 110 |
| 116 base::WeakPtrFactory<QuicSimpleServer> weak_factory_; | 111 base::WeakPtrFactory<QuicSimpleServer> weak_factory_; |
| 117 | 112 |
| 118 DISALLOW_COPY_AND_ASSIGN(QuicSimpleServer); | 113 DISALLOW_COPY_AND_ASSIGN(QuicSimpleServer); |
| 119 }; | 114 }; |
| 120 | 115 |
| 121 } // namespace tools | 116 } // namespace tools |
| 122 } // namespace net | 117 } // namespace net |
| 123 | 118 |
| 124 #endif // NET_QUIC_TOOLS_QUIC_SIMPLE_SERVER_H_ | 119 #endif // NET_QUIC_TOOLS_QUIC_SIMPLE_SERVER_H_ |
| OLD | NEW |