Landing Recent QUIC changes until 8/19/2015 17:00 UTC.
[chromium-blink-merge.git] / cc / output / latency_info_swap_promise.cc
blob3b267454076e574b01a510403395d2f3b08aec3c
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/output/latency_info_swap_promise.h"
7 #include "base/logging.h"
8 #include "base/trace_event/trace_event.h"
10 namespace {
11 ui::LatencyComponentType DidNotSwapReasonToLatencyComponentType(
12 cc::SwapPromise::DidNotSwapReason reason) {
13 switch (reason) {
14 case cc::SwapPromise::ACTIVATION_FAILS:
15 case cc::SwapPromise::SWAP_FAILS:
16 return ui::INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT;
17 case cc::SwapPromise::COMMIT_FAILS:
18 return ui::INPUT_EVENT_LATENCY_TERMINATED_COMMIT_FAILED_COMPONENT;
19 case cc::SwapPromise::COMMIT_NO_UPDATE:
20 return ui::INPUT_EVENT_LATENCY_TERMINATED_COMMIT_NO_UPDATE_COMPONENT;
22 NOTREACHED() << "Unhandled DidNotSwapReason.";
23 return ui::INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT;
25 } // namespace
27 namespace cc {
29 LatencyInfoSwapPromise::LatencyInfoSwapPromise(const ui::LatencyInfo& latency)
30 : latency_(latency) {
33 LatencyInfoSwapPromise::~LatencyInfoSwapPromise() {
36 void LatencyInfoSwapPromise::DidSwap(CompositorFrameMetadata* metadata) {
37 DCHECK(!latency_.terminated());
38 metadata->latency_info.push_back(latency_);
41 void LatencyInfoSwapPromise::DidNotSwap(DidNotSwapReason reason) {
42 latency_.AddLatencyNumber(DidNotSwapReasonToLatencyComponentType(reason), 0,
43 0);
44 // TODO(miletus): Turn this back on once per-event LatencyInfo tracking
45 // is enabled in GPU side.
46 // DCHECK(latency_.terminated);
49 int64 LatencyInfoSwapPromise::TraceId() const {
50 return latency_.trace_id();
53 // Trace the original LatencyInfo of a LatencyInfoSwapPromise
54 void LatencyInfoSwapPromise::OnCommit() {
55 TRACE_EVENT_WITH_FLOW1("input,benchmark",
56 "LatencyInfo.Flow",
57 TRACE_ID_DONT_MANGLE(TraceId()),
58 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT,
59 "step", "HandleInputEventMainCommit");
62 } // namespace cc