diff options
-rw-r--r-- | base/allocator/allocator_shim.cc | 3 | ||||
-rw-r--r-- | base/profiler/alternate_timer.cc | 9 | ||||
-rw-r--r-- | base/profiler/alternate_timer.h | 12 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_log.cc | 3 |
4 files changed, 22 insertions, 5 deletions
diff --git a/base/allocator/allocator_shim.cc b/base/allocator/allocator_shim.cc index d61a9a4..075828d 100644 --- a/base/allocator/allocator_shim.cc +++ b/base/allocator/allocator_shim.cc @@ -270,7 +270,8 @@ extern "C" int _heap_init() { GetenvBeforeMain(tracked_objects::kAlternateProfilerTime); if (profiling && *profiling == '1') { tracked_objects::SetAlternateTimeSource( - tcmalloc::ThreadCache::GetBytesAllocatedOnCurrentThread); + tcmalloc::ThreadCache::GetBytesAllocatedOnCurrentThread, + tracked_objects::TIME_SOURCE_TYPE_TCMALLOC); } return 1; diff --git a/base/profiler/alternate_timer.cc b/base/profiler/alternate_timer.cc index abf9180..4eba89c 100644 --- a/base/profiler/alternate_timer.cc +++ b/base/profiler/alternate_timer.cc @@ -9,6 +9,8 @@ namespace { tracked_objects::NowFunction* g_time_function = NULL; +tracked_objects::TimeSourceType g_time_source_type = + tracked_objects::TIME_SOURCE_TYPE_WALL_TIME; } // anonymous namespace @@ -18,13 +20,18 @@ const char kAlternateProfilerTime[] = "CHROME_PROFILER_TIME"; // Set an alternate timer function to replace the OS time function when // profiling. -void SetAlternateTimeSource(NowFunction* now_function) { +void SetAlternateTimeSource(NowFunction* now_function, TimeSourceType type) { DCHECK_EQ(reinterpret_cast<NowFunction*>(NULL), g_time_function); g_time_function = now_function; + g_time_source_type = type; } NowFunction* GetAlternateTimeSource() { return g_time_function; } +TimeSourceType GetTimeSourceType() { + return g_time_source_type; +} + } // namespace tracked_objects diff --git a/base/profiler/alternate_timer.h b/base/profiler/alternate_timer.h index 778dc62..eb0022d 100644 --- a/base/profiler/alternate_timer.h +++ b/base/profiler/alternate_timer.h @@ -12,6 +12,11 @@ namespace tracked_objects { +enum BASE_EXPORT TimeSourceType { + TIME_SOURCE_TYPE_WALL_TIME, + TIME_SOURCE_TYPE_TCMALLOC +}; + // Provide type for an alternate timer function. typedef unsigned int NowFunction(); @@ -24,11 +29,14 @@ extern const char kAlternateProfilerTime[]; // profiling. Typically this is called by an allocator that is providing a // function that indicates how much memory has been allocated on any given // thread. -void SetAlternateTimeSource(NowFunction* now_function); +void SetAlternateTimeSource(NowFunction* now_function, TimeSourceType type); // Gets the pointer to a function that was set via SetAlternateTimeSource(). // Returns NULL if no set was done prior to calling GetAlternateTimeSource. -BASE_EXPORT NowFunction* GetAlternateTimeSource(); +NowFunction* GetAlternateTimeSource(); + +// Returns the type of the currently set time source. +BASE_EXPORT TimeSourceType GetTimeSourceType(); } // namespace tracked_objects diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc index 36be84f..b79ecef1 100644 --- a/chrome/browser/metrics/metrics_log.cc +++ b/chrome/browser/metrics/metrics_log.cc @@ -787,7 +787,8 @@ void MetricsLog::RecordProfilerData( content::ProcessType process_type) { DCHECK(!locked()); - if (tracked_objects::GetAlternateTimeSource()) { + if (tracked_objects::GetTimeSourceType() != + tracked_objects::TIME_SOURCE_TYPE_WALL_TIME) { // We currently only support the default time source, wall clock time. return; } |