• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2021 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 #include "net/dcsctp/tx/retransmission_error_counter.h"
11 
12 #include "absl/strings/string_view.h"
13 #include "rtc_base/logging.h"
14 
15 namespace dcsctp {
Increment(absl::string_view reason)16 bool RetransmissionErrorCounter::Increment(absl::string_view reason) {
17   ++counter_;
18   if (limit_.has_value() && counter_ > limit_.value()) {
19     RTC_DLOG(LS_INFO) << log_prefix_ << reason
20                       << ", too many retransmissions, counter=" << counter_;
21     return false;
22   }
23 
24   RTC_DLOG(LS_VERBOSE) << log_prefix_ << reason << ", new counter=" << counter_
25                        << ", max=" << limit_.value_or(-1);
26   return true;
27 }
28 
Clear()29 void RetransmissionErrorCounter::Clear() {
30   if (counter_ > 0) {
31     RTC_DLOG(LS_VERBOSE) << log_prefix_
32                          << "recovered from counter=" << counter_;
33     counter_ = 0;
34   }
35 }
36 
37 }  // namespace dcsctp
38