#include "chrome/common/profiler/native_unwinder_android_map_delegate_impl.h"
#include "base/check_op.h"
#include "base/profiler/native_unwinder_android.h"
NativeUnwinderAndroidMapDelegateImpl::NativeUnwinderAndroidMapDelegateImpl() =
default;
NativeUnwinderAndroidMapDelegateImpl::~NativeUnwinderAndroidMapDelegateImpl() {
DCHECK_EQ(reference_count_, 0u);
DCHECK(!memory_regions_map_);
}
base::NativeUnwinderAndroidMemoryRegionsMap*
NativeUnwinderAndroidMapDelegateImpl::GetMapReference() {
if (reference_count_ == 0) {
DCHECK(!memory_regions_map_);
memory_regions_map_ = base::NativeUnwinderAndroid::CreateMemoryRegionsMap();
}
reference_count_++;
return memory_regions_map_.get();
}
void NativeUnwinderAndroidMapDelegateImpl::ReleaseMapReference() {
DCHECK_GT(reference_count_, 0u);
DCHECK(memory_regions_map_);
if (--reference_count_ == 0) {
memory_regions_map_.reset();
}
}