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

Side by Side Diff: cc/base/latency_info_swap_promise_monitor.cc

Issue 437163007: Revert of Implement scroll handler latency tracking (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « cc/base/latency_info_swap_promise_monitor.h ('k') | cc/base/swap_promise.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/base/latency_info_swap_promise_monitor.h" 5 #include "cc/base/latency_info_swap_promise_monitor.h"
6 6
7 #include "base/threading/platform_thread.h"
8 #include "cc/base/latency_info_swap_promise.h" 7 #include "cc/base/latency_info_swap_promise.h"
9 #include "cc/trees/layer_tree_host.h" 8 #include "cc/trees/layer_tree_host.h"
10 #include "cc/trees/layer_tree_host_impl.h" 9 #include "cc/trees/layer_tree_host_impl.h"
11 #include "cc/trees/layer_tree_impl.h" 10 #include "cc/trees/layer_tree_impl.h"
12 11
13 namespace {
14
15 bool AddRenderingScheduledComponent(ui::LatencyInfo* latency_info) {
16 if (latency_info->FindLatency(
17 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL))
18 return false;
19 latency_info->AddLatencyNumber(
20 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0);
21 return true;
22 }
23
24 bool AddForwardingScrollUpdateToMainComponent(ui::LatencyInfo* latency_info) {
25 if (latency_info->FindLatency(
26 ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT,
27 0,
28 NULL))
29 return false;
30 latency_info->AddLatencyNumber(
31 ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT,
32 0,
33 latency_info->trace_id);
34 return true;
35 }
36
37 } // namespace
38
39 namespace cc { 12 namespace cc {
40 13
41 LatencyInfoSwapPromiseMonitor::LatencyInfoSwapPromiseMonitor( 14 LatencyInfoSwapPromiseMonitor::LatencyInfoSwapPromiseMonitor(
42 ui::LatencyInfo* latency, 15 ui::LatencyInfo* latency,
43 LayerTreeHost* layer_tree_host, 16 LayerTreeHost* layer_tree_host,
44 LayerTreeHostImpl* layer_tree_host_impl) 17 LayerTreeHostImpl* layer_tree_host_impl)
45 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), 18 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl),
46 latency_(latency) {} 19 latency_(latency) {}
47 20
48 LatencyInfoSwapPromiseMonitor::~LatencyInfoSwapPromiseMonitor() {} 21 LatencyInfoSwapPromiseMonitor::~LatencyInfoSwapPromiseMonitor() {}
49 22
50 void LatencyInfoSwapPromiseMonitor::OnSetNeedsCommitOnMain() { 23 void LatencyInfoSwapPromiseMonitor::OnSetNeedsCommitOnMain() {
51 if (AddRenderingScheduledComponent(latency_)) { 24 if (!latency_->FindLatency(
25 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0)) {
26 latency_->AddLatencyNumber(
27 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0);
52 scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_)); 28 scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_));
53 layer_tree_host_->QueueSwapPromise(swap_promise.Pass()); 29 layer_tree_host_->QueueSwapPromise(swap_promise.Pass());
54 } 30 }
55 } 31 }
56 32
57 void LatencyInfoSwapPromiseMonitor::OnSetNeedsRedrawOnImpl() { 33 void LatencyInfoSwapPromiseMonitor::OnSetNeedsRedrawOnImpl() {
58 if (AddRenderingScheduledComponent(latency_)) { 34 if (!latency_->FindLatency(
35 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0)) {
36 latency_->AddLatencyNumber(
37 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0);
59 scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_)); 38 scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_));
60 layer_tree_host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass()); 39 layer_tree_host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass());
61 } 40 }
62 } 41 }
63 42
64 void LatencyInfoSwapPromiseMonitor::OnForwardScrollUpdateToMainThreadOnImpl() {
65 if (AddForwardingScrollUpdateToMainComponent(latency_)) {
66 int64 new_sequence_number = 0;
67 for (ui::LatencyInfo::LatencyMap::const_iterator it =
68 latency_->latency_components.begin();
69 it != latency_->latency_components.end();
70 ++it) {
71 if (it->first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT) {
72 new_sequence_number =
73 (static_cast<int64>(base::PlatformThread::CurrentId()) << 32) |
74 (it->second.sequence_number & 0xffffffff);
75 DCHECK(new_sequence_number != it->second.sequence_number);
76 break;
77 }
78 }
79 if (!new_sequence_number)
80 return;
81 ui::LatencyInfo new_latency;
82 new_latency.AddLatencyNumber(
83 ui::INPUT_EVENT_LATENCY_BEGIN_SCROLL_UPDATE_MAIN_COMPONENT,
84 0,
85 new_sequence_number);
86 new_latency.TraceEventType("ScrollUpdate");
87 new_latency.CopyLatencyFrom(
88 *latency_,
89 ui::INPUT_EVENT_LATENCY_FORWARD_SCROLL_UPDATE_TO_MAIN_COMPONENT);
90 scoped_ptr<SwapPromise> swap_promise(
91 new LatencyInfoSwapPromise(new_latency));
92 layer_tree_host_impl_->QueueSwapPromiseForMainThreadScrollUpdate(
93 swap_promise.Pass());
94 }
95 }
96
97 } // namespace cc 43 } // namespace cc
OLDNEW
« no previous file with comments | « cc/base/latency_info_swap_promise_monitor.h ('k') | cc/base/swap_promise.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698