• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 // A toy server specific QuicSession subclass.
6 
7 #ifndef QUICHE_QUIC_TOOLS_QUIC_SIMPLE_SERVER_SESSION_H_
8 #define QUICHE_QUIC_TOOLS_QUIC_SIMPLE_SERVER_SESSION_H_
9 
10 #include <stdint.h>
11 
12 #include <list>
13 #include <memory>
14 #include <set>
15 #include <string>
16 #include <utility>
17 #include <vector>
18 
19 #include "quiche/quic/core/http/quic_server_session_base.h"
20 #include "quiche/quic/core/http/quic_spdy_session.h"
21 #include "quiche/quic/core/quic_crypto_server_stream_base.h"
22 #include "quiche/quic/core/quic_packets.h"
23 #include "quiche/quic/tools/quic_backend_response.h"
24 #include "quiche/quic/tools/quic_simple_server_backend.h"
25 #include "quiche/quic/tools/quic_simple_server_stream.h"
26 #include "quiche/spdy/core/http2_header_block.h"
27 
28 namespace quic {
29 
30 namespace test {
31 class QuicSimpleServerSessionPeer;
32 }  // namespace test
33 
34 class QuicSimpleServerSession : public QuicServerSessionBase {
35  public:
36   // Takes ownership of |connection|.
37   QuicSimpleServerSession(const QuicConfig& config,
38                           const ParsedQuicVersionVector& supported_versions,
39                           QuicConnection* connection,
40                           QuicSession::Visitor* visitor,
41                           QuicCryptoServerStreamBase::Helper* helper,
42                           const QuicCryptoServerConfig* crypto_config,
43                           QuicCompressedCertsCache* compressed_certs_cache,
44                           QuicSimpleServerBackend* quic_simple_server_backend);
45   QuicSimpleServerSession(const QuicSimpleServerSession&) = delete;
46   QuicSimpleServerSession& operator=(const QuicSimpleServerSession&) = delete;
47 
48   ~QuicSimpleServerSession() override;
49 
50   // Override base class to detact client sending data on server push stream.
51   void OnStreamFrame(const QuicStreamFrame& frame) override;
52 
53  protected:
54   // QuicSession methods:
55   QuicSpdyStream* CreateIncomingStream(QuicStreamId id) override;
56   QuicSpdyStream* CreateIncomingStream(PendingStream* pending) override;
57   QuicSpdyStream* CreateOutgoingBidirectionalStream() override;
58   QuicSimpleServerStream* CreateOutgoingUnidirectionalStream() override;
59 
60   // QuicServerSessionBaseMethod:
61   std::unique_ptr<QuicCryptoServerStreamBase> CreateQuicCryptoServerStream(
62       const QuicCryptoServerConfig* crypto_config,
63       QuicCompressedCertsCache* compressed_certs_cache) override;
64 
server_backend()65   QuicSimpleServerBackend* server_backend() {
66     return quic_simple_server_backend_;
67   }
68 
ShouldNegotiateWebTransport()69   bool ShouldNegotiateWebTransport() override {
70     return quic_simple_server_backend_->SupportsWebTransport();
71   }
LocalHttpDatagramSupport()72   HttpDatagramSupport LocalHttpDatagramSupport() override {
73     if (ShouldNegotiateWebTransport()) {
74       return HttpDatagramSupport::kRfcAndDraft04;
75     }
76     return QuicServerSessionBase::LocalHttpDatagramSupport();
77   }
78 
79  private:
80   friend class test::QuicSimpleServerSessionPeer;
81 
82   QuicSimpleServerBackend* quic_simple_server_backend_;  // Not owned.
83 };
84 
85 }  // namespace quic
86 
87 #endif  // QUICHE_QUIC_TOOLS_QUIC_SIMPLE_SERVER_SESSION_H_
88