• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
7 #include "partition_alloc/buildflags.h"
8 
9 namespace base::allocator::dispatcher::internal {
10 
11 #if PA_BUILDFLAG(USE_PARTITION_ALLOC)
12 
SetAllocationObserverHooks(AllocationObserverHook * allocation_observer_hook,FreeObserverHook * free_observer_hook)13 DispatchData& DispatchData::SetAllocationObserverHooks(
14     AllocationObserverHook* allocation_observer_hook,
15     FreeObserverHook* free_observer_hook) {
16   allocation_observer_hook_ = allocation_observer_hook;
17   free_observer_hook_ = free_observer_hook;
18 
19   return *this;
20 }
21 
GetAllocationObserverHook() const22 DispatchData::AllocationObserverHook* DispatchData::GetAllocationObserverHook()
23     const {
24   return allocation_observer_hook_;
25 }
26 
GetFreeObserverHook() const27 DispatchData::FreeObserverHook* DispatchData::GetFreeObserverHook() const {
28   return free_observer_hook_;
29 }
30 #endif
31 
32 #if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
SetAllocatorDispatch(AllocatorDispatch * allocator_dispatch)33 DispatchData& DispatchData::SetAllocatorDispatch(
34     AllocatorDispatch* allocator_dispatch) {
35   allocator_dispatch_ = allocator_dispatch;
36   return *this;
37 }
38 
GetAllocatorDispatch() const39 AllocatorDispatch* DispatchData::GetAllocatorDispatch() const {
40   return allocator_dispatch_;
41 }
42 #endif
43 }  // namespace base::allocator::dispatcher::internal
44