Fix crash in SpeechRecognizerImpl introduced in AudioParams refactor.
[chromium-blink-merge.git] / net / tools / quic / quic_simple_per_connection_packet_writer.h
blob5cb4f4a8b9c1a462f2d12a3801f2f5f3ae5d7520
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 #ifndef NET_QUIC_TOOLS_QUIC_SIMPLE_PER_CONNECTION_PACKET_WRITER_H_
6 #define NET_QUIC_TOOLS_QUIC_SIMPLE_PER_CONNECTION_PACKET_WRITER_H_
8 #include "base/memory/weak_ptr.h"
9 #include "net/quic/quic_connection.h"
10 #include "net/quic/quic_packet_writer.h"
12 namespace net {
13 namespace tools {
15 class QuicSimpleServerPacketWriter;
17 // A connection-specific packet writer that notifies its connection when its
18 // writes to the shared QuicServerPacketWriter complete.
19 // This class is necessary because multiple connections can share the same
20 // QuicServerPacketWriter, so it has no way to know which connection to notify.
21 class QuicSimplePerConnectionPacketWriter : public QuicPacketWriter {
22 public:
23 // Does not take ownership of |shared_writer| or |connection|.
24 QuicSimplePerConnectionPacketWriter(
25 QuicSimpleServerPacketWriter* shared_writer,
26 QuicConnection* connection);
27 ~QuicSimplePerConnectionPacketWriter() override;
29 QuicPacketWriter* shared_writer() const;
30 QuicConnection* connection() const { return connection_; }
32 // Default implementation of the QuicPacketWriter interface: Passes everything
33 // to |shared_writer_|.
34 WriteResult WritePacket(const char* buffer,
35 size_t buf_len,
36 const IPAddressNumber& self_address,
37 const IPEndPoint& peer_address) override;
38 bool IsWriteBlockedDataBuffered() const override;
39 bool IsWriteBlocked() const override;
40 void SetWritable() override;
42 private:
43 void OnWriteComplete(WriteResult result);
45 QuicSimpleServerPacketWriter* shared_writer_; // Not owned.
46 QuicConnection* connection_; // Not owned.
48 base::WeakPtrFactory<QuicSimplePerConnectionPacketWriter> weak_factory_;
50 DISALLOW_COPY_AND_ASSIGN(QuicSimplePerConnectionPacketWriter);
53 } // namespace tools
54 } // namespace net
56 #endif // NET_QUIC_TOOLS_QUIC_SIMPLE_PER_CONNECTION_PACKET_WRITER_H_