1 // Copyright 2014 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.
5 #include "net/tools/quic/quic_simple_per_connection_packet_writer.h"
7 #include "net/tools/quic/quic_simple_server_packet_writer.h"
12 QuicSimplePerConnectionPacketWriter::QuicSimplePerConnectionPacketWriter(
13 QuicSimpleServerPacketWriter
* shared_writer
,
14 QuicConnection
* connection
)
15 : shared_writer_(shared_writer
),
16 connection_(connection
),
20 QuicSimplePerConnectionPacketWriter::~QuicSimplePerConnectionPacketWriter() {
23 QuicPacketWriter
* QuicSimplePerConnectionPacketWriter::shared_writer() const {
24 return shared_writer_
;
27 WriteResult
QuicSimplePerConnectionPacketWriter::WritePacket(
30 const IPAddressNumber
& self_address
,
31 const IPEndPoint
& peer_address
) {
32 return shared_writer_
->WritePacketWithCallback(
37 base::Bind(&QuicSimplePerConnectionPacketWriter::OnWriteComplete
,
38 weak_factory_
.GetWeakPtr()));
41 bool QuicSimplePerConnectionPacketWriter::IsWriteBlockedDataBuffered() const {
42 return shared_writer_
->IsWriteBlockedDataBuffered();
45 bool QuicSimplePerConnectionPacketWriter::IsWriteBlocked() const {
46 return shared_writer_
->IsWriteBlocked();
49 void QuicSimplePerConnectionPacketWriter::SetWritable() {
50 shared_writer_
->SetWritable();
53 void QuicSimplePerConnectionPacketWriter::OnWriteComplete(WriteResult result
) {
54 if (result
.status
== WRITE_STATUS_ERROR
) {
55 connection_
->OnWriteError(result
.error_code
);