OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016 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 #ifndef NET_QUIC_QUARTC_QUARTC_FACTORY_INTERFACE_H_ |
| 6 #define NET_QUIC_QUARTC_QUARTC_FACTORY_INTERFACE_H_ |
| 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
| 11 #include <memory> |
| 12 |
| 13 #include "net/base/net_export.h" |
| 14 #include "net/quic/quartc/quartc_session_interface.h" |
| 15 #include "net/quic/quartc/quartc_task_runner_interface.h" |
| 16 |
| 17 namespace net { |
| 18 |
| 19 // Used to create instances for Quartc objects such as QuartcSession. |
| 20 class NET_EXPORT_PRIVATE QuartcFactoryInterface { |
| 21 public: |
| 22 virtual ~QuartcFactoryInterface() {} |
| 23 |
| 24 struct QuartcSessionConfig { |
| 25 // 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 |
| 27 // client. |
| 28 bool is_server = false; |
| 29 // This is only needed when is_server = false. It must be unique |
| 30 // for each endpoint the local endpoint may communicate with. For example, |
| 31 // a WebRTC client could use the remote endpoint's crypto fingerprint |
| 32 std::string unique_remote_server_id; |
| 33 // The way the QuicConnection will send and receive packets, like a virtual |
| 34 // UDP socket. For WebRTC, this will typically be an IceTransport. |
| 35 QuartcSessionInterface::PacketTransport* packet_transport = nullptr; |
| 36 // The maximum size of the packet can be written with the packet writer. |
| 37 // 1200 bytes by default. |
| 38 uint64_t max_packet_size = 1200; |
| 39 }; |
| 40 |
| 41 virtual std::unique_ptr<QuartcSessionInterface> CreateQuartcSession( |
| 42 const QuartcSessionConfig& quartc_config) = 0; |
| 43 }; |
| 44 |
| 45 // The configuration for creating a QuartcFactory. |
| 46 struct QuartcFactoryConfig { |
| 47 // The task runner used by the QuartcAlarm. Implemented by the Quartc user |
| 48 // with different mechanism. For example in WebRTC, it is implemented with |
| 49 // rtc::Thread. |
| 50 QuartcTaskRunnerInterface* task_runner = nullptr; |
| 51 // If create_at_exit_manager = true, an AtExitManager will be created and |
| 52 // owned by the QuartcFactory. In some scenarios, such as unit tests, this |
| 53 // value could be false and no AtExitManager will be created. |
| 54 bool create_at_exit_manager = true; |
| 55 }; |
| 56 |
| 57 // Creates a new instance of QuartcFactoryInterface. |
| 58 NET_EXPORT_PRIVATE std::unique_ptr<QuartcFactoryInterface> CreateQuartcFactory( |
| 59 const QuartcFactoryConfig& factory_config); |
| 60 |
| 61 } // namepace net |
| 62 |
| 63 #endif // NET_QUIC_QUARTC_QUARTC_FACTORY_INTERFACE_H_ |
OLD | NEW |