1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/sandbox/chromium/base/threading/thread_checker_impl.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,43 @@ 1.4 +// Copyright (c) 2011 The Chromium Authors. All rights reserved. 1.5 +// Use of this source code is governed by a BSD-style license that can be 1.6 +// found in the LICENSE file. 1.7 + 1.8 +#ifndef BASE_THREADING_THREAD_CHECKER_IMPL_H_ 1.9 +#define BASE_THREADING_THREAD_CHECKER_IMPL_H_ 1.10 + 1.11 +#include "base/base_export.h" 1.12 +#include "base/synchronization/lock.h" 1.13 +#include "base/threading/platform_thread.h" 1.14 + 1.15 +namespace base { 1.16 + 1.17 +// Real implementation of ThreadChecker, for use in debug mode, or 1.18 +// for temporary use in release mode (e.g. to CHECK on a threading issue 1.19 +// seen only in the wild). 1.20 +// 1.21 +// Note: You should almost always use the ThreadChecker class to get the 1.22 +// right version for your build configuration. 1.23 +class BASE_EXPORT ThreadCheckerImpl { 1.24 + public: 1.25 + ThreadCheckerImpl(); 1.26 + ~ThreadCheckerImpl(); 1.27 + 1.28 + bool CalledOnValidThread() const; 1.29 + 1.30 + // Changes the thread that is checked for in CalledOnValidThread. This may 1.31 + // be useful when an object may be created on one thread and then used 1.32 + // exclusively on another thread. 1.33 + void DetachFromThread(); 1.34 + 1.35 + private: 1.36 + void EnsureThreadIdAssigned() const; 1.37 + 1.38 + mutable base::Lock lock_; 1.39 + // This is mutable so that CalledOnValidThread can set it. 1.40 + // It's guarded by |lock_|. 1.41 + mutable PlatformThreadId valid_thread_id_; 1.42 +}; 1.43 + 1.44 +} // namespace base 1.45 + 1.46 +#endif // BASE_THREADING_THREAD_CHECKER_IMPL_H_