| 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 // 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 // Note that this server is intended to verify correctness of the client and is |    8 // Note that this server is intended to verify correctness of the client and is | 
|    9 // in no way expected to be performant. |    9 // in no way expected to be performant. | 
|   10  |   10  | 
|   11 #ifndef NET_TOOLS_QUIC_QUIC_SERVER_H_ |   11 #ifndef NET_TOOLS_QUIC_QUIC_SERVER_H_ | 
|   12 #define NET_TOOLS_QUIC_QUIC_SERVER_H_ |   12 #define NET_TOOLS_QUIC_QUIC_SERVER_H_ | 
|   13  |   13  | 
|   14 #include <stddef.h> |   14 #include <stddef.h> | 
|   15  |   15  | 
|   16 #include <memory> |   16 #include <memory> | 
|   17  |   17  | 
|   18 #include "base/macros.h" |   18 #include "base/macros.h" | 
|   19 #include "net/quic/chromium/quic_chromium_connection_helper.h" |   19 #include "net/quic/chromium/quic_chromium_connection_helper.h" | 
|   20 #include "net/quic/core/crypto/quic_crypto_server_config.h" |   20 #include "net/quic/core/crypto/quic_crypto_server_config.h" | 
|   21 #include "net/quic/core/quic_config.h" |   21 #include "net/quic/core/quic_config.h" | 
|   22 #include "net/quic/core/quic_framer.h" |   22 #include "net/quic/core/quic_framer.h" | 
|   23 #include "net/quic/platform/api/quic_socket_address.h" |   23 #include "net/quic/platform/api/quic_socket_address.h" | 
|   24 #include "net/tools/epoll_server/epoll_server.h" |   24 #include "net/tools/epoll_server/epoll_server.h" | 
|   25 #include "net/tools/quic/quic_default_packet_writer.h" |   25 #include "net/tools/quic/quic_default_packet_writer.h" | 
 |   26 #include "net/tools/quic/quic_in_memory_cache.h" | 
|   26  |   27  | 
|   27 namespace net { |   28 namespace net { | 
|   28  |   29  | 
|   29 namespace test { |   30 namespace test { | 
|   30 class QuicServerPeer; |   31 class QuicServerPeer; | 
|   31 }  // namespace test |   32 }  // namespace test | 
|   32  |   33  | 
|   33 class QuicDispatcher; |   34 class QuicDispatcher; | 
|   34 class QuicPacketReader; |   35 class QuicPacketReader; | 
|   35  |   36  | 
|   36 class QuicServer : public EpollCallbackInterface { |   37 class QuicServer : public EpollCallbackInterface { | 
|   37  public: |   38  public: | 
|   38   explicit QuicServer(std::unique_ptr<ProofSource> proof_source); |   39   QuicServer(std::unique_ptr<ProofSource> proof_source, | 
 |   40              QuicInMemoryCache* in_memory_cache); | 
|   39   QuicServer(std::unique_ptr<ProofSource> proof_source, |   41   QuicServer(std::unique_ptr<ProofSource> proof_source, | 
|   40              const QuicConfig& config, |   42              const QuicConfig& config, | 
|   41              const QuicCryptoServerConfig::ConfigOptions& server_config_options, |   43              const QuicCryptoServerConfig::ConfigOptions& server_config_options, | 
|   42              const QuicVersionVector& supported_versions); |   44              const QuicVersionVector& supported_versions, | 
 |   45              QuicInMemoryCache* in_memory_cache); | 
|   43  |   46  | 
|   44   ~QuicServer() override; |   47   ~QuicServer() override; | 
|   45  |   48  | 
|   46   // Start listening on the specified address. |   49   // Start listening on the specified address. | 
|   47   bool CreateUDPSocketAndListen(const QuicSocketAddress& address); |   50   bool CreateUDPSocketAndListen(const QuicSocketAddress& address); | 
|   48  |   51  | 
|   49   // Wait up to 50ms, and handle any events which occur. |   52   // Wait up to 50ms, and handle any events which occur. | 
|   50   void WaitForEvents(); |   53   void WaitForEvents(); | 
|   51  |   54  | 
|   52   // Server deletion is imminent.  Start cleaning up the epoll server. |   55   // Server deletion is imminent.  Start cleaning up the epoll server. | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
|   76   virtual QuicDispatcher* CreateQuicDispatcher(); |   79   virtual QuicDispatcher* CreateQuicDispatcher(); | 
|   77  |   80  | 
|   78   const QuicConfig& config() const { return config_; } |   81   const QuicConfig& config() const { return config_; } | 
|   79   const QuicCryptoServerConfig& crypto_config() const { return crypto_config_; } |   82   const QuicCryptoServerConfig& crypto_config() const { return crypto_config_; } | 
|   80   EpollServer* epoll_server() { return &epoll_server_; } |   83   EpollServer* epoll_server() { return &epoll_server_; } | 
|   81  |   84  | 
|   82   QuicDispatcher* dispatcher() { return dispatcher_.get(); } |   85   QuicDispatcher* dispatcher() { return dispatcher_.get(); } | 
|   83  |   86  | 
|   84   QuicVersionManager* version_manager() { return &version_manager_; } |   87   QuicVersionManager* version_manager() { return &version_manager_; } | 
|   85  |   88  | 
 |   89   QuicInMemoryCache* in_memory_cache() { return in_memory_cache_; } | 
 |   90  | 
|   86  private: |   91  private: | 
|   87   friend class net::test::QuicServerPeer; |   92   friend class net::test::QuicServerPeer; | 
|   88  |   93  | 
|   89   // Initialize the internal state of the server. |   94   // Initialize the internal state of the server. | 
|   90   void Initialize(); |   95   void Initialize(); | 
|   91  |   96  | 
|   92   // Accepts data from the framer and demuxes clients to sessions. |   97   // Accepts data from the framer and demuxes clients to sessions. | 
|   93   std::unique_ptr<QuicDispatcher> dispatcher_; |   98   std::unique_ptr<QuicDispatcher> dispatcher_; | 
|   94   // Frames incoming packets and hands them to the dispatcher. |   99   // Frames incoming packets and hands them to the dispatcher. | 
|   95   EpollServer epoll_server_; |  100   EpollServer epoll_server_; | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
|  117   // crypto_config_options_ contains crypto parameters for the handshake. |  122   // crypto_config_options_ contains crypto parameters for the handshake. | 
|  118   QuicCryptoServerConfig::ConfigOptions crypto_config_options_; |  123   QuicCryptoServerConfig::ConfigOptions crypto_config_options_; | 
|  119  |  124  | 
|  120   // Used to generate current supported versions. |  125   // Used to generate current supported versions. | 
|  121   QuicVersionManager version_manager_; |  126   QuicVersionManager version_manager_; | 
|  122  |  127  | 
|  123   // Point to a QuicPacketReader object on the heap. The reader allocates more |  128   // Point to a QuicPacketReader object on the heap. The reader allocates more | 
|  124   // space than allowed on the stack. |  129   // space than allowed on the stack. | 
|  125   std::unique_ptr<QuicPacketReader> packet_reader_; |  130   std::unique_ptr<QuicPacketReader> packet_reader_; | 
|  126  |  131  | 
 |  132   QuicInMemoryCache* in_memory_cache_;  // unowned. | 
 |  133  | 
|  127   DISALLOW_COPY_AND_ASSIGN(QuicServer); |  134   DISALLOW_COPY_AND_ASSIGN(QuicServer); | 
|  128 }; |  135 }; | 
|  129  |  136  | 
|  130 }  // namespace net |  137 }  // namespace net | 
|  131  |  138  | 
|  132 #endif  // NET_TOOLS_QUIC_QUIC_SERVER_H_ |  139 #endif  // NET_TOOLS_QUIC_QUIC_SERVER_H_ | 
| OLD | NEW |