Fix emulator build error
[platform/framework/web/chromium-efl.git] / base / profiler / sampling_profiler_thread_token.h
1 // Copyright 2019 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BASE_PROFILER_SAMPLING_PROFILER_THREAD_TOKEN_H_
6 #define BASE_PROFILER_SAMPLING_PROFILER_THREAD_TOKEN_H_
7
8 #include "base/base_export.h"
9 #include "base/threading/platform_thread.h"
10 #include "build/build_config.h"
11 #include "third_party/abseil-cpp/absl/types/optional.h"
12
13 #if BUILDFLAG(IS_ANDROID)
14 #include <pthread.h>
15 #elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
16 #include <stdint.h>
17 #endif
18
19 namespace base {
20
21 // SamplingProfilerThreadToken represents the thread identifier(s) required by
22 // sampling profiler to operate on a thread. PlatformThreadId is needed for all
23 // platforms, while Android also requires a pthread_t to pass to pthread
24 // functions used to obtain the stack base address.
25 struct SamplingProfilerThreadToken {
26   PlatformThreadId id;
27 #if BUILDFLAG(IS_ANDROID)
28   pthread_t pthread_id;
29 #elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
30   // Due to the sandbox, we can only retrieve the stack base address for the
31   // current thread. We must grab it during
32   // GetSamplingProfilerCurrentThreadToken() and not try to get it later.
33   absl::optional<uintptr_t> stack_base_address;
34 #endif
35 };
36
37 BASE_EXPORT SamplingProfilerThreadToken GetSamplingProfilerCurrentThreadToken();
38
39 }  // namespace base
40
41 #endif  // BASE_PROFILER_SAMPLING_PROFILER_THREAD_TOKEN_H_