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 // The Google-specific helper for QuicConnection which uses 6 // EpollAlarm for alarms, and used an int fd_ for writing data. 7 8 #ifndef NET_TOOLS_QUIC_QUIC_EPOLL_CONNECTION_HELPER_H_ 9 #define NET_TOOLS_QUIC_QUIC_EPOLL_CONNECTION_HELPER_H_ 10 11 #include <sys/types.h> 12 #include <set> 13 14 #include "net/quic/quic_connection.h" 15 #include "net/quic/quic_protocol.h" 16 #include "net/quic/quic_time.h" 17 #include "net/tools/quic/quic_epoll_clock.h" 18 #include "net/tools/quic/quic_packet_writer.h" 19 20 namespace net { 21 22 class EpollServer; 23 class QuicRandom; 24 25 namespace tools { 26 27 class AckAlarm; 28 class RetransmissionAlarm; 29 class SendAlarm; 30 class TimeoutAlarm; 31 32 namespace test { 33 class QuicEpollConnectionHelperPeer; 34 } // namespace test 35 36 class QuicEpollConnectionHelper : public QuicConnectionHelperInterface { 37 public: 38 QuicEpollConnectionHelper(int fd, EpollServer* eps); 39 QuicEpollConnectionHelper(QuicPacketWriter* writer, EpollServer* eps); 40 virtual ~QuicEpollConnectionHelper(); 41 42 // QuicEpollConnectionHelperInterface 43 virtual void SetConnection(QuicConnection* connection) OVERRIDE; 44 virtual const QuicClock* GetClock() const OVERRIDE; 45 virtual QuicRandom* GetRandomGenerator() OVERRIDE; 46 virtual int WritePacketToWire(const QuicEncryptedPacket& packet, 47 int* error) OVERRIDE; 48 virtual bool IsWriteBlockedDataBuffered() OVERRIDE; 49 virtual bool IsWriteBlocked(int error) OVERRIDE; 50 virtual QuicAlarm* CreateAlarm(QuicAlarm::Delegate* delegate) OVERRIDE; 51 52 EpollServer* epoll_server() { return epoll_server_; } 53 54 private: 55 friend class QuicConnectionPeer; 56 friend class net::tools::test::QuicEpollConnectionHelperPeer; 57 58 QuicPacketWriter* writer_; // Not owned 59 EpollServer* epoll_server_; // Not owned. 60 int fd_; 61 62 QuicConnection* connection_; 63 const QuicEpollClock clock_; 64 QuicRandom* random_generator_; 65 66 DISALLOW_COPY_AND_ASSIGN(QuicEpollConnectionHelper); 67 }; 68 69 } // namespace tools 70 } // namespace net 71 72 #endif // NET_TOOLS_QUIC_QUIC_EPOLL_CONNECTION_HELPER_H_ 73