OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 cache_lifetime_us_(cache_lifetime_us) { | 382 cache_lifetime_us_(cache_lifetime_us) { |
383 RTC_DCHECK(pc_); | 383 RTC_DCHECK(pc_); |
384 RTC_DCHECK(signaling_thread_); | 384 RTC_DCHECK(signaling_thread_); |
385 RTC_DCHECK(worker_thread_); | 385 RTC_DCHECK(worker_thread_); |
386 RTC_DCHECK(network_thread_); | 386 RTC_DCHECK(network_thread_); |
387 RTC_DCHECK_GE(cache_lifetime_us_, 0); | 387 RTC_DCHECK_GE(cache_lifetime_us_, 0); |
388 pc_->SignalDataChannelCreated.connect( | 388 pc_->SignalDataChannelCreated.connect( |
389 this, &RTCStatsCollector::OnDataChannelCreated); | 389 this, &RTCStatsCollector::OnDataChannelCreated); |
390 } | 390 } |
391 | 391 |
| 392 RTCStatsCollector::~RTCStatsCollector() { |
| 393 RTC_DCHECK_EQ(num_pending_partial_reports_, 0); |
| 394 } |
| 395 |
392 void RTCStatsCollector::GetStatsReport( | 396 void RTCStatsCollector::GetStatsReport( |
393 rtc::scoped_refptr<RTCStatsCollectorCallback> callback) { | 397 rtc::scoped_refptr<RTCStatsCollectorCallback> callback) { |
394 RTC_DCHECK(signaling_thread_->IsCurrent()); | 398 RTC_DCHECK(signaling_thread_->IsCurrent()); |
395 RTC_DCHECK(callback); | 399 RTC_DCHECK(callback); |
396 callbacks_.push_back(callback); | 400 callbacks_.push_back(callback); |
397 | 401 |
398 // "Now" using a monotonically increasing timer. | 402 // "Now" using a monotonically increasing timer. |
399 int64_t cache_now_us = rtc::TimeMicros(); | 403 int64_t cache_now_us = rtc::TimeMicros(); |
400 if (cached_report_ && | 404 if (cached_report_ && |
401 cache_now_us - cache_timestamp_us_ <= cache_lifetime_us_) { | 405 cache_now_us - cache_timestamp_us_ <= cache_lifetime_us_) { |
(...skipping 21 matching lines...) Expand all Loading... |
423 rtc::Bind(&RTCStatsCollector::ProducePartialResultsOnNetworkThread, | 427 rtc::Bind(&RTCStatsCollector::ProducePartialResultsOnNetworkThread, |
424 rtc::scoped_refptr<RTCStatsCollector>(this), timestamp_us)); | 428 rtc::scoped_refptr<RTCStatsCollector>(this), timestamp_us)); |
425 } | 429 } |
426 } | 430 } |
427 | 431 |
428 void RTCStatsCollector::ClearCachedStatsReport() { | 432 void RTCStatsCollector::ClearCachedStatsReport() { |
429 RTC_DCHECK(signaling_thread_->IsCurrent()); | 433 RTC_DCHECK(signaling_thread_->IsCurrent()); |
430 cached_report_ = nullptr; | 434 cached_report_ = nullptr; |
431 } | 435 } |
432 | 436 |
| 437 void RTCStatsCollector::WaitForPendingRequest() { |
| 438 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 439 if (num_pending_partial_reports_) { |
| 440 rtc::Thread::Current()->ProcessMessages(0); |
| 441 while (num_pending_partial_reports_) { |
| 442 rtc::Thread::Current()->SleepMs(1); |
| 443 rtc::Thread::Current()->ProcessMessages(0); |
| 444 } |
| 445 } |
| 446 } |
| 447 |
433 void RTCStatsCollector::ProducePartialResultsOnSignalingThread( | 448 void RTCStatsCollector::ProducePartialResultsOnSignalingThread( |
434 int64_t timestamp_us) { | 449 int64_t timestamp_us) { |
435 RTC_DCHECK(signaling_thread_->IsCurrent()); | 450 RTC_DCHECK(signaling_thread_->IsCurrent()); |
436 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( | 451 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( |
437 timestamp_us); | 452 timestamp_us); |
438 | 453 |
439 SessionStats session_stats; | 454 SessionStats session_stats; |
440 if (pc_->session()->GetTransportStats(&session_stats)) { | 455 if (pc_->session()->GetTransportStats(&session_stats)) { |
441 std::map<std::string, CertificateStatsPair> transport_cert_stats = | 456 std::map<std::string, CertificateStatsPair> transport_cert_stats = |
442 PrepareTransportCertificateStats(session_stats); | 457 PrepareTransportCertificateStats(session_stats); |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 const std::string& type) { | 943 const std::string& type) { |
929 return CandidateTypeToRTCIceCandidateType(type); | 944 return CandidateTypeToRTCIceCandidateType(type); |
930 } | 945 } |
931 | 946 |
932 const char* DataStateToRTCDataChannelStateForTesting( | 947 const char* DataStateToRTCDataChannelStateForTesting( |
933 DataChannelInterface::DataState state) { | 948 DataChannelInterface::DataState state) { |
934 return DataStateToRTCDataChannelState(state); | 949 return DataStateToRTCDataChannelState(state); |
935 } | 950 } |
936 | 951 |
937 } // namespace webrtc | 952 } // namespace webrtc |
OLD | NEW |