| OLD | NEW | 
|    1 /* |    1 /* | 
|    2  *  Copyright 2015 The WebRTC Project Authors. All rights reserved. |    2  *  Copyright 2015 The WebRTC Project Authors. All rights reserved. | 
|    3  * |    3  * | 
|    4  *  Use of this source code is governed by a BSD-style license |    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 |    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 |    6  *  tree. An additional intellectual property rights grant can be found | 
|    7  *  in the file PATENTS.  All contributing project authors may |    7  *  in the file PATENTS.  All contributing project authors may | 
|    8  *  be found in the AUTHORS file in the root of the source tree. |    8  *  be found in the AUTHORS file in the root of the source tree. | 
|    9  */ |    9  */ | 
|   10  |   10  | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   56         current_time - bucket_start_time_milliseconds_ + |   56         current_time - bucket_start_time_milliseconds_ + | 
|   57         static_cast<uint32_t>(bucket_count_) * bucket_milliseconds_ - |   57         static_cast<uint32_t>(bucket_count_) * bucket_milliseconds_ - | 
|   58         available_interval_milliseconds; |   58         available_interval_milliseconds; | 
|   59     buckets_to_skip = time_to_skip / bucket_milliseconds_; |   59     buckets_to_skip = time_to_skip / bucket_milliseconds_; | 
|   60     milliseconds_to_skip = time_to_skip % bucket_milliseconds_; |   60     milliseconds_to_skip = time_to_skip % bucket_milliseconds_; | 
|   61   } else { |   61   } else { | 
|   62     buckets_to_skip = bucket_count_ - current_bucket_; |   62     buckets_to_skip = bucket_count_ - current_bucket_; | 
|   63     milliseconds_to_skip = 0u; |   63     milliseconds_to_skip = 0u; | 
|   64     available_interval_milliseconds = |   64     available_interval_milliseconds = | 
|   65         TimeDiff(current_time, initialization_time_milliseconds_); |   65         TimeDiff(current_time, initialization_time_milliseconds_); | 
 |   66     // Let one bucket interval pass after initialization before reporting. | 
 |   67     if (available_interval_milliseconds < bucket_milliseconds_) { | 
 |   68       return 0.0; | 
 |   69     } | 
|   66   } |   70   } | 
|   67   // If we're skipping all buckets that means that there have been no samples |   71   // If we're skipping all buckets that means that there have been no samples | 
|   68   // within the sampling interval so report 0. |   72   // within the sampling interval so report 0. | 
|   69   if (buckets_to_skip > bucket_count_ || |   73   if (buckets_to_skip > bucket_count_ || | 
|   70       available_interval_milliseconds == 0u) { |   74       available_interval_milliseconds == 0u) { | 
|   71     return 0.0; |   75     return 0.0; | 
|   72   } |   76   } | 
|   73   size_t start_bucket = NextBucketIndex(current_bucket_ + buckets_to_skip); |   77   size_t start_bucket = NextBucketIndex(current_bucket_ + buckets_to_skip); | 
|   74   // Only count a portion of the first bucket according to how much of the |   78   // Only count a portion of the first bucket according to how much of the | 
|   75   // first bucket is within the current interval. |   79   // first bucket is within the current interval. | 
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  139     // current_bucket_ increments. |  143     // current_bucket_ increments. | 
|  140     sample_buckets_[current_bucket_] = 0u; |  144     sample_buckets_[current_bucket_] = 0u; | 
|  141   } |  145   } | 
|  142 } |  146 } | 
|  143  |  147  | 
|  144 size_t RateTracker::NextBucketIndex(size_t bucket_index) const { |  148 size_t RateTracker::NextBucketIndex(size_t bucket_index) const { | 
|  145   return (bucket_index + 1u) % (bucket_count_ + 1u); |  149   return (bucket_index + 1u) % (bucket_count_ + 1u); | 
|  146 } |  150 } | 
|  147  |  151  | 
|  148 }  // namespace rtc |  152 }  // namespace rtc | 
| OLD | NEW |