• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 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 "net/tools/quic/quic_default_packet_writer.h"
6 
7 #include "net/tools/quic/quic_socket_utils.h"
8 
9 namespace net {
10 namespace tools {
11 
QuicDefaultPacketWriter(int fd)12 QuicDefaultPacketWriter::QuicDefaultPacketWriter(int fd)
13     : fd_(fd),
14       write_blocked_(false) {}
15 
~QuicDefaultPacketWriter()16 QuicDefaultPacketWriter::~QuicDefaultPacketWriter() {}
17 
WritePacket(const char * buffer,size_t buf_len,const IPAddressNumber & self_address,const IPEndPoint & peer_address)18 WriteResult QuicDefaultPacketWriter::WritePacket(
19     const char* buffer,
20     size_t buf_len,
21     const IPAddressNumber& self_address,
22     const IPEndPoint& peer_address) {
23   DCHECK(!IsWriteBlocked());
24   WriteResult result = QuicSocketUtils::WritePacket(
25       fd_, buffer, buf_len, self_address, peer_address);
26   if (result.status == WRITE_STATUS_BLOCKED) {
27     write_blocked_ = true;
28   }
29   return result;
30 }
31 
IsWriteBlockedDataBuffered() const32 bool QuicDefaultPacketWriter::IsWriteBlockedDataBuffered() const {
33   return false;
34 }
35 
IsWriteBlocked() const36 bool QuicDefaultPacketWriter::IsWriteBlocked() const {
37   return write_blocked_;
38 }
39 
SetWritable()40 void QuicDefaultPacketWriter::SetWritable() {
41   write_blocked_ = false;
42 }
43 
44 }  // namespace tools
45 }  // namespace net
46