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

Unified Diff: cc/debug/worker_thread_cost_tracker.cc

Issue 799863004: not for commit/review (thread cost tracker) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 | « cc/debug/worker_thread_cost_tracker.h ('k') | cc/resources/tile_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/debug/worker_thread_cost_tracker.cc
diff --git a/cc/debug/worker_thread_cost_tracker.cc b/cc/debug/worker_thread_cost_tracker.cc
new file mode 100644
index 0000000000000000000000000000000000000000..780dc71ad631b854fc4e2fa8cab14a98cbf5bea3
--- /dev/null
+++ b/cc/debug/worker_thread_cost_tracker.cc
@@ -0,0 +1,59 @@
+// Copyright 2014 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 "cc/debug/worker_thread_cost_tracker.h"
+
+#include "base/logging.h"
+
+namespace cc {
+
+WorkerThreadCostTracker::WorkerThreadCostTracker() : source_frame_number_(0) {
+}
+
+WorkerThreadCostTracker::~WorkerThreadCostTracker() {
+}
+
+scoped_ptr<WorkerThreadCostTracker::Probe>
+WorkerThreadCostTracker::CreateProbe() {
+ return make_scoped_ptr(new Probe(this, source_frame_number_));
+}
+
+WorkerThreadCostTracker::Probe::Probe(WorkerThreadCostTracker* tracker,
+ int tracked_source_frame_number)
+ : tracker_(tracker),
+ tracked_source_frame_number_(tracked_source_frame_number),
+ tracker_thread_id_(base::PlatformThread::CurrentId()),
+ started_(false) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+}
+
+WorkerThreadCostTracker::Probe::~Probe() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(!started_);
+ if (tracker_->source_frame_number_ == tracked_source_frame_number_)
+ tracker_->add_cost(cost_);
+}
+
+void WorkerThreadCostTracker::Probe::Start(int source_frame_number) {
+ DCHECK(!started_);
+ // If this start request is for a wrong frame number, abort.
+ if (source_frame_number != tracked_source_frame_number_)
+ return;
+ // If this is being run on the same thread as the main tracker (i.e. this is
+ // not a worker thread), abort.
+ if (tracker_thread_id_ == base::PlatformThread::CurrentId())
+ return;
+
+ start_ = base::TimeTicks::HighResNow();
+ started_ = true;
+}
+
+void WorkerThreadCostTracker::Probe::Stop() {
+ if (!started_)
+ return;
+ cost_ = base::TimeTicks::HighResNow() - start_;
+ started_ = false;
+}
+
+} // namespace cc
« no previous file with comments | « cc/debug/worker_thread_cost_tracker.h ('k') | cc/resources/tile_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698