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

Unified Diff: components/scheduler/renderer/coarse_duration_timer.cc

Issue 1898233002: Report expected task queueing time via UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Super rough alternative approach. Created 4 years, 7 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
Index: components/scheduler/renderer/coarse_duration_timer.cc
diff --git a/components/scheduler/renderer/coarse_duration_timer.cc b/components/scheduler/renderer/coarse_duration_timer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9c58f39b8b71e9884c574d0ebe158609ac4d3b4f
--- /dev/null
+++ b/components/scheduler/renderer/coarse_duration_timer.cc
@@ -0,0 +1,39 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/scheduler/renderer/coarse_duration_timer.h"
+
+#include "base/message_loop/message_loop.h"
+
+namespace scheduler {
+
+void CoarseDurationTimer::OnUpdateRecentTime(base::TimeTicks recent_time) {
+ most_recent_time_ = recent_time;
+ if (state_ == State::WITHIN_INTERVAL_NEEDS_START) {
+ start_time_ = recent_time;
+ state_ = State::WITHIN_INTERVAL;
+ }
+}
+
+void CoarseDurationTimer::BeginInterval() {
+ // DCHECK(state_ == State::OUTSIDE_INTERVAL);
+ state_ = State::WITHIN_INTERVAL_NEEDS_START;
+}
+
+base::TimeDelta CoarseDurationTimer::EndInterval() {
+ base::TimeDelta duration;
+ // DCHECK(state_ != State::OUTSIDE_INTERVAL);
+
+ // If we haven't received a single time update within this interval, report
+ // a duration of 0.
+ if (state_ != State::WITHIN_INTERVAL_NEEDS_START)
+ duration = most_recent_time_ - start_time_;
+ state_ = State::OUTSIDE_INTERVAL;
+
+ if (!duration.is_zero())
+ LOG(ERROR) << "DURATION IS " << duration.InMillisecondsF();
+ return duration;
+}
+
+} // namespace scheduler

Powered by Google App Engine
This is Rietveld 408576698