OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #include "base/allocator/type_profiler.h" | |
6 | |
7 #if defined(TYPE_PROFILING) | |
8 | |
9 namespace base { | |
10 namespace type_profiler { | |
11 | |
12 static InterceptFunction* g_new_intercept = NULL; | |
13 static InterceptFunction* g_delete_intercept = NULL; | |
14 | |
15 void SetInterceptFunctions(InterceptFunction* new_intercept, | |
jar (doing other things)
2012/09/02 01:37:11
You added a comment on IsInterceptFunctionAvailabl
Dai Mikurube (NOT FULLTIME)
2012/09/03 08:16:30
ContentMainRunnerImpl::Initialize (content/app/con
| |
16 InterceptFunction* delete_intercept) { | |
17 g_new_intercept = new_intercept; | |
18 g_delete_intercept = delete_intercept; | |
19 } | |
20 | |
21 // This function is not thread safe. Use it only when SetInterceptFunctions() | |
22 // is called in a single-threaded status such as type_profiler_unittests. | |
jar (doing other things)
2012/09/02 01:37:11
This comment should appear in the header, rather t
Dai Mikurube (NOT FULLTIME)
2012/09/03 08:16:30
Done.
| |
23 bool IsInterceptFunctionsAvailable() { | |
24 return g_new_intercept != NULL || g_delete_intercept != NULL; | |
25 } | |
26 | |
27 } // namespace type_profiler | |
28 } // namespace base | |
29 | |
30 void* __op_new_intercept__(void* ptr, | |
31 size_t size, | |
32 const std::type_info& type) { | |
33 base::type_profiler::InterceptFunction* new_intercept = | |
jar (doing other things)
2012/09/02 01:37:11
As noted above, this is a racy assignment, relativ
Dai Mikurube (NOT FULLTIME)
2012/09/03 08:16:30
It is because of maruel's suggestion...
http://co
jar (doing other things)
2012/09/04 17:40:38
I put comments into the thread you suggested.
My
| |
34 base::type_profiler::g_new_intercept; | |
35 if (new_intercept) | |
36 return new_intercept(ptr, size, type); | |
37 | |
38 return ptr; | |
39 } | |
40 | |
41 void* __op_delete_intercept__(void* ptr, | |
42 size_t size, | |
43 const std::type_info& type) { | |
44 base::type_profiler::InterceptFunction* delete_intercept = | |
45 base::type_profiler::g_delete_intercept; | |
46 if (delete_intercept) | |
47 return delete_intercept(ptr, size, type); | |
48 | |
49 return ptr; | |
50 } | |
51 | |
52 #endif // defined(TYPE_PROFILING) | |
OLD | NEW |