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

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

Issue 1122153002: Fixit: Fork base::TimeTicks --> TimeTicks + ThreadTicks + TraceTicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@FIXIT_timeclasses_1of2
Patch Set: REBASE after it passed CQ but did not commit to tree Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « cc/scheduler/begin_frame_tracker.h ('k') | components/tracing/child_trace_message_filter.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::TimeTicks::FromInternalValue(-1)) { 14 current_finished_at_(base::TraceTicks::FromInternalValue(-1)) {
15 } 15 }
16 16
17 BeginFrameTracker::~BeginFrameTracker() { 17 BeginFrameTracker::~BeginFrameTracker() {
18 } 18 }
19 19
20 void BeginFrameTracker::Start(BeginFrameArgs new_args) { 20 void BeginFrameTracker::Start(BeginFrameArgs new_args) {
21 // Trace the frame time being passed between BeginFrameTrackers. 21 // Trace the frame time being passed between BeginFrameTrackers.
22 TRACE_EVENT_FLOW_STEP0( 22 TRACE_EVENT_FLOW_STEP0(
23 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), "BeginFrameArgs", 23 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), "BeginFrameArgs",
24 new_args.frame_time.ToInternalValue(), location_string_); 24 new_args.frame_time.ToInternalValue(), location_string_);
25 25
26 // Trace this specific begin frame tracker Start/Finish times. 26 // Trace this specific begin frame tracker Start/Finish times.
27 TRACE_EVENT_ASYNC_BEGIN2( 27 TRACE_EVENT_ASYNC_BEGIN2(
28 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), 28 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"),
29 location_string_.c_str(), new_args.frame_time.ToInternalValue(), 29 location_string_.c_str(), new_args.frame_time.ToInternalValue(),
30 "new args", new_args.AsValue(), "current args", current_args_.AsValue()); 30 "new args", new_args.AsValue(), "current args", current_args_.AsValue());
31 31
32 // Check the new BeginFrameArgs are valid and monotonically increasing. 32 // Check the new BeginFrameArgs are valid and monotonically increasing.
33 DCHECK(new_args.IsValid()); 33 DCHECK(new_args.IsValid());
34 DCHECK_LE(current_args_.frame_time, new_args.frame_time); 34 DCHECK_LE(current_args_.frame_time, new_args.frame_time);
35 35
36 DCHECK(HasFinished()) 36 DCHECK(HasFinished())
37 << "Tried to start a new frame before finishing an existing frame."; 37 << "Tried to start a new frame before finishing an existing frame.";
38 current_updated_at_ = base::TimeTicks::NowFromSystemTraceTime(); 38 current_updated_at_ = base::TraceTicks::Now();
39 current_args_ = new_args; 39 current_args_ = new_args;
40 current_finished_at_ = base::TimeTicks(); 40 current_finished_at_ = base::TraceTicks();
41 41
42 // TODO(mithro): Add UMA tracking of delta between current_updated_at_ time 42 // 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 43 // 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. 44 // BeginFrameArgs message was created before we started processing it.
45 } 45 }
46 46
47 const BeginFrameArgs& BeginFrameTracker::Current() const { 47 const BeginFrameArgs& BeginFrameTracker::Current() const {
48 DCHECK(!HasFinished()) 48 DCHECK(!HasFinished())
49 << "Tried to use BeginFrameArgs after marking the frame finished."; 49 << "Tried to use BeginFrameArgs after marking the frame finished.";
50 DCHECK(current_args_.IsValid()) 50 DCHECK(current_args_.IsValid())
51 << "Tried to use BeginFrameArgs before starting a frame!"; 51 << "Tried to use BeginFrameArgs before starting a frame!";
52 return current_args_; 52 return current_args_;
53 } 53 }
54 54
55 void BeginFrameTracker::Finish() { 55 void BeginFrameTracker::Finish() {
56 DCHECK(!HasFinished()) << "Tried to finish an already finished frame"; 56 DCHECK(!HasFinished()) << "Tried to finish an already finished frame";
57 current_finished_at_ = base::TimeTicks::NowFromSystemTraceTime(); 57 current_finished_at_ = base::TraceTicks::Now();
58 TRACE_EVENT_ASYNC_END0(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), 58 TRACE_EVENT_ASYNC_END0(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"),
59 location_string_.c_str(), 59 location_string_.c_str(),
60 current_args_.frame_time.ToInternalValue()); 60 current_args_.frame_time.ToInternalValue());
61 } 61 }
62 62
63 const BeginFrameArgs& BeginFrameTracker::Last() const { 63 const BeginFrameArgs& BeginFrameTracker::Last() const {
64 DCHECK(current_args_.IsValid()) 64 DCHECK(current_args_.IsValid())
65 << "Tried to use last BeginFrameArgs before starting a frame!"; 65 << "Tried to use last BeginFrameArgs before starting a frame!";
66 DCHECK(HasFinished()) 66 DCHECK(HasFinished())
67 << "Tried to use last BeginFrameArgs before the frame is finished."; 67 << "Tried to use last BeginFrameArgs before the frame is finished.";
68 return current_args_; 68 return current_args_;
69 } 69 }
70 70
71 base::TimeDelta BeginFrameTracker::Interval() const { 71 base::TimeDelta BeginFrameTracker::Interval() const {
72 base::TimeDelta interval = current_args_.interval; 72 base::TimeDelta interval = current_args_.interval;
73 // Normal interval will be ~16ms, 200Hz (5ms) screens are the fastest 73 // Normal interval will be ~16ms, 200Hz (5ms) screens are the fastest
74 // easily available so anything less than that is likely an error. 74 // easily available so anything less than that is likely an error.
75 if (interval < base::TimeDelta::FromMilliseconds(1)) { 75 if (interval < base::TimeDelta::FromMilliseconds(1)) {
76 interval = BeginFrameArgs::DefaultInterval(); 76 interval = BeginFrameArgs::DefaultInterval();
77 } 77 }
78 return interval; 78 return interval;
79 } 79 }
80 80
81 void BeginFrameTracker::AsValueInto( 81 void BeginFrameTracker::AsValueInto(
82 base::TimeTicks now, 82 base::TimeTicks now,
83 base::trace_event::TracedValue* state) const { 83 base::trace_event::TracedValue* state) const {
84 state->SetInteger("updated_at_us", current_updated_at_.ToInternalValue()); 84 state->SetInteger("updated_at_us", (current_updated_at_ - base::TraceTicks())
85 state->SetInteger("finished_at_us", current_finished_at_.ToInternalValue()); 85 .InMicroseconds());
86 state->SetInteger("finished_at_us", (current_finished_at_ -
87 base::TraceTicks()).InMicroseconds());
86 if (HasFinished()) { 88 if (HasFinished()) {
87 state->SetString("state", "FINISHED"); 89 state->SetString("state", "FINISHED");
88 state->BeginDictionary("current_args_"); 90 state->BeginDictionary("current_args_");
89 } else { 91 } else {
90 state->SetString("state", "USING"); 92 state->SetString("state", "USING");
91 state->BeginDictionary("last_args_"); 93 state->BeginDictionary("last_args_");
92 } 94 }
93 current_args_.AsValueInto(state); 95 current_args_.AsValueInto(state);
94 state->EndDictionary(); 96 state->EndDictionary();
95 97
(...skipping 16 matching lines...) Expand all
112 114
113 const BeginFrameArgs& BeginFrameTracker::DangerousMethodCurrentOrLast() const { 115 const BeginFrameArgs& BeginFrameTracker::DangerousMethodCurrentOrLast() const {
114 if (!HasFinished()) { 116 if (!HasFinished()) {
115 return Current(); 117 return Current();
116 } else { 118 } else {
117 return Last(); 119 return Last();
118 } 120 }
119 } 121 }
120 122
121 } // namespace cc 123 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/begin_frame_tracker.h ('k') | components/tracing/child_trace_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698