LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/base - sequenced_task_checker_impl.cc (source / functions) Hit Total Coverage
Test: output.info Lines: 0 22 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2016 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             : 
      11             : #include "webrtc/base/sequenced_task_checker_impl.h"
      12             : 
      13             : #if defined(WEBRTC_MAC)
      14             : #include <dispatch/dispatch.h>
      15             : #endif
      16             : 
      17             : #include "webrtc/base/platform_thread.h"
      18             : #include "webrtc/base/sequenced_task_checker.h"
      19             : #include "webrtc/base/task_queue.h"
      20             : 
      21             : namespace rtc {
      22             : 
      23           0 : SequencedTaskCheckerImpl::SequencedTaskCheckerImpl()
      24           0 :     : attached_(true), valid_queue_(TaskQueue::Current()) {}
      25             : 
      26           0 : SequencedTaskCheckerImpl::~SequencedTaskCheckerImpl() {}
      27             : 
      28           0 : bool SequencedTaskCheckerImpl::CalledSequentially() const {
      29           0 :   QueueId current_queue = TaskQueue::Current();
      30             : #if defined(WEBRTC_MAC)
      31             :   // If we're not running on a TaskQueue, use the system dispatch queue
      32             :   // label as an identifier.
      33             :   if (current_queue == nullptr) {
      34             : #ifdef DISPATCH_CURRENT_QUEUE_LABEL
      35             :     // defined in 10.9
      36             :     current_queue = dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL);
      37             : #else
      38             :     // MacOS 10.9 or less; not available >10.9
      39             :     dispatch_queue_t currentQueue = dispatch_get_current_queue();
      40             :     current_queue = dispatch_queue_get_label(currentQueue);
      41             : #endif
      42             :   }
      43             : #endif
      44           0 :   CritScope scoped_lock(&lock_);
      45           0 :   if (!attached_) {  // true if previously detached.
      46           0 :     valid_queue_ = current_queue;
      47           0 :     attached_ = true;
      48             :   }
      49           0 :   if (!valid_queue_)
      50           0 :     return thread_checker_.CalledOnValidThread();
      51           0 :   return valid_queue_ == current_queue;
      52             : }
      53             : 
      54           0 : void SequencedTaskCheckerImpl::Detach() {
      55           0 :   CritScope scoped_lock(&lock_);
      56           0 :   attached_ = false;
      57           0 :   valid_queue_ = nullptr;
      58           0 :   thread_checker_.DetachFromThread();
      59           0 : }
      60             : 
      61             : namespace internal {
      62             : 
      63           0 : SequencedTaskCheckerScope::SequencedTaskCheckerScope(
      64             :     const SequencedTaskChecker* checker) {
      65           0 :   RTC_DCHECK(checker->CalledSequentially());
      66           0 : }
      67             : 
      68           0 : SequencedTaskCheckerScope::~SequencedTaskCheckerScope() {}
      69             : 
      70             : }  // namespace internal
      71             : }  // namespace rtc

Generated by: LCOV version 1.13