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

Unified Diff: net/quic/quic_per_connection_packet_writer.h

Issue 340433002: Port QuicServer to Chrome network stack (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Indentation fix Created 6 years, 6 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/quic_per_connection_packet_writer.h
diff --git a/net/quic/quic_default_packet_writer.h b/net/quic/quic_per_connection_packet_writer.h
similarity index 41%
copy from net/quic/quic_default_packet_writer.h
copy to net/quic/quic_per_connection_packet_writer.h
index ed3b5975cee5edb964ad0466c12eb993deda238e..96a37b61d6fe18d02638b04e1b5df298e76252e9 100644
--- a/net/quic/quic_default_packet_writer.h
+++ b/net/quic/quic_per_connection_packet_writer.h
@@ -1,9 +1,9 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef NET_QUIC_QUIC_DEFAULT_PACKET_WRITER_H_
-#define NET_QUIC_QUIC_DEFAULT_PACKET_WRITER_H_
+#ifndef NET_QUIC_QUIC_PER_CONNECTION_PACKET_WRITER_H_
+#define NET_QUIC_QUIC_PER_CONNECTION_PACKET_WRITER_H_
#include "base/basictypes.h"
#include "base/memory/weak_ptr.h"
@@ -11,19 +11,24 @@
#include "net/quic/quic_connection.h"
#include "net/quic/quic_packet_writer.h"
#include "net/quic/quic_protocol.h"
-#include "net/udp/datagram_client_socket.h"
+#include "net/quic/quic_types.h"
namespace net {
-struct WriteResult;
+class QuicServerPacketWriter;
-// Chrome specific packet writer which uses a DatagramClientSocket for writing
-// data.
-class NET_EXPORT_PRIVATE QuicDefaultPacketWriter : public QuicPacketWriter {
+// A connection-specific packet writer that notifies its connection when its
+// writes to the shared QuicServerPacketWriter complete.
+// This class is necessary because multiple connections can share the same
+// QuicServerPacketWriter, so it has no way to know which connection to notify.
+// TODO(dmz) Try to merge with Chrome's default packet writer
+class QuicPerConnectionPacketWriter : public QuicPacketWriter {
public:
- QuicDefaultPacketWriter();
- explicit QuicDefaultPacketWriter(DatagramClientSocket* socket);
- virtual ~QuicDefaultPacketWriter();
+ QuicPerConnectionPacketWriter(QuicServerPacketWriter* writer);
+ virtual ~QuicPerConnectionPacketWriter();
+
+ // Set the connection to notify after writes complete.
+ void set_connection(QuicConnection* connection) { connection_ = connection; }
// QuicPacketWriter
virtual WriteResult WritePacket(const char* buffer,
@@ -34,25 +39,16 @@ class NET_EXPORT_PRIVATE QuicDefaultPacketWriter : public QuicPacketWriter {
virtual bool IsWriteBlocked() const OVERRIDE;
virtual void SetWritable() OVERRIDE;
- void OnWriteComplete(int rv);
- void SetConnection(QuicConnection* connection) {
- connection_ = connection;
- }
-
- protected:
- void set_write_blocked(bool is_blocked) {
- write_blocked_ = is_blocked;
- }
-
private:
- base::WeakPtrFactory<QuicDefaultPacketWriter> weak_factory_;
- DatagramClientSocket* socket_;
+ void OnWriteComplete(WriteResult result);
+
+ base::WeakPtrFactory<QuicPerConnectionPacketWriter> weak_factory_;
+ QuicServerPacketWriter* writer_; // Not owned.
QuicConnection* connection_;
- bool write_blocked_;
- DISALLOW_COPY_AND_ASSIGN(QuicDefaultPacketWriter);
+ DISALLOW_COPY_AND_ASSIGN(QuicPerConnectionPacketWriter);
};
} // namespace net
-#endif // NET_QUIC_QUIC_DEFAULT_PACKET_WRITER_H_
+#endif // NET_QUIC_QUIC_PER_CONNECTION_PACKET_WRITER_H_

Powered by Google App Engine
This is Rietveld 408576698