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

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

Issue 2398603004: Fixing issue that causes STUN throttle rate to be off by a factor of 1000. (Closed)
Patch Set: Disabling new test on component builds. Created 4 years, 2 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
« no previous file with comments | « no previous file | content/browser/renderer_host/p2p/socket_host_udp_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "third_party/webrtc/base/ratelimiter.h" 9 #include "third_party/webrtc/base/ratelimiter.h"
10 #include "third_party/webrtc/base/timeutils.h" 10 #include "third_party/webrtc/base/timeutils.h"
(...skipping 13 matching lines...) Expand all
24 24
25 P2PMessageThrottler::~P2PMessageThrottler() { 25 P2PMessageThrottler::~P2PMessageThrottler() {
26 } 26 }
27 27
28 void P2PMessageThrottler::SetSendIceBandwidth(int bandwidth_kbps) { 28 void P2PMessageThrottler::SetSendIceBandwidth(int bandwidth_kbps) {
29 rate_limiter_.reset(new rtc::RateLimiter(bandwidth_kbps, 1.0)); 29 rate_limiter_.reset(new rtc::RateLimiter(bandwidth_kbps, 1.0));
30 } 30 }
31 31
32 bool P2PMessageThrottler::DropNextPacket(size_t packet_len) { 32 bool P2PMessageThrottler::DropNextPacket(size_t packet_len) {
33 double now = 33 double now =
34 rtc::TimeMicros() / static_cast<double>(rtc::kNumMicrosecsPerMillisec); 34 rtc::TimeNanos() / static_cast<double>(rtc::kNumNanosecsPerSec);
35 if (!rate_limiter_->CanUse(packet_len, now)) { 35 if (!rate_limiter_->CanUse(packet_len, now)) {
36 // Exceeding the send rate, this packet should be dropped. 36 // Exceeding the send rate, this packet should be dropped.
37 return true; 37 return true;
38 } 38 }
39 39
40 rate_limiter_->Use(packet_len, now); 40 rate_limiter_->Use(packet_len, now);
41 return false; 41 return false;
42 } 42 }
43 43
44 } // namespace content 44 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/p2p/socket_host_udp_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698