sampling_profiler_thread_token.h 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_PROFILER_SAMPLING_PROFILER_THREAD_TOKEN_H_
  5. #define BASE_PROFILER_SAMPLING_PROFILER_THREAD_TOKEN_H_
  6. #include "base/base_export.h"
  7. #include "base/threading/platform_thread.h"
  8. #include "build/build_config.h"
  9. #if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS)
  10. #include <pthread.h>
  11. #endif
  12. namespace base {
  13. // SamplingProfilerThreadToken represents the thread identifier(s) required by
  14. // sampling profiler to operate on a thread. PlatformThreadId is needed for all
  15. // platforms, while non-Mac POSIX also requires a pthread_t to pass to pthread
  16. // functions used to obtain the stack base address.
  17. struct SamplingProfilerThreadToken {
  18. PlatformThreadId id;
  19. #if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS)
  20. pthread_t pthread_id;
  21. #endif
  22. };
  23. BASE_EXPORT SamplingProfilerThreadToken GetSamplingProfilerCurrentThreadToken();
  24. } // namespace base
  25. #endif // BASE_PROFILER_SAMPLING_PROFILER_THREAD_TOKEN_H_