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

Unified Diff: net/quic/chromium/quic_chromium_packet_writer.cc

Issue 2325733004: Makes QuicChromiumPacketWriter use the delegate for interacting with the connection. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: net/quic/chromium/quic_chromium_packet_writer.cc
diff --git a/net/quic/chromium/quic_chromium_packet_writer.cc b/net/quic/chromium/quic_chromium_packet_writer.cc
index 0494d44705a6f1e05e9d9e0d5861703f27c104ee..440360d41d3aab5fa4c7f61b400957727963e98a 100644
--- a/net/quic/chromium/quic_chromium_packet_writer.cc
+++ b/net/quic/chromium/quic_chromium_packet_writer.cc
@@ -20,20 +20,13 @@ QuicChromiumPacketWriter::QuicChromiumPacketWriter() : weak_factory_(this) {}
QuicChromiumPacketWriter::QuicChromiumPacketWriter(Socket* socket)
: socket_(socket),
- connection_(nullptr),
- observer_(nullptr),
+ delegate_(nullptr),
packet_(nullptr),
write_blocked_(false),
weak_factory_(this) {}
QuicChromiumPacketWriter::~QuicChromiumPacketWriter() {}
-void QuicChromiumPacketWriter::Initialize(WriteErrorObserver* observer,
- QuicConnection* connection) {
- observer_ = observer;
- connection_ = connection;
-}
-
int QuicChromiumPacketWriter::WritePacketToSocket(StringIOBuffer* packet) {
return socket_->Write(packet, packet->size(),
base::Bind(&QuicChromiumPacketWriter::OnWriteComplete,
@@ -53,12 +46,11 @@ WriteResult QuicChromiumPacketWriter::WritePacket(
int rv = WritePacketToSocket(buf.get());
- if (rv < 0 && rv != ERR_IO_PENDING && observer_ != nullptr) {
- // If write error, then call observer's OnWriteError, which may be
- // able to migrate and rewrite packet on a new socket.
- // OnWriteError returns the outcome of that attempt, which is returned
- // to the caller.
- rv = observer_->OnWriteError(rv, buf);
+ if (rv < 0 && rv != ERR_IO_PENDING && delegate_ != nullptr) {
+ // If write error, then call delegate's HandleWriteError, which
+ // may be able to migrate and rewrite packet on a new socket.
+ // HandleWriteError returns the outcome of that rewrite attempt.
+ rv = delegate_->HandleWriteError(rv, buf);
}
WriteStatus status = WRITE_STATUS_OK;
@@ -99,23 +91,22 @@ void QuicChromiumPacketWriter::SetWritable() {
void QuicChromiumPacketWriter::OnWriteComplete(int rv) {
DCHECK_NE(rv, ERR_IO_PENDING);
- DCHECK(connection_) << "Uninitialized connection.";
- DCHECK(observer_) << "Uninitialized observer.";
+ DCHECK(delegate_) << "Uninitialized observer.";
Ryan Hamilton 2016/09/09 02:56:23 nit: here and elsewhere s/observer/delegate/
Jana 2016/09/09 04:19:34 Done.
write_blocked_ = false;
if (rv < 0) {
// If write error, then call into the observer's OnWriteError,
// which may be able to rewrite the packet on a new
// socket. OnWriteError returns the outcome of the attempt.
- rv = observer_->OnWriteError(rv, packet_);
+ rv = delegate_->HandleWriteError(rv, packet_);
packet_ = nullptr;
if (rv == ERR_IO_PENDING)
return;
}
- if (rv < 0) {
- connection_->OnWriteError(rv);
- }
- connection_->OnCanWrite();
+ if (rv < 0)
+ delegate_->OnWriteError(rv);
+ else
+ delegate_->OnWriteUnblocked();
Ryan Hamilton 2016/09/09 02:56:23 this is actually a functional change, right? proba
Jana 2016/09/09 04:19:34 Yes, this is a functional change, but it's a relat
}
QuicByteCount QuicChromiumPacketWriter::GetMaxPacketSize(

Powered by Google App Engine
This is Rietveld 408576698