Home | History | Annotate | Download | only in p2p
      1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_THROTTLER_H_
      6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_THROTTLER_H_
      7 
      8 #include "base/memory/scoped_ptr.h"
      9 #include "content/common/content_export.h"
     10 
     11 namespace rtc {
     12 class RateLimiter;
     13 class Timing;
     14 }
     15 
     16 namespace content {
     17 
     18 // A very simple message throtller. User of this class must drop the packet if
     19 // DropNextPacket returns false for that packet. This method verifies the
     20 // current sendrate against the required sendrate.
     21 
     22 class CONTENT_EXPORT P2PMessageThrottler {
     23  public:
     24   P2PMessageThrottler();
     25   virtual ~P2PMessageThrottler();
     26 
     27   void SetTiming(scoped_ptr<rtc::Timing> timing);
     28   bool DropNextPacket(size_t packet_len);
     29   void SetSendIceBandwidth(int bandwith_kbps);
     30 
     31  private:
     32   scoped_ptr<rtc::Timing> timing_;
     33   scoped_ptr<rtc::RateLimiter> rate_limiter_;
     34 
     35   DISALLOW_COPY_AND_ASSIGN(P2PMessageThrottler);
     36 };
     37 
     38 }  // namespace content
     39 
     40 #endif  // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_THROTTLER_H_
     41