| OLD | NEW |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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_QUIC_QUARTC_QUARTC_FACTORY_INTERFACE_H_ | 5 #ifndef NET_QUIC_QUARTC_QUARTC_FACTORY_INTERFACE_H_ |
| 6 #define NET_QUIC_QUARTC_QUARTC_FACTORY_INTERFACE_H_ | 6 #define NET_QUIC_QUARTC_QUARTC_FACTORY_INTERFACE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 | 12 |
| 13 #include "net/quic/quartc/quartc_clock_interface.h" | 13 #include "net/quic/quartc/quartc_clock_interface.h" |
| 14 #include "net/quic/quartc/quartc_session_interface.h" | 14 #include "net/quic/quartc/quartc_session_interface.h" |
| 15 #include "net/quic/quartc/quartc_task_runner_interface.h" | 15 #include "net/quic/quartc/quartc_task_runner_interface.h" |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 | 18 |
| 19 // Algorithm to use for congestion control. |
| 20 enum class QuartcCongestionControl { |
| 21 kDefault, // Use an arbitrary algorithm chosen by QUIC. |
| 22 kBBR, // Use BBR. |
| 23 }; |
| 24 |
| 19 // Used to create instances for Quartc objects such as QuartcSession. | 25 // Used to create instances for Quartc objects such as QuartcSession. |
| 20 class QuartcFactoryInterface { | 26 class QUIC_EXPORT_PRIVATE QuartcFactoryInterface { |
| 21 public: | 27 public: |
| 22 virtual ~QuartcFactoryInterface() {} | 28 virtual ~QuartcFactoryInterface() {} |
| 23 | 29 |
| 24 struct QuartcSessionConfig { | 30 struct QuartcSessionConfig { |
| 25 // When using Quartc, there are two endpoints. The QuartcSession on one | 31 // When using Quartc, there are two endpoints. The QuartcSession on one |
| 26 // endpoint must act as a server and the one on the other side must act as a | 32 // endpoint must act as a server and the one on the other side must act as a |
| 27 // client. | 33 // client. |
| 28 bool is_server = false; | 34 bool is_server = false; |
| 29 // This is only needed when is_server = false. It must be unique | 35 // This is only needed when is_server = false. It must be unique |
| 30 // for each endpoint the local endpoint may communicate with. For example, | 36 // for each endpoint the local endpoint may communicate with. For example, |
| 31 // a WebRTC client could use the remote endpoint's crypto fingerprint | 37 // a WebRTC client could use the remote endpoint's crypto fingerprint |
| 32 std::string unique_remote_server_id; | 38 std::string unique_remote_server_id; |
| 33 // The way the QuicConnection will send and receive packets, like a virtual | 39 // The way the QuicConnection will send and receive packets, like a virtual |
| 34 // UDP socket. For WebRTC, this will typically be an IceTransport. | 40 // UDP socket. For WebRTC, this will typically be an IceTransport. |
| 35 QuartcSessionInterface::PacketTransport* packet_transport = nullptr; | 41 QuartcSessionInterface::PacketTransport* packet_transport = nullptr; |
| 36 // The maximum size of the packet can be written with the packet writer. | 42 // The maximum size of the packet can be written with the packet writer. |
| 37 // 1200 bytes by default. | 43 // 1200 bytes by default. |
| 38 uint64_t max_packet_size = 1200; | 44 uint64_t max_packet_size = 1200; |
| 45 // Algorithm to use for congestion control. By default, uses an arbitrary |
| 46 // congestion control algorithm chosen by QUIC. |
| 47 QuartcCongestionControl congestion_control = |
| 48 QuartcCongestionControl::kDefault; |
| 39 }; | 49 }; |
| 40 | 50 |
| 41 virtual std::unique_ptr<QuartcSessionInterface> CreateQuartcSession( | 51 virtual std::unique_ptr<QuartcSessionInterface> CreateQuartcSession( |
| 42 const QuartcSessionConfig& quartc_config) = 0; | 52 const QuartcSessionConfig& quartc_config) = 0; |
| 43 }; | 53 }; |
| 44 | 54 |
| 45 // The configuration for creating a QuartcFactory. | 55 // The configuration for creating a QuartcFactory. |
| 46 struct QuartcFactoryConfig { | 56 struct QuartcFactoryConfig { |
| 47 // The task runner used by the QuartcAlarm. Implemented by the Quartc user | 57 // The task runner used by the QuartcAlarm. Implemented by the Quartc user |
| 48 // with different mechanism. For example in WebRTC, it is implemented with | 58 // with different mechanism. For example in WebRTC, it is implemented with |
| 49 // rtc::Thread. Owned by the user, and needs to stay alive for as long | 59 // rtc::Thread. Owned by the user, and needs to stay alive for as long |
| 50 // as the QuartcFactory exists. | 60 // as the QuartcFactory exists. |
| 51 QuartcTaskRunnerInterface* task_runner = nullptr; | 61 QuartcTaskRunnerInterface* task_runner = nullptr; |
| 52 // The clock used by QuartcAlarms. Implemented by the Quartc user. Owned by | 62 // The clock used by QuartcAlarms. Implemented by the Quartc user. Owned by |
| 53 // the user, and needs to stay alive for as long as the QuartcFactory exists. | 63 // the user, and needs to stay alive for as long as the QuartcFactory exists. |
| 54 QuartcClockInterface* clock = nullptr; | 64 QuartcClockInterface* clock = nullptr; |
| 55 // If create_at_exit_manager = true, an AtExitManager will be created and | 65 // If create_at_exit_manager = true, an AtExitManager will be created and |
| 56 // owned by the QuartcFactory. In some scenarios, such as unit tests, this | 66 // owned by the QuartcFactory. In some scenarios, such as unit tests, this |
| 57 // value could be false and no AtExitManager will be created. | 67 // value could be false and no AtExitManager will be created. |
| 58 bool create_at_exit_manager = true; | 68 bool create_at_exit_manager = true; |
| 59 }; | 69 }; |
| 60 | 70 |
| 61 // Creates a new instance of QuartcFactoryInterface. | 71 // Creates a new instance of QuartcFactoryInterface. |
| 62 std::unique_ptr<QuartcFactoryInterface> CreateQuartcFactory( | 72 std::unique_ptr<QuartcFactoryInterface> CreateQuartcFactory( |
| 63 const QuartcFactoryConfig& factory_config); | 73 const QuartcFactoryConfig& factory_config); |
| 64 | 74 |
| 65 } // namespace net | 75 } // namespace net |
| 66 | 76 |
| 67 #endif // NET_QUIC_QUARTC_QUARTC_FACTORY_INTERFACE_H_ | 77 #endif // NET_QUIC_QUARTC_QUARTC_FACTORY_INTERFACE_H_ |
| OLD | NEW |