| OLD | NEW | 
|    1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2015 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 #ifndef NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_SERVER_H_ |    5 #ifndef NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_SERVER_H_ | 
|    6 #define NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_SERVER_H_ |    6 #define NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_SERVER_H_ | 
|    7  |    7  | 
|    8 #include <memory> |    8 #include <memory> | 
|    9 #include <string> |    9 #include <string> | 
|   10  |   10  | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
|   30    public: |   30    public: | 
|   31     virtual ~SessionFactory() {} |   31     virtual ~SessionFactory() {} | 
|   32  |   32  | 
|   33     // Returns a new session owned by the caller. |   33     // Returns a new session owned by the caller. | 
|   34     virtual QuicServerSessionBase* CreateSession( |   34     virtual QuicServerSessionBase* CreateSession( | 
|   35         const QuicConfig& config, |   35         const QuicConfig& config, | 
|   36         QuicConnection* connection, |   36         QuicConnection* connection, | 
|   37         QuicSession::Visitor* visitor, |   37         QuicSession::Visitor* visitor, | 
|   38         QuicCryptoServerStream::Helper* helper, |   38         QuicCryptoServerStream::Helper* helper, | 
|   39         const QuicCryptoServerConfig* crypto_config, |   39         const QuicCryptoServerConfig* crypto_config, | 
|   40         QuicCompressedCertsCache* compressed_certs_cache) = 0; |   40         QuicCompressedCertsCache* compressed_certs_cache, | 
 |   41         QuicInMemoryCache* in_memory_cache) = 0; | 
|   41   }; |   42   }; | 
|   42  |   43  | 
|   43   // Factory for creating QuicSimpleServerStreams. |   44   // Factory for creating QuicSimpleServerStreams. | 
|   44   class StreamFactory { |   45   class StreamFactory { | 
|   45    public: |   46    public: | 
|   46     virtual ~StreamFactory() {} |   47     virtual ~StreamFactory() {} | 
|   47  |   48  | 
|   48     // Returns a new stream owned by the caller. |   49     // Returns a new stream owned by the caller. | 
|   49     virtual QuicSimpleServerStream* CreateStream(QuicStreamId id, |   50     virtual QuicSimpleServerStream* CreateStream( | 
|   50                                                  QuicSpdySession* session) = 0; |   51         QuicStreamId id, | 
 |   52         QuicSpdySession* session, | 
 |   53         QuicInMemoryCache* in_memory_cache) = 0; | 
|   51   }; |   54   }; | 
|   52  |   55  | 
|   53   class CryptoStreamFactory { |   56   class CryptoStreamFactory { | 
|   54    public: |   57    public: | 
|   55     virtual ~CryptoStreamFactory() {} |   58     virtual ~CryptoStreamFactory() {} | 
|   56  |   59  | 
|   57     // Returns a new QuicCryptoServerStreamBase owned by the caller |   60     // Returns a new QuicCryptoServerStreamBase owned by the caller | 
|   58     virtual QuicCryptoServerStreamBase* CreateCryptoStream( |   61     virtual QuicCryptoServerStreamBase* CreateCryptoStream( | 
|   59         const QuicCryptoServerConfig* crypto_config, |   62         const QuicCryptoServerConfig* crypto_config, | 
|   60         QuicServerSessionBase* session) = 0; |   63         QuicServerSessionBase* session) = 0; | 
|   61   }; |   64   }; | 
|   62  |   65  | 
|   63   explicit QuicTestServer(std::unique_ptr<ProofSource> proof_source); |   66   QuicTestServer(std::unique_ptr<ProofSource> proof_source, | 
 |   67                  QuicInMemoryCache* in_memory_cache); | 
|   64   QuicTestServer(std::unique_ptr<ProofSource> proof_source, |   68   QuicTestServer(std::unique_ptr<ProofSource> proof_source, | 
|   65                  const QuicConfig& config, |   69                  const QuicConfig& config, | 
|   66                  const QuicVersionVector& supported_versions); |   70                  const QuicVersionVector& supported_versions, | 
 |   71                  QuicInMemoryCache* in_memory_cache); | 
|   67  |   72  | 
|   68   // Create a custom dispatcher which creates custom sessions. |   73   // Create a custom dispatcher which creates custom sessions. | 
|   69   QuicDispatcher* CreateQuicDispatcher() override; |   74   QuicDispatcher* CreateQuicDispatcher() override; | 
|   70  |   75  | 
|   71   // Sets a custom session factory, owned by the caller, for easy custom |   76   // Sets a custom session factory, owned by the caller, for easy custom | 
|   72   // session logic. This is incompatible with setting a stream factory or a |   77   // session logic. This is incompatible with setting a stream factory or a | 
|   73   // crypto stream factory. |   78   // crypto stream factory. | 
|   74   void SetSessionFactory(SessionFactory* factory); |   79   void SetSessionFactory(SessionFactory* factory); | 
|   75  |   80  | 
|   76   // Sets a custom stream factory, owned by the caller, for easy custom |   81   // Sets a custom stream factory, owned by the caller, for easy custom | 
|   77   // stream logic. This is incompatible with setting a session factory. |   82   // stream logic. This is incompatible with setting a session factory. | 
|   78   void SetSpdyStreamFactory(StreamFactory* factory); |   83   void SetSpdyStreamFactory(StreamFactory* factory); | 
|   79  |   84  | 
|   80   // Sets a custom crypto stream factory, owned by the caller, for easy custom |   85   // Sets a custom crypto stream factory, owned by the caller, for easy custom | 
|   81   // crypto logic.  This is incompatible with setting a session factory. |   86   // crypto logic.  This is incompatible with setting a session factory. | 
|   82   void SetCryptoStreamFactory(CryptoStreamFactory* factory); |   87   void SetCryptoStreamFactory(CryptoStreamFactory* factory); | 
|   83 }; |   88 }; | 
|   84  |   89  | 
|   85 // Useful test sessions for the QuicTestServer. |   90 // Useful test sessions for the QuicTestServer. | 
|   86  |   91  | 
|   87 // Test session which sends a GOAWAY immedaitely on creation, before crypto |   92 // Test session which sends a GOAWAY immedaitely on creation, before crypto | 
|   88 // credentials have even been established. |   93 // credentials have even been established. | 
|   89 class ImmediateGoAwaySession : public QuicSimpleServerSession { |   94 class ImmediateGoAwaySession : public QuicSimpleServerSession { | 
|   90  public: |   95  public: | 
|   91   ImmediateGoAwaySession(const QuicConfig& config, |   96   ImmediateGoAwaySession(const QuicConfig& config, | 
|   92                          QuicConnection* connection, |   97                          QuicConnection* connection, | 
|   93                          QuicSession::Visitor* visitor, |   98                          QuicSession::Visitor* visitor, | 
|   94                          QuicCryptoServerStream::Helper* helper, |   99                          QuicCryptoServerStream::Helper* helper, | 
|   95                          const QuicCryptoServerConfig* crypto_config, |  100                          const QuicCryptoServerConfig* crypto_config, | 
|   96                          QuicCompressedCertsCache* compressed_certs_cache); |  101                          QuicCompressedCertsCache* compressed_certs_cache, | 
 |  102                          QuicInMemoryCache* in_memory_cache); | 
 |  103  | 
|   97   // Override to send GoAway. |  104   // Override to send GoAway. | 
|   98   void OnStreamFrame(const QuicStreamFrame& frame) override; |  105   void OnStreamFrame(const QuicStreamFrame& frame) override; | 
|   99 }; |  106 }; | 
|  100  |  107  | 
|  101 }  // namespace test |  108 }  // namespace test | 
|  102  |  109  | 
|  103  |  110  | 
|  104 }  // namespace net |  111 }  // namespace net | 
|  105  |  112  | 
|  106 #endif  // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_SERVER_H_ |  113 #endif  // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_SERVER_H_ | 
| OLD | NEW |