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

Side by Side Diff: cc/scheduler/begin_frame_tracker.cc

Issue 1424703003: Kills TraceTicks, which was functionally the same as TimeTicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed win compile error. Created 5 years, 1 month 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/scheduler/begin_frame_tracker.h ('k') | components/scheduler/child/idle_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/scheduler/begin_frame_tracker.h" 5 #include "cc/scheduler/begin_frame_tracker.h"
6 6
7 namespace cc { 7 namespace cc {
8 8
9 BeginFrameTracker::BeginFrameTracker(const tracked_objects::Location& location) 9 BeginFrameTracker::BeginFrameTracker(const tracked_objects::Location& location)
10 : location_(location), 10 : location_(location),
11 location_string_(location.ToString()), 11 location_string_(location.ToString()),
12 current_updated_at_(), 12 current_updated_at_(),
13 current_args_(), 13 current_args_(),
14 current_finished_at_(base::TraceTicks::FromInternalValue(-1)) { 14 current_finished_at_(base::TimeTicks::FromInternalValue(-1)) {}
15 }
16 15
17 BeginFrameTracker::~BeginFrameTracker() { 16 BeginFrameTracker::~BeginFrameTracker() {
18 } 17 }
19 18
20 void BeginFrameTracker::Start(BeginFrameArgs new_args) { 19 void BeginFrameTracker::Start(BeginFrameArgs new_args) {
21 // Trace the frame time being passed between BeginFrameTrackers. 20 // Trace the frame time being passed between BeginFrameTrackers.
22 TRACE_EVENT_FLOW_STEP0( 21 TRACE_EVENT_FLOW_STEP0(
23 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), "BeginFrameArgs", 22 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), "BeginFrameArgs",
24 new_args.frame_time.ToInternalValue(), location_string_); 23 new_args.frame_time.ToInternalValue(), location_string_);
25 24
26 // Trace this specific begin frame tracker Start/Finish times. 25 // Trace this specific begin frame tracker Start/Finish times.
27 TRACE_EVENT_ASYNC_BEGIN2( 26 TRACE_EVENT_ASYNC_BEGIN2(
28 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), 27 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"),
29 location_string_.c_str(), new_args.frame_time.ToInternalValue(), 28 location_string_.c_str(), new_args.frame_time.ToInternalValue(),
30 "new args", new_args.AsValue(), "current args", current_args_.AsValue()); 29 "new args", new_args.AsValue(), "current args", current_args_.AsValue());
31 30
32 // Check the new BeginFrameArgs are valid and monotonically increasing. 31 // Check the new BeginFrameArgs are valid and monotonically increasing.
33 DCHECK(new_args.IsValid()); 32 DCHECK(new_args.IsValid());
34 DCHECK_LE(current_args_.frame_time, new_args.frame_time); 33 DCHECK_LE(current_args_.frame_time, new_args.frame_time);
35 34
36 DCHECK(HasFinished()) 35 DCHECK(HasFinished())
37 << "Tried to start a new frame before finishing an existing frame."; 36 << "Tried to start a new frame before finishing an existing frame.";
38 current_updated_at_ = base::TraceTicks::Now(); 37 current_updated_at_ = base::TimeTicks::Now();
39 current_args_ = new_args; 38 current_args_ = new_args;
40 current_finished_at_ = base::TraceTicks(); 39 current_finished_at_ = base::TimeTicks();
41 40
42 // TODO(mithro): Add UMA tracking of delta between current_updated_at_ time 41 // TODO(mithro): Add UMA tracking of delta between current_updated_at_ time
43 // and the new_args.frame_time argument. This will give us how long after a 42 // and the new_args.frame_time argument. This will give us how long after a
44 // BeginFrameArgs message was created before we started processing it. 43 // BeginFrameArgs message was created before we started processing it.
45 } 44 }
46 45
47 const BeginFrameArgs& BeginFrameTracker::Current() const { 46 const BeginFrameArgs& BeginFrameTracker::Current() const {
48 DCHECK(!HasFinished()) 47 DCHECK(!HasFinished())
49 << "Tried to use BeginFrameArgs after marking the frame finished."; 48 << "Tried to use BeginFrameArgs after marking the frame finished.";
50 DCHECK(current_args_.IsValid()) 49 DCHECK(current_args_.IsValid())
51 << "Tried to use BeginFrameArgs before starting a frame!"; 50 << "Tried to use BeginFrameArgs before starting a frame!";
52 return current_args_; 51 return current_args_;
53 } 52 }
54 53
55 void BeginFrameTracker::Finish() { 54 void BeginFrameTracker::Finish() {
56 DCHECK(!HasFinished()) << "Tried to finish an already finished frame"; 55 DCHECK(!HasFinished()) << "Tried to finish an already finished frame";
57 current_finished_at_ = base::TraceTicks::Now(); 56 current_finished_at_ = base::TimeTicks::Now();
58 TRACE_EVENT_ASYNC_END0(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), 57 TRACE_EVENT_ASYNC_END0(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"),
59 location_string_.c_str(), 58 location_string_.c_str(),
60 current_args_.frame_time.ToInternalValue()); 59 current_args_.frame_time.ToInternalValue());
61 } 60 }
62 61
63 const BeginFrameArgs& BeginFrameTracker::Last() const { 62 const BeginFrameArgs& BeginFrameTracker::Last() const {
64 DCHECK(current_args_.IsValid()) 63 DCHECK(current_args_.IsValid())
65 << "Tried to use last BeginFrameArgs before starting a frame!"; 64 << "Tried to use last BeginFrameArgs before starting a frame!";
66 DCHECK(HasFinished()) 65 DCHECK(HasFinished())
67 << "Tried to use last BeginFrameArgs before the frame is finished."; 66 << "Tried to use last BeginFrameArgs before the frame is finished.";
68 return current_args_; 67 return current_args_;
69 } 68 }
70 69
71 base::TimeDelta BeginFrameTracker::Interval() const { 70 base::TimeDelta BeginFrameTracker::Interval() const {
72 base::TimeDelta interval = current_args_.interval; 71 base::TimeDelta interval = current_args_.interval;
73 // Normal interval will be ~16ms, 200Hz (5ms) screens are the fastest 72 // Normal interval will be ~16ms, 200Hz (5ms) screens are the fastest
74 // easily available so anything less than that is likely an error. 73 // easily available so anything less than that is likely an error.
75 if (interval < base::TimeDelta::FromMilliseconds(1)) { 74 if (interval < base::TimeDelta::FromMilliseconds(1)) {
76 interval = BeginFrameArgs::DefaultInterval(); 75 interval = BeginFrameArgs::DefaultInterval();
77 } 76 }
78 return interval; 77 return interval;
79 } 78 }
80 79
81 void BeginFrameTracker::AsValueInto( 80 void BeginFrameTracker::AsValueInto(
82 base::TimeTicks now, 81 base::TimeTicks now,
83 base::trace_event::TracedValue* state) const { 82 base::trace_event::TracedValue* state) const {
84 state->SetInteger("updated_at_us", (current_updated_at_ - base::TraceTicks()) 83 state->SetInteger("updated_at_us",
85 .InMicroseconds()); 84 (current_updated_at_ - base::TimeTicks()).InMicroseconds());
86 state->SetInteger("finished_at_us", (current_finished_at_ - 85 state->SetInteger("finished_at_us", (current_finished_at_ - base::TimeTicks())
87 base::TraceTicks()).InMicroseconds()); 86 .InMicroseconds());
88 if (HasFinished()) { 87 if (HasFinished()) {
89 state->SetString("state", "FINISHED"); 88 state->SetString("state", "FINISHED");
90 state->BeginDictionary("current_args_"); 89 state->BeginDictionary("current_args_");
91 } else { 90 } else {
92 state->SetString("state", "USING"); 91 state->SetString("state", "USING");
93 state->BeginDictionary("last_args_"); 92 state->BeginDictionary("last_args_");
94 } 93 }
95 current_args_.AsValueInto(state); 94 current_args_.AsValueInto(state);
96 state->EndDictionary(); 95 state->EndDictionary();
97 96
(...skipping 16 matching lines...) Expand all
114 113
115 const BeginFrameArgs& BeginFrameTracker::DangerousMethodCurrentOrLast() const { 114 const BeginFrameArgs& BeginFrameTracker::DangerousMethodCurrentOrLast() const {
116 if (!HasFinished()) { 115 if (!HasFinished()) {
117 return Current(); 116 return Current();
118 } else { 117 } else {
119 return Last(); 118 return Last();
120 } 119 }
121 } 120 }
122 121
123 } // namespace cc 122 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/begin_frame_tracker.h ('k') | components/scheduler/child/idle_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698