diff options
author | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-27 00:36:49 +0000 |
---|---|---|
committer | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-27 00:36:49 +0000 |
commit | 8f82968945b4e4567f961dab42c9f291b66112a5 (patch) | |
tree | a6fb901d13d0062bb91e77049001451c66ab93b3 /base/profiler | |
parent | c239336e9507a35a758fe58f54e7b3efcf02d48c (diff) | |
download | chromium_src-8f82968945b4e4567f961dab42c9f291b66112a5.zip chromium_src-8f82968945b4e4567f961dab42c9f291b66112a5.tar.gz chromium_src-8f82968945b4e4567f961dab42c9f291b66112a5.tar.bz2 |
Explicitly track the time source type in base/profiler/alternate_timer.h
We were previously implicitly tracking the time source as either default or tcmalloc-based; but as we add more time sources (e.g. cpu time), we'll want to have explicit tracking for this.
BUG=none
TEST=none
TBR=jar@chromium.org
(Recommit of [ https://chromiumcodereview.appspot.com/10225017/ ])
Review URL: http://codereview.chromium.org/10248001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134187 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/profiler')
-rw-r--r-- | base/profiler/alternate_timer.cc | 9 | ||||
-rw-r--r-- | base/profiler/alternate_timer.h | 12 |
2 files changed, 18 insertions, 3 deletions
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 |