summaryrefslogtreecommitdiffstats
path: root/base/tracked_objects.cc
diff options
context:
space:
mode:
authorvadimt <vadimt@chromium.org>2014-10-28 13:14:20 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-28 20:14:53 +0000
commit20175533a430be7798d031992b83a0b4f043e939 (patch)
treefce212f2f308fadcc66e13d19e2bd49d948e27f1 /base/tracked_objects.cc
parentefc205007b618ce5fbd2c2a0f98e9bff0a2a19c1 (diff)
downloadchromium_src-20175533a430be7798d031992b83a0b4f043e939.zip
chromium_src-20175533a430be7798d031992b83a0b4f043e939.tar.gz
chromium_src-20175533a430be7798d031992b83a0b4f043e939.tar.bz2
Creating infrastructure for profiler instrumentation only in developer build and Canary channel.
This introduces TrackingProfile class that is equivalent to ScopedProfile what tracking is enabled and does nothing otherwise. There is an idea to remove the single-parametered ScopedProfile constructor, but for this CL, I’m leaving it. Otherwise, I’d have to replace ~100 ScopedProfile instantiations throughout the code with TrackingProfile, and the substantial changes would be lost in these changes. I’ll do this in a separate CL. I replaced one ScopedProfile just to make sure this will compile. BUG=401560 TBR=asanka@chromium.org Review URL: https://codereview.chromium.org/663093005 Cr-Commit-Position: refs/heads/master@{#301695}
Diffstat (limited to 'base/tracked_objects.cc')
-rw-r--r--base/tracked_objects.cc42
1 files changed, 29 insertions, 13 deletions
diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc
index 659d421..4fe88512 100644
--- a/base/tracked_objects.cc
+++ b/base/tracked_objects.cc
@@ -854,16 +854,32 @@ void ThreadData::ShutdownSingleThreadedCleanup(bool leak) {
//------------------------------------------------------------------------------
TaskStopwatch::TaskStopwatch()
- : start_time_(ThreadData::Now()),
- current_thread_data_(ThreadData::Get()),
+ : wallclock_duration_ms_(0),
+ current_thread_data_(NULL),
excluded_duration_ms_(0),
parent_(NULL) {
#if DCHECK_IS_ON
- state_ = RUNNING;
+ state_ = CREATED;
child_ = NULL;
#endif
+}
+
+TaskStopwatch::~TaskStopwatch() {
+#if DCHECK_IS_ON
+ DCHECK(state_ != RUNNING);
+ DCHECK(child_ == NULL);
+#endif
+}
+
+void TaskStopwatch::Start() {
+#if DCHECK_IS_ON
+ DCHECK(state_ == CREATED);
+ state_ = RUNNING;
+#endif
+
+ start_time_ = ThreadData::Now();
- wallclock_duration_ms_ = 0;
+ current_thread_data_ = ThreadData::Get();
if (!current_thread_data_)
return;
@@ -878,13 +894,6 @@ TaskStopwatch::TaskStopwatch()
current_thread_data_->current_stopwatch_ = this;
}
-TaskStopwatch::~TaskStopwatch() {
-#if DCHECK_IS_ON
- DCHECK(state_ != RUNNING);
- DCHECK(child_ == NULL);
-#endif
-}
-
void TaskStopwatch::Stop() {
const TrackedTime end_time = ThreadData::Now();
#if DCHECK_IS_ON
@@ -910,12 +919,15 @@ void TaskStopwatch::Stop() {
DCHECK(parent_->child_ == this);
parent_->child_ = NULL;
#endif
- parent_->excluded_duration_ms_ +=
- wallclock_duration_ms_;
+ parent_->excluded_duration_ms_ += wallclock_duration_ms_;
parent_ = NULL;
}
TrackedTime TaskStopwatch::StartTime() const {
+#if DCHECK_IS_ON
+ DCHECK(state_ != CREATED);
+#endif
+
return start_time_;
}
@@ -928,6 +940,10 @@ int32 TaskStopwatch::RunDurationMs() const {
}
ThreadData* TaskStopwatch::GetThreadData() const {
+#if DCHECK_IS_ON
+ DCHECK(state_ != CREATED);
+#endif
+
return current_thread_data_;
}