socket_host_throttler.h revision 68043e1e95eeb07d5cae7aca370b26518b0867d6
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
11namespace talk_base {
12class RateLimiter;
13class Timing;
14}
15
16namespace 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
22class CONTENT_EXPORT P2PMessageThrottler {
23 public:
24  P2PMessageThrottler();
25  virtual ~P2PMessageThrottler();
26
27  void SetTiming(scoped_ptr<talk_base::Timing> timing);
28  bool DropNextPacket(size_t packet_len);
29  void SetSendIceBandwidth(int bandwith_kbps);
30
31 private:
32  scoped_ptr<talk_base::Timing> timing_;
33  scoped_ptr<talk_base::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