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

Unified Diff: net/quic/quic_buffered_packet_store.h

Issue 2014383002: relnote: Add a new class QuicBufferedPacketStore which is not in use yet. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « net/net.gypi ('k') | net/quic/quic_buffered_packet_store.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_buffered_packet_store.h
diff --git a/net/quic/quic_buffered_packet_store.h b/net/quic/quic_buffered_packet_store.h
new file mode 100644
index 0000000000000000000000000000000000000000..6dea24f2fbed025d79c8919295ff6b68f8d0cd99
--- /dev/null
+++ b/net/quic/quic_buffered_packet_store.h
@@ -0,0 +1,124 @@
+// Copyright (c) 2016 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_BUFFERED_PACKET_STORE_H_
+#define NET_QUIC_QUIC_BUFFERED_PACKET_STORE_H_
+
+#include "net/base/ip_address.h"
+#include "net/base/linked_hash_map.h"
+#include "net/quic/quic_alarm.h"
+#include "net/quic/quic_alarm_factory.h"
+#include "net/quic/quic_clock.h"
+#include "net/quic/quic_protocol.h"
+#include "net/quic/quic_time.h"
+
+namespace net {
+
+namespace test {
+class QuicBufferedPacketStorePeer;
+} // namespace test
+
+// This class buffers undeliverable packets for each connection until either
+// 1) They are requested to be delivered via DeliverPacket(), or
+// 2) They expire after exceeding their lifetime in the store.
+class NET_EXPORT_PRIVATE QuicBufferedPacketStore {
+ public:
+ enum EnqueuePacketResult {
+ SUCCESS = 0,
+ TOO_MANY_PACKETS, // Too many packets stored up for a certain connection.
+ TOO_MANY_CONNECTIONS // Too many connections stored up in the store.
+ };
+
+ // A packets with client/server address.
+ struct BufferedPacket {
+ BufferedPacket(std::unique_ptr<QuicEncryptedPacket> packet,
+ IPEndPoint server_address,
+ IPEndPoint client_address);
+ BufferedPacket(BufferedPacket&& other);
+
+ BufferedPacket& operator=(BufferedPacket&& other);
+
+ ~BufferedPacket();
+
+ std::unique_ptr<QuicEncryptedPacket> packet;
+ IPEndPoint server_address;
+ IPEndPoint client_address;
+ };
+
+ // A queue of BufferedPackets for a connection.
+ struct BufferedPacketList {
+ BufferedPacketList();
+ BufferedPacketList(BufferedPacketList&& other);
+
+ BufferedPacketList& operator=(BufferedPacketList&& other);
+
+ ~BufferedPacketList();
+
+ std::list<BufferedPacket> buffered_packets;
+ QuicTime creation_time;
+ };
+
+ typedef linked_hash_map<QuicConnectionId, BufferedPacketList>
+ BufferedPacketMap;
+
+ class NET_EXPORT_PRIVATE VisitorInterface {
+ public:
+ virtual ~VisitorInterface() {}
+
+ // Called for each expired connection when alarm fires.
+ virtual void OnExpiredPackets(QuicConnectionId connection_id,
+ BufferedPacketList early_arrived_packets) = 0;
+ };
+
+ QuicBufferedPacketStore(VisitorInterface* vistor,
+ QuicClock* clock,
+ QuicAlarmFactory* alarm_factory);
+
+ QuicBufferedPacketStore(const QuicBufferedPacketStore&) = delete;
+
+ virtual ~QuicBufferedPacketStore();
+
+ QuicBufferedPacketStore& operator=(const QuicBufferedPacketStore&) = delete;
+
+ // Adds a copy of packet into packet queue for given connection.
+ EnqueuePacketResult EnqueuePacket(QuicConnectionId connection_id,
+ const QuicEncryptedPacket& packet,
+ IPEndPoint server_address,
+ IPEndPoint client_address);
+
+ // Returns the std::list of buffered packets for |connection_id| and removes
+ // them
+ // from the store. Returns an empty std::list if no early arrived packets for
+ // this
Ryan Hamilton 2016/05/26 22:17:36 nit: I'm not sure if this in the internal version
+ // connection are present.
+ virtual std::list<BufferedPacket> DeliverPackets(
+ QuicConnectionId connection_id);
+
+ // Examines how long packets have been buffered in the store for each
+ // connection. If they stay too long, removes them for new coming packets and
+ // calls |visitor_|'s OnPotentialConnectionExpire().
+ // Resets the alarm at the end.
+ void OnExpirationTimeout();
+
+ private:
+ friend class test::QuicBufferedPacketStorePeer;
+
+ // A map to store packet queues with creation time for each connection.
+ BufferedPacketMap undecryptable_packets_;
+
+ // The max time the packets of a connection can be buffer in the store.
+ QuicTime::Delta connection_life_span_;
+
+ VisitorInterface* visitor_; // Unowned.
+
+ QuicClock* clock_; // Unowned.
+
+ // This alarm fires every |connection_life_span_| to clean up
+ // packets staying in the store for too long.
+ std::unique_ptr<QuicAlarm> expiration_alarm_;
+};
+
+} // namespace net
+
+#endif // NET_QUIC_QUIC_BUFFERED_PACKET_STORE_H_
« no previous file with comments | « net/net.gypi ('k') | net/quic/quic_buffered_packet_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698