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

Side by Side Diff: content/browser/renderer_host/p2p/socket_host_throttler.cc

Issue 429253003: Webrtc deps roll. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/p2p/socket_host_throttler.h" 5 #include "content/browser/renderer_host/p2p/socket_host_throttler.h"
6 #include "third_party/libjingle/source/talk/base/ratelimiter.h" 6 #include "third_party/webrtc/base/ratelimiter.h"
7 #include "third_party/libjingle/source/talk/base/timing.h" 7 #include "third_party/webrtc/base/timing.h"
8 8
9 namespace content { 9 namespace content {
10 10
11 namespace { 11 namespace {
12 12
13 const int kMaxIceMessageBandwidth = 256 * 1024; 13 const int kMaxIceMessageBandwidth = 256 * 1024;
14 14
15 } // namespace 15 } // namespace
16 16
17 17
18 P2PMessageThrottler::P2PMessageThrottler() 18 P2PMessageThrottler::P2PMessageThrottler()
19 : timing_(new talk_base::Timing()), 19 : timing_(new rtc::Timing()),
20 rate_limiter_(new talk_base::RateLimiter(kMaxIceMessageBandwidth, 1.0)) { 20 rate_limiter_(new rtc::RateLimiter(kMaxIceMessageBandwidth, 1.0)) {
21 } 21 }
22 22
23 P2PMessageThrottler::~P2PMessageThrottler() { 23 P2PMessageThrottler::~P2PMessageThrottler() {
24 } 24 }
25 25
26 void P2PMessageThrottler::SetTiming(scoped_ptr<talk_base::Timing> timing) { 26 void P2PMessageThrottler::SetTiming(scoped_ptr<rtc::Timing> timing) {
27 timing_ = timing.Pass(); 27 timing_ = timing.Pass();
28 } 28 }
29 29
30 void P2PMessageThrottler::SetSendIceBandwidth(int bandwidth_kbps) { 30 void P2PMessageThrottler::SetSendIceBandwidth(int bandwidth_kbps) {
31 rate_limiter_.reset(new talk_base::RateLimiter(bandwidth_kbps, 1.0)); 31 rate_limiter_.reset(new rtc::RateLimiter(bandwidth_kbps, 1.0));
32 } 32 }
33 33
34 bool P2PMessageThrottler::DropNextPacket(size_t packet_len) { 34 bool P2PMessageThrottler::DropNextPacket(size_t packet_len) {
35 double now = timing_->TimerNow(); 35 double now = timing_->TimerNow();
36 if (!rate_limiter_->CanUse(packet_len, now)) { 36 if (!rate_limiter_->CanUse(packet_len, now)) {
37 // Exceeding the send rate, this packet should be dropped. 37 // Exceeding the send rate, this packet should be dropped.
38 return true; 38 return true;
39 } 39 }
40 40
41 rate_limiter_->Use(packet_len, now); 41 rate_limiter_->Use(packet_len, now);
42 return false; 42 return false;
43 } 43 }
44 44
45 } // namespace content 45 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/p2p/socket_host_throttler.h ('k') | content/browser/renderer_host/p2p/socket_host_udp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698