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"
8 #include "net/tools/quic/quic_simple_server_packet_writer.h"
13 QuicSimplePerConnectionPacketWriter::QuicSimplePerConnectionPacketWriter(
14 QuicSimpleServerPacketWriter
* shared_writer
,
15 QuicConnection
* connection
)
16 : shared_writer_(shared_writer
),
17 connection_(connection
),
21 QuicSimplePerConnectionPacketWriter::~QuicSimplePerConnectionPacketWriter() {
24 QuicPacketWriter
* QuicSimplePerConnectionPacketWriter::shared_writer() const {
25 return shared_writer_
;
28 WriteResult
QuicSimplePerConnectionPacketWriter::WritePacket(
31 const IPAddressNumber
& self_address
,
32 const IPEndPoint
& peer_address
) {
33 return shared_writer_
->WritePacketWithCallback(
38 base::Bind(&QuicSimplePerConnectionPacketWriter::OnWriteComplete
,
39 weak_factory_
.GetWeakPtr()));
42 bool QuicSimplePerConnectionPacketWriter::IsWriteBlockedDataBuffered() const {
43 return shared_writer_
->IsWriteBlockedDataBuffered();
46 bool QuicSimplePerConnectionPacketWriter::IsWriteBlocked() const {
47 return shared_writer_
->IsWriteBlocked();
50 void QuicSimplePerConnectionPacketWriter::SetWritable() {
51 shared_writer_
->SetWritable();
54 void QuicSimplePerConnectionPacketWriter::OnWriteComplete(WriteResult result
) {
55 if (result
.status
== WRITE_STATUS_ERROR
) {
56 connection_
->OnWriteError(result
.error_code
);