15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef BASE_ALLOCATOR_TYPE_PROFILER_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define BASE_ALLOCATOR_TYPE_PROFILER_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(TYPE_PROFILING) 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <stddef.h> // for size_t 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <typeinfo> // for std::typeinfo 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace base { 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace type_profiler { 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef void* InterceptFunction(void*, size_t, const std::type_info&); 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class InterceptFunctions { 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // It must be called only once in a process while it is in single-thread. 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // For now, ContentMainRunnerImpl::Initialize is the only supposed caller 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // of this function except for single-threaded unit tests. 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static void SetFunctions(InterceptFunction* new_intercept, 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) InterceptFunction* delete_intercept); 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) friend class TypeProfilerTest; 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // These functions are not thread safe. 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // They must be used only from single-threaded unit tests. 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static void ResetFunctions(); 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static bool IsAvailable(); 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace type_profiler 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace base 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // defined(TYPE_PROFILING) 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // BASE_ALLOCATOR_TYPE_PROFILER_H_ 41