Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / net / quic / quic_server_session.h
bloba2e4feb65cf0eaa52685801370d7a70fb427fe65
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
3 // found in the LICENSE file.
4 //
5 // A server specific QuicSession subclass.
7 #ifndef NET_QUIC_QUIC_SERVER_SESSION_H_
8 #define NET_QUIC_QUIC_SERVER_SESSION_H_
10 #include <set>
11 #include <vector>
13 #include "base/basictypes.h"
14 #include "base/containers/hash_tables.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "net/quic/quic_crypto_server_stream.h"
17 #include "net/quic/quic_per_connection_packet_writer.h"
18 #include "net/quic/quic_protocol.h"
19 #include "net/quic/quic_session.h"
21 namespace net {
23 class QuicBlockedWriterInterface;
24 class QuicConfig;
25 class QuicConnection;
26 class QuicCryptoServerConfig;
27 class ReliableQuicStream;
29 namespace test {
30 class QuicServerSessionPeer;
31 } // namespace test
33 // An interface from the session to the entity owning the session.
34 // This lets the session notify its owner (the Dispatcher) when the connection
35 // is closed or blocked.
36 class QuicServerSessionVisitor {
37 public:
38 virtual ~QuicServerSessionVisitor() {}
40 virtual void OnConnectionClosed(QuicConnectionId connection_id,
41 QuicErrorCode error) = 0;
42 virtual void OnWriteBlocked(QuicBlockedWriterInterface* blocked_writer) = 0;
45 class QuicServerSession : public QuicSession {
46 public:
47 QuicServerSession(const QuicConfig& config,
48 QuicConnection* connection,
49 QuicServerSessionVisitor* visitor);
51 // Override the base class to notify the owner of the connection close.
52 virtual void OnConnectionClosed(QuicErrorCode error, bool from_peer) OVERRIDE;
53 virtual void OnWriteBlocked() OVERRIDE;
55 // Sends a server config update to the client, containing new bandwidth
56 // estimate.
57 virtual void OnCongestionWindowChange(QuicTime now) OVERRIDE;
59 virtual ~QuicServerSession();
61 virtual void InitializeSession(const QuicCryptoServerConfig& crypto_config);
63 const QuicCryptoServerStream* crypto_stream() const {
64 return crypto_stream_.get();
67 // Override base class to process FEC config received from client.
68 virtual void OnConfigNegotiated() OVERRIDE;
70 void set_serving_region(string serving_region) {
71 serving_region_ = serving_region;
74 protected:
75 // QuicSession methods:
76 virtual QuicDataStream* CreateIncomingDataStream(QuicStreamId id) OVERRIDE;
77 virtual QuicDataStream* CreateOutgoingDataStream() OVERRIDE;
78 virtual QuicCryptoServerStream* GetCryptoStream() OVERRIDE;
80 // If we should create an incoming stream, returns true. Otherwise
81 // does error handling, including communicating the error to the client and
82 // possibly closing the connection, and returns false.
83 virtual bool ShouldCreateIncomingDataStream(QuicStreamId id);
85 virtual QuicCryptoServerStream* CreateQuicCryptoServerStream(
86 const QuicCryptoServerConfig& crypto_config);
88 private:
89 friend class test::QuicServerSessionPeer;
91 scoped_ptr<QuicCryptoServerStream> crypto_stream_;
92 QuicServerSessionVisitor* visitor_;
94 // The most recent bandwidth estimate sent to the client.
95 QuicBandwidth bandwidth_estimate_sent_to_client_;
97 // Text describing server location. Sent to the client as part of the bandwith
98 // estimate in the source-address token. Optional, can be left empty.
99 string serving_region_;
101 // Time at which we send the last SCUP to the client.
102 QuicTime last_server_config_update_time_;
104 DISALLOW_COPY_AND_ASSIGN(QuicServerSession);
107 } // namespace net
109 #endif // NET_QUIC_QUIC_SERVER_SESSION_H_