[Android WebView] Fix webview perf bot switchover to use org.chromium.webview_shell...
[chromium-blink-merge.git] / net / tools / quic / quic_simple_per_connection_packet_writer.cc
blob9823eb1bedf3b6a8ac052afbc8a36ed5f5909bf0
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 "base/bind.h"
8 #include "net/tools/quic/quic_simple_server_packet_writer.h"
10 namespace net {
11 namespace tools {
13 QuicSimplePerConnectionPacketWriter::QuicSimplePerConnectionPacketWriter(
14 QuicSimpleServerPacketWriter* shared_writer,
15 QuicConnection* connection)
16 : shared_writer_(shared_writer),
17 connection_(connection),
18 weak_factory_(this){
21 QuicSimplePerConnectionPacketWriter::~QuicSimplePerConnectionPacketWriter() {
24 QuicPacketWriter* QuicSimplePerConnectionPacketWriter::shared_writer() const {
25 return shared_writer_;
28 WriteResult QuicSimplePerConnectionPacketWriter::WritePacket(
29 const char* buffer,
30 size_t buf_len,
31 const IPAddressNumber& self_address,
32 const IPEndPoint& peer_address) {
33 return shared_writer_->WritePacketWithCallback(
34 buffer,
35 buf_len,
36 self_address,
37 peer_address,
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);
60 } // namespace tools
61 } // namespace net