We started redesigning GpuMemoryBuffer interface to handle multiple buffers [0].
[chromium-blink-merge.git] / net / tools / quic / quic_simple_per_connection_packet_writer.cc
blob713278ff7cc69a7a91e9425b27cd7047984063f0
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"
9 namespace net {
10 namespace tools {
12 QuicSimplePerConnectionPacketWriter::QuicSimplePerConnectionPacketWriter(
13 QuicSimpleServerPacketWriter* shared_writer,
14 QuicConnection* connection)
15 : shared_writer_(shared_writer),
16 connection_(connection),
17 weak_factory_(this){
20 QuicSimplePerConnectionPacketWriter::~QuicSimplePerConnectionPacketWriter() {
23 QuicPacketWriter* QuicSimplePerConnectionPacketWriter::shared_writer() const {
24 return shared_writer_;
27 WriteResult QuicSimplePerConnectionPacketWriter::WritePacket(
28 const char* buffer,
29 size_t buf_len,
30 const IPAddressNumber& self_address,
31 const IPEndPoint& peer_address) {
32 return shared_writer_->WritePacketWithCallback(
33 buffer,
34 buf_len,
35 self_address,
36 peer_address,
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);
59 } // namespace tools
60 } // namespace net