| Index: webrtc/base/thread_scope.h
 | 
| diff --git a/webrtc/base/thread_scope.h b/webrtc/base/thread_scope.h
 | 
| new file mode 100644
 | 
| index 0000000000000000000000000000000000000000..599922572b129b3b525fc7dd6e3b72bdc613a2f1
 | 
| --- /dev/null
 | 
| +++ b/webrtc/base/thread_scope.h
 | 
| @@ -0,0 +1,57 @@
 | 
| +/*
 | 
| + *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
 | 
| + *
 | 
| + *  Use of this source code is governed by a BSD-style license
 | 
| + *  that can be found in the LICENSE file in the root of the source
 | 
| + *  tree. An additional intellectual property rights grant can be found
 | 
| + *  in the file PATENTS.  All contributing project authors may
 | 
| + *  be found in the AUTHORS file in the root of the source tree.
 | 
| + */
 | 
| +
 | 
| +#ifndef WEBRTC_BASE_THREAD_SCOPE_H_
 | 
| +#define WEBRTC_BASE_THREAD_SCOPE_H_
 | 
| +
 | 
| +#include "webrtc/base/checks.h"
 | 
| +// #include webrtc/base/task_queue.h"
 | 
| +#include "webrtc/base/thread.h"
 | 
| +#include "webrtc/base/thread_annotations.h"
 | 
| +#include "webrtc/base/thread_checker.h"
 | 
| +
 | 
| +namespace rtc {
 | 
| +// ThreadScope mimic CritScope.
 | 
| +class SCOPED_LOCKABLE ThreadScope {
 | 
| + public:
 | 
| +  template<typename ThreadLikeObject>
 | 
| +  explicit ThreadScope(const ThreadLikeObject* thread)
 | 
| +      EXCLUSIVE_LOCK_FUNCTION(thread) {}
 | 
| +
 | 
| +  static bool IsCurrent(const Thread* thread) {
 | 
| +    return thread->IsCurrent();
 | 
| +  }
 | 
| +  static bool IsCurrent(const ThreadChecker* checker) {
 | 
| +    return checker->CalledOnValidThread();
 | 
| +  }
 | 
| +  /*
 | 
| +  static bool IsCurrent(const TaskQueue* queue) {
 | 
| +    return queue->IsCurrent();
 | 
| +  } */
 | 
| +
 | 
| +  ~ThreadScope() UNLOCK_FUNCTION() {}
 | 
| + private:
 | 
| +  RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(ThreadScope);
 | 
| +};
 | 
| +
 | 
| +}  // namespace rtc
 | 
| +
 | 
| +// Macro so that DCHECK report correct __FILE__ and __LINE__
 | 
| +#define RTC_DCHECK_RUN_ON(thread_like_object) \
 | 
| +  rtc::ThreadScope check(thread_like_object); \
 | 
| +  RTC_DCHECK(rtc::ThreadScope::IsCurrent(thread_like_object))
 | 
| +
 | 
| +// Forward macros to avoid word 'lock' when annotating threads
 | 
| +#define RTC_MUST_RUN_ON(thread_like_object) \
 | 
| +  EXCLUSIVE_LOCKS_REQUIRED(thread_like_object)
 | 
| +#define RTC_MUST_BE_ACCESSED_FROM(thread_like_object) \
 | 
| +  GUARDED_BY(thread_like_object)
 | 
| +
 | 
| +#endif  // WEBRTC_BASE_THREAD_SCOPE_H_
 | 
| 
 |