Lots of random cleanups, mostly for native_theme_win.cc:
[chromium-blink-merge.git] / cc / base / latency_info_swap_promise_monitor.cc
blob1a69b211d94b95b6b33a9f2ec0b1f75277c9a2e1
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
3 // found in the LICENSE file.
5 #include "cc/base/latency_info_swap_promise_monitor.h"
7 #include "cc/base/latency_info_swap_promise.h"
8 #include "cc/trees/layer_tree_host.h"
9 #include "cc/trees/layer_tree_host_impl.h"
10 #include "cc/trees/layer_tree_impl.h"
12 namespace {
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;
23 } // namespace
25 namespace cc {
27 LatencyInfoSwapPromiseMonitor::LatencyInfoSwapPromiseMonitor(
28 ui::LatencyInfo* latency,
29 LayerTreeHost* layer_tree_host,
30 LayerTreeHostImpl* layer_tree_host_impl)
31 : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl),
32 latency_(latency) {}
34 LatencyInfoSwapPromiseMonitor::~LatencyInfoSwapPromiseMonitor() {}
36 void LatencyInfoSwapPromiseMonitor::OnSetNeedsCommitOnMain() {
37 if (AddRenderingScheduledComponent(latency_)) {
38 scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_));
39 layer_tree_host_->QueueSwapPromise(swap_promise.Pass());
43 void LatencyInfoSwapPromiseMonitor::OnSetNeedsRedrawOnImpl() {
44 if (AddRenderingScheduledComponent(latency_)) {
45 scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_));
46 layer_tree_host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass());
50 void LatencyInfoSwapPromiseMonitor::OnForwardScrollUpdateToMainThreadOnImpl() {
51 if (AddRenderingScheduledComponent(latency_)) {
52 scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_));
53 layer_tree_host_impl_->QueueSwapPromiseForMainThreadScrollUpdate(
54 swap_promise.Pass());
58 } // namespace cc