michael@0: // Copyright (c) 2012 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: // This is a glue file, which allows third party code to call into our profiler michael@0: // without having to include most any functions from base. michael@0: michael@0: #ifndef BASE_PROFILER_ALTERNATE_TIMER_H_ michael@0: #define BASE_PROFILER_ALTERNATE_TIMER_H_ michael@0: michael@0: #include "base/base_export.h" michael@0: michael@0: namespace tracked_objects { michael@0: michael@0: enum TimeSourceType { michael@0: TIME_SOURCE_TYPE_WALL_TIME, michael@0: TIME_SOURCE_TYPE_TCMALLOC michael@0: }; michael@0: michael@0: // Provide type for an alternate timer function. michael@0: typedef unsigned int NowFunction(); michael@0: michael@0: // Environment variable name that is used to activate alternate timer profiling michael@0: // (such as using TCMalloc allocations to provide a pseudo-timer) for tasks michael@0: // instead of wall clock profiling. michael@0: BASE_EXPORT extern const char kAlternateProfilerTime[]; michael@0: michael@0: // Set an alternate timer function to replace the OS time function when michael@0: // profiling. Typically this is called by an allocator that is providing a michael@0: // function that indicates how much memory has been allocated on any given michael@0: // thread. michael@0: BASE_EXPORT void SetAlternateTimeSource(NowFunction* now_function, michael@0: TimeSourceType type); michael@0: michael@0: // Gets the pointer to a function that was set via SetAlternateTimeSource(). michael@0: // Returns NULL if no set was done prior to calling GetAlternateTimeSource. michael@0: NowFunction* GetAlternateTimeSource(); michael@0: michael@0: // Returns the type of the currently set time source. michael@0: BASE_EXPORT TimeSourceType GetTimeSourceType(); michael@0: michael@0: } // namespace tracked_objects michael@0: michael@0: #endif // BASE_PROFILER_ALTERNATE_TIMER_H_