Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(850)

Unified Diff: base/tracked_objects.cc

Issue 669813003: Update from chromium https://crrev.com/301725/ (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/tracked_objects.h ('k') | base/tracked_objects_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/tracked_objects.cc
diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc
index 659d421017e7c7ce9e071b8554c927f2a35ec323..4fe8851297254fd18228282d7ae8c4ff08592a87 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_;
}
« no previous file with comments | « base/tracked_objects.h ('k') | base/tracked_objects_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698