• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 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_NATIVE_UNWINDER_ANDROID_MEMORY_REGIONS_MAP_H_
6 #define BASE_PROFILER_NATIVE_UNWINDER_ANDROID_MEMORY_REGIONS_MAP_H_
7 
8 #include <memory>
9 
10 namespace unwindstack {
11 class Maps;
12 class Memory;
13 }  // namespace unwindstack
14 
15 namespace base {
16 
17 // NativeUnwinderAndroidMemoryRegionsMap is an opaque interface that hides
18 // concrete libunwindstack types, i.e. `unwindstack::Maps` and
19 // `unwindstack::Memory`. By introducing the interface, chrome code can
20 // pass the underlying instances around without referencing libunwindstack.
21 // NativeUnwinderAndroidMemoryRegionsMap's implementation must live in the
22 // stack_unwinder dynamic feature module.
23 class NativeUnwinderAndroidMemoryRegionsMap {
24  public:
25   NativeUnwinderAndroidMemoryRegionsMap() = default;
26   virtual ~NativeUnwinderAndroidMemoryRegionsMap() = default;
27 
28   NativeUnwinderAndroidMemoryRegionsMap(
29       const NativeUnwinderAndroidMemoryRegionsMap&) = delete;
30   NativeUnwinderAndroidMemoryRegionsMap& operator=(
31       const NativeUnwinderAndroidMemoryRegionsMap&) = delete;
32 
33   virtual unwindstack::Maps* GetMaps() = 0;
34   virtual unwindstack::Memory* GetMemory() = 0;
35   // This function exists to provide a method for
36   // `LibunwindstackUnwinderAndroid` to take the ownership of `Memory`.
37   virtual std::unique_ptr<unwindstack::Memory> TakeMemory() = 0;
38 };
39 
40 }  // namespace base
41 
42 #endif  // BASE_PROFILER_NATIVE_UNWINDER_ANDROID_MEMORY_REGIONS_MAP_H_
43