Add APIs to thumbnail_store to decompress thumbnails into SkBitmap
[chromium-blink-merge.git] / base / allocator / type_profiler.cc
blob635fbcf5ed95582f872c049a8950df6ea26ed266
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"
9 #include <assert.h>
11 namespace {
13 void* NopIntercept(void* ptr, size_t size, const std::type_info& type) {
14 return ptr;
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,
23 size_t size,
24 const std::type_info& type) {
25 return g_new_intercept(ptr, size, type);
28 void* __op_delete_intercept__(void* ptr,
29 size_t size,
30 const std::type_info& type) {
31 return g_delete_intercept(ptr, size, type);
34 namespace base {
35 namespace type_profiler {
37 // static
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;
49 // static
50 void InterceptFunctions::ResetFunctions() {
51 g_new_intercept = NopIntercept;
52 g_delete_intercept = NopIntercept;
55 // static
56 bool InterceptFunctions::IsAvailable() {
57 return g_new_intercept != NopIntercept || g_delete_intercept != NopIntercept;
60 } // namespace type_profiler
61 } // namespace base
63 #endif // defined(TYPE_PROFILING)