xref: /aosp_15_r20/external/cronet/base/allocator/dispatcher/internal/dispatch_data.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2022 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 #include "base/allocator/dispatcher/internal/dispatch_data.h"
6 #include "partition_alloc/partition_alloc_buildflags.h"
7 
8 namespace base::allocator::dispatcher::internal {
9 
10 #if BUILDFLAG(USE_PARTITION_ALLOC)
11 
SetAllocationObserverHooks(AllocationObserverHook * allocation_observer_hook,FreeObserverHook * free_observer_hook)12 DispatchData& DispatchData::SetAllocationObserverHooks(
13     AllocationObserverHook* allocation_observer_hook,
14     FreeObserverHook* free_observer_hook) {
15   allocation_observer_hook_ = allocation_observer_hook;
16   free_observer_hook_ = free_observer_hook;
17 
18   return *this;
19 }
20 
GetAllocationObserverHook() const21 DispatchData::AllocationObserverHook* DispatchData::GetAllocationObserverHook()
22     const {
23   return allocation_observer_hook_;
24 }
25 
GetFreeObserverHook() const26 DispatchData::FreeObserverHook* DispatchData::GetFreeObserverHook() const {
27   return free_observer_hook_;
28 }
29 #endif
30 
31 #if BUILDFLAG(USE_ALLOCATOR_SHIM)
SetAllocatorDispatch(AllocatorDispatch * allocator_dispatch)32 DispatchData& DispatchData::SetAllocatorDispatch(
33     AllocatorDispatch* allocator_dispatch) {
34   allocator_dispatch_ = allocator_dispatch;
35   return *this;
36 }
37 
GetAllocatorDispatch() const38 AllocatorDispatch* DispatchData::GetAllocatorDispatch() const {
39   return allocator_dispatch_;
40 }
41 #endif
42 }  // namespace base::allocator::dispatcher::internal
43