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

Unified Diff: net/quic/test_tools/simulator/traffic_policer.h

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/simulator_test.cc ('k') | net/quic/test_tools/simulator/traffic_policer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/test_tools/simulator/traffic_policer.h
diff --git a/net/quic/test_tools/simulator/traffic_policer.h b/net/quic/test_tools/simulator/traffic_policer.h
index caa585594ce702fbe9d2104ad72e91a06f0eca37..3a218ae0a1af730640f4f558bd0eb48b0ee32fb8 100644
--- a/net/quic/test_tools/simulator/traffic_policer.h
+++ b/net/quic/test_tools/simulator/traffic_policer.h
@@ -7,6 +7,7 @@
#include <unordered_map>
+#include "net/quic/test_tools/simulator/packet_filter.h"
#include "net/quic/test_tools/simulator/port.h"
namespace net {
@@ -16,8 +17,8 @@ namespace simulator {
// passing through. It wraps around an input port and exposes an output port.
// Only the traffic from input to the output is policed, so in case when
// bidirectional policing is desired, two policers have to be used. The flows
-// are hashed by the source only.
-class TrafficPolicer : public Actor, public ConstrainedPortInterface {
+// are hashed by the destination only.
+class TrafficPolicer : public PacketFilter {
public:
TrafficPolicer(Simulator* simulator,
std::string name,
@@ -27,28 +28,10 @@ class TrafficPolicer : public Actor, public ConstrainedPortInterface {
Endpoint* input);
~TrafficPolicer() override;
- Endpoint* input() { return input_; }
- Endpoint* output() { return &output_; }
-
- void AcceptPacket(std::unique_ptr<Packet> packet) override;
- QuicTime::Delta TimeUntilAvailable() override;
-
- void Act() override;
+ protected:
+ bool FilterPacket(const Packet& packet) override;
private:
- class Output : public Endpoint {
- public:
- explicit Output(TrafficPolicer* policer);
- ~Output() override;
-
- UnconstrainedPortInterface* GetRxPort() override;
- void SetTxPort(ConstrainedPortInterface* port) override;
- void Act() override;
-
- private:
- TrafficPolicer* policer_;
- };
-
// Refill the token buckets with all the tokens that have been granted since
// |last_refill_time_|.
void Refill();
@@ -60,11 +43,6 @@ class TrafficPolicer : public Actor, public ConstrainedPortInterface {
// The time at which the token buckets were last refilled.
QuicTime last_refill_time_;
- ConstrainedPortInterface* output_tx_port_;
-
- Endpoint* input_;
- Output output_;
-
// Maps each destination to the number of tokens it has left.
std::unordered_map<std::string, QuicByteCount> token_buckets_;
« no previous file with comments | « net/quic/test_tools/simulator/simulator_test.cc ('k') | net/quic/test_tools/simulator/traffic_policer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698