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

Unified Diff: net/quic/test_tools/simulator/packet_filter.cc

Issue 2529293009: Split TrafficPolicer into a generic one-way packet filter class and a policer-specific logic. (Closed)
Patch Set: Created 4 years 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/quic/test_tools/simulator/packet_filter.h ('k') | net/quic/test_tools/simulator/simulator_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/test_tools/simulator/packet_filter.cc
diff --git a/net/quic/test_tools/simulator/packet_filter.cc b/net/quic/test_tools/simulator/packet_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a988d9bdd713ab9247ccd998d8363ca58eddf8fc
--- /dev/null
+++ b/net/quic/test_tools/simulator/packet_filter.cc
@@ -0,0 +1,40 @@
+// 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.
+
+#include "net/quic/test_tools/simulator/packet_filter.h"
+
+namespace net {
+namespace simulator {
+
+PacketFilter::PacketFilter(Simulator* simulator,
+ std::string name,
+ Endpoint* input)
+ : Endpoint(simulator, name), input_(input) {
+ input_->SetTxPort(this);
+}
+
+PacketFilter::~PacketFilter() {}
+
+void PacketFilter::AcceptPacket(std::unique_ptr<Packet> packet) {
+ if (FilterPacket(*packet)) {
+ output_tx_port_->AcceptPacket(std::move(packet));
+ }
+}
+
+QuicTime::Delta PacketFilter::TimeUntilAvailable() {
+ return output_tx_port_->TimeUntilAvailable();
+}
+
+void PacketFilter::Act() {}
+
+UnconstrainedPortInterface* PacketFilter::GetRxPort() {
+ return input_->GetRxPort();
+}
+
+void PacketFilter::SetTxPort(ConstrainedPortInterface* port) {
+ output_tx_port_ = port;
+}
+
+} // namespace simulator
+} // namespace net
« no previous file with comments | « net/quic/test_tools/simulator/packet_filter.h ('k') | net/quic/test_tools/simulator/simulator_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698