Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(895)

Side by Side Diff: net/quic/chromium/quic_chromium_packet_writer.h

Issue 2319343004: Makes migration on write error asynchronous to avoid reentrancy issues (Closed)
Patch Set: Avoids multiple tasks from repeating packet write. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_QUIC_QUIC_CHROMIUM_PACKET_WRITER_H_ 5 #ifndef NET_QUIC_QUIC_CHROMIUM_PACKET_WRITER_H_
6 #define NET_QUIC_QUIC_CHROMIUM_PACKET_WRITER_H_ 6 #define NET_QUIC_QUIC_CHROMIUM_PACKET_WRITER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 14 matching lines...) Expand all
25 // Delegate interface which receives notifications on socket write events. 25 // Delegate interface which receives notifications on socket write events.
26 class NET_EXPORT_PRIVATE Delegate { 26 class NET_EXPORT_PRIVATE Delegate {
27 public: 27 public:
28 // Called when a socket write attempt results in a failure, so 28 // Called when a socket write attempt results in a failure, so
29 // that the delegate may recover from it by perhaps rewriting the 29 // that the delegate may recover from it by perhaps rewriting the
30 // packet to a different socket. An implementation must return the 30 // packet to a different socket. An implementation must return the
31 // return value from the rewrite attempt if there is one, and 31 // return value from the rewrite attempt if there is one, and
32 // |error_code| otherwise. 32 // |error_code| otherwise.
33 virtual int HandleWriteError(int error_code, 33 virtual int HandleWriteError(int error_code,
34 scoped_refptr<StringIOBuffer> last_packet) = 0; 34 scoped_refptr<StringIOBuffer> last_packet) = 0;
35
35 // Called to propagate the final write error to the delegate. 36 // Called to propagate the final write error to the delegate.
36 virtual void OnWriteError(int error_code) = 0; 37 virtual void OnWriteError(int error_code) = 0;
38
37 // Called when the writer is unblocked due to a write completion. 39 // Called when the writer is unblocked due to a write completion.
38 virtual void OnWriteUnblocked() = 0; 40 virtual void OnWriteUnblocked() = 0;
41
42 // Called when the writer's IsWriteBlocked is called.
43 virtual bool ShouldWriteBlock() = 0;
39 }; 44 };
40 45
41 QuicChromiumPacketWriter(); 46 QuicChromiumPacketWriter();
42 // |socket| must outlive writer. 47 // |socket| must outlive writer.
43 explicit QuicChromiumPacketWriter(Socket* socket); 48 explicit QuicChromiumPacketWriter(Socket* socket);
44 ~QuicChromiumPacketWriter() override; 49 ~QuicChromiumPacketWriter() override;
45 50
46 // |delegate| must outlive writer. 51 // |delegate| must outlive writer.
47 void set_delegate(Delegate* delegate) { delegate_ = delegate; } 52 void set_delegate(Delegate* delegate) { delegate_ = delegate; }
48 53
49 // Writes |packet| to the socket and returns the error code from the write. 54 // Writes |packet| to the socket and returns the error code from the write.
50 int WritePacketToSocket(StringIOBuffer* packet); 55 WriteResult WritePacketToSocket(scoped_refptr<StringIOBuffer> packet);
51 56
52 // QuicPacketWriter 57 // QuicPacketWriter
53 WriteResult WritePacket(const char* buffer, 58 WriteResult WritePacket(const char* buffer,
54 size_t buf_len, 59 size_t buf_len,
55 const IPAddress& self_address, 60 const IPAddress& self_address,
56 const IPEndPoint& peer_address, 61 const IPEndPoint& peer_address,
57 PerPacketOptions* options) override; 62 PerPacketOptions* options) override;
58 bool IsWriteBlockedDataBuffered() const override; 63 bool IsWriteBlockedDataBuffered() const override;
59 bool IsWriteBlocked() const override; 64 bool IsWriteBlocked() const override;
60 void SetWritable() override; 65 void SetWritable() override;
(...skipping 15 matching lines...) Expand all
76 bool write_blocked_; 81 bool write_blocked_;
77 82
78 base::WeakPtrFactory<QuicChromiumPacketWriter> weak_factory_; 83 base::WeakPtrFactory<QuicChromiumPacketWriter> weak_factory_;
79 84
80 DISALLOW_COPY_AND_ASSIGN(QuicChromiumPacketWriter); 85 DISALLOW_COPY_AND_ASSIGN(QuicChromiumPacketWriter);
81 }; 86 };
82 87
83 } // namespace net 88 } // namespace net
84 89
85 #endif // NET_QUIC_QUIC_CHROMIUM_PACKET_WRITER_H_ 90 #endif // NET_QUIC_QUIC_CHROMIUM_PACKET_WRITER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698