summaryrefslogtreecommitdiffstats
path: root/base/tracked_objects.cc
diff options
context:
space:
mode:
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_;
}