Bence Béky | bac0405 | 2022-04-07 15:44:29 -0400 | [diff] [blame] | 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 | #include "quiche/quic/core/quic_epoll_connection_helper.h" |
| 6 | |
| 7 | #include <errno.h> |
| 8 | #include <sys/socket.h> |
| 9 | |
| 10 | #include "quiche/quic/core/crypto/quic_random.h" |
| 11 | |
| 12 | namespace quic { |
| 13 | |
| 14 | QuicEpollConnectionHelper::QuicEpollConnectionHelper( |
| 15 | QuicEpollServer* epoll_server, QuicAllocator allocator_type) |
| 16 | : clock_(epoll_server), |
| 17 | random_generator_(QuicRandom::GetInstance()), |
| 18 | allocator_type_(allocator_type) {} |
| 19 | |
| 20 | QuicEpollConnectionHelper::~QuicEpollConnectionHelper() = default; |
| 21 | |
| 22 | const QuicClock* QuicEpollConnectionHelper::GetClock() const { |
| 23 | return &clock_; |
| 24 | } |
| 25 | |
| 26 | QuicRandom* QuicEpollConnectionHelper::GetRandomGenerator() { |
| 27 | return random_generator_; |
| 28 | } |
| 29 | |
| 30 | quiche::QuicheBufferAllocator* |
| 31 | QuicEpollConnectionHelper::GetStreamSendBufferAllocator() { |
| 32 | if (allocator_type_ == QuicAllocator::BUFFER_POOL) { |
| 33 | return &stream_buffer_allocator_; |
| 34 | } else { |
| 35 | QUICHE_DCHECK(allocator_type_ == QuicAllocator::SIMPLE); |
| 36 | return &simple_buffer_allocator_; |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | } // namespace quic |