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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/debug/worker_thread_cost_tracker.h"
6
7 #include "base/logging.h"
8
9 namespace cc {
10
11 WorkerThreadCostTracker::WorkerThreadCostTracker() : source_frame_number_(0) {
12 }
13
14 WorkerThreadCostTracker::~WorkerThreadCostTracker() {
15 }
16
17 scoped_ptr<WorkerThreadCostTracker::Probe>
18 WorkerThreadCostTracker::CreateProbe() {
19 return make_scoped_ptr(new Probe(this, source_frame_number_));
20 }
21
22 WorkerThreadCostTracker::Probe::Probe(WorkerThreadCostTracker* tracker,
23 int tracked_source_frame_number)
24 : tracker_(tracker),
25 tracked_source_frame_number_(tracked_source_frame_number),
26 tracker_thread_id_(base::PlatformThread::CurrentId()),
27 started_(false) {
28 DCHECK(thread_checker_.CalledOnValidThread());
29 }
30
31 WorkerThreadCostTracker::Probe::~Probe() {
32 DCHECK(thread_checker_.CalledOnValidThread());
33 DCHECK(!started_);
34 if (tracker_->source_frame_number_ == tracked_source_frame_number_)
35 tracker_->add_cost(cost_);
36 }
37
38 void WorkerThreadCostTracker::Probe::Start(int source_frame_number) {
39 DCHECK(!started_);
40 // If this start request is for a wrong frame number, abort.
41 if (source_frame_number != tracked_source_frame_number_)
42 return;
43 // If this is being run on the same thread as the main tracker (i.e. this is
44 // not a worker thread), abort.
45 if (tracker_thread_id_ == base::PlatformThread::CurrentId())
46 return;
47
48 start_ = base::TimeTicks::HighResNow();
49 started_ = true;
50 }
51
52 void WorkerThreadCostTracker::Probe::Stop() {
53 if (!started_)
54 return;
55 cost_ = base::TimeTicks::HighResNow() - start_;
56 started_ = false;
57 }
58
59 } // namespace cc
OLDNEW
« 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