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

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

Issue 365463003: Implement scroll handler latency tracking (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments. Created 6 years, 5 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
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 "cc/base/latency_info_swap_promise.h" 7 #include "cc/base/latency_info_swap_promise.h"
8 #include "cc/trees/layer_tree_host.h" 8 #include "cc/trees/layer_tree_host.h"
9 #include "cc/trees/layer_tree_host_impl.h" 9 #include "cc/trees/layer_tree_host_impl.h"
10 #include "cc/trees/layer_tree_impl.h" 10 #include "cc/trees/layer_tree_impl.h"
11 11
12 namespace {
13
14 bool AddRenderingScheduledComponent(ui::LatencyInfo* latency_info) {
15 if (latency_info->FindLatency(
16 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0))
17 return false;
18 latency_info->AddLatencyNumber(
19 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0);
20 return true;
21 }
22
23 } // namespace
24
12 namespace cc { 25 namespace cc {
13 26
14 LatencyInfoSwapPromiseMonitor::LatencyInfoSwapPromiseMonitor( 27 LatencyInfoSwapPromiseMonitor::LatencyInfoSwapPromiseMonitor(
15 ui::LatencyInfo* latency, 28 ui::LatencyInfo* latency,
16 LayerTreeHost* layer_tree_host, 29 LayerTreeHost* layer_tree_host,
17 LayerTreeHostImpl* layer_tree_host_impl) 30 LayerTreeHostImpl* layer_tree_host_impl)
18 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl), 31 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl),
19 latency_(latency) {} 32 latency_(latency) {}
20 33
21 LatencyInfoSwapPromiseMonitor::~LatencyInfoSwapPromiseMonitor() {} 34 LatencyInfoSwapPromiseMonitor::~LatencyInfoSwapPromiseMonitor() {}
22 35
23 void LatencyInfoSwapPromiseMonitor::OnSetNeedsCommitOnMain() { 36 void LatencyInfoSwapPromiseMonitor::OnSetNeedsCommitOnMain() {
24 if (!latency_->FindLatency( 37 if (AddRenderingScheduledComponent(latency_)) {
25 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0)) {
26 latency_->AddLatencyNumber(
27 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0);
28 scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_)); 38 scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_));
29 layer_tree_host_->QueueSwapPromise(swap_promise.Pass()); 39 layer_tree_host_->QueueSwapPromise(swap_promise.Pass());
30 } 40 }
31 } 41 }
32 42
33 void LatencyInfoSwapPromiseMonitor::OnSetNeedsRedrawOnImpl() { 43 void LatencyInfoSwapPromiseMonitor::OnSetNeedsRedrawOnImpl() {
34 if (!latency_->FindLatency( 44 if (AddRenderingScheduledComponent(latency_)) {
35 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0)) {
36 latency_->AddLatencyNumber(
37 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0);
38 scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_)); 45 scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_));
39 layer_tree_host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass()); 46 layer_tree_host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass());
40 } 47 }
41 } 48 }
42 49
50 void LatencyInfoSwapPromiseMonitor::OnForwardScrollUpdateToMainThreadOnImpl() {
51 if (AddRenderingScheduledComponent(latency_))
52 layer_tree_host_impl_->QueueScrollUpdateLatencyInfo(*latency_);
danakj 2014/07/08 16:49:07 Why doesn't this make a SwapPromise and queue that
Sami 2014/07/09 13:28:55 Initially I avoided that because otherwise it got
53 }
54
43 } // namespace cc 55 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698