1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #if defined(TYPE_PROFILING)
7 #include "base/allocator/type_profiler.h"
13 void* NopIntercept(void* ptr
, size_t size
, const std::type_info
& type
) {
17 base::type_profiler::InterceptFunction
* g_new_intercept
= NopIntercept
;
18 base::type_profiler::InterceptFunction
* g_delete_intercept
= NopIntercept
;
22 void* __op_new_intercept__(void* ptr
,
24 const std::type_info
& type
) {
25 return g_new_intercept(ptr
, size
, type
);
28 void* __op_delete_intercept__(void* ptr
,
30 const std::type_info
& type
) {
31 return g_delete_intercept(ptr
, size
, type
);
35 namespace type_profiler
{
38 void InterceptFunctions::SetFunctions(InterceptFunction
* new_intercept
,
39 InterceptFunction
* delete_intercept
) {
40 // Don't use DCHECK, as this file is injected into targets
41 // that do not and should not depend on base/base.gyp:base
42 assert(g_new_intercept
== NopIntercept
);
43 assert(g_delete_intercept
== NopIntercept
);
45 g_new_intercept
= new_intercept
;
46 g_delete_intercept
= delete_intercept
;
50 void InterceptFunctions::ResetFunctions() {
51 g_new_intercept
= NopIntercept
;
52 g_delete_intercept
= NopIntercept
;
56 bool InterceptFunctions::IsAvailable() {
57 return g_new_intercept
!= NopIntercept
|| g_delete_intercept
!= NopIntercept
;
60 } // namespace type_profiler
63 #endif // defined(TYPE_PROFILING)