OLD | NEW |
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/output/latency_info_swap_promise.h" | 5 #include "cc/output/latency_info_swap_promise.h" |
6 | 6 |
| 7 #include <iostream> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/threading/platform_thread.h" |
8 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
| 12 #include "content/renderer/greenweb_latency_tracking.h" |
9 | 13 |
10 namespace { | 14 namespace { |
11 ui::LatencyComponentType DidNotSwapReasonToLatencyComponentType( | 15 ui::LatencyComponentType DidNotSwapReasonToLatencyComponentType( |
12 cc::SwapPromise::DidNotSwapReason reason) { | 16 cc::SwapPromise::DidNotSwapReason reason) { |
13 switch (reason) { | 17 switch (reason) { |
14 case cc::SwapPromise::ACTIVATION_FAILS: | 18 case cc::SwapPromise::ACTIVATION_FAILS: |
15 case cc::SwapPromise::SWAP_FAILS: | 19 case cc::SwapPromise::SWAP_FAILS: |
16 return ui::INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT; | 20 return ui::INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT; |
17 case cc::SwapPromise::COMMIT_FAILS: | 21 case cc::SwapPromise::COMMIT_FAILS: |
18 return ui::INPUT_EVENT_LATENCY_TERMINATED_COMMIT_FAILED_COMPONENT; | 22 return ui::INPUT_EVENT_LATENCY_TERMINATED_COMMIT_FAILED_COMPONENT; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 return latency_.trace_id(); | 54 return latency_.trace_id(); |
51 } | 55 } |
52 | 56 |
53 // Trace the original LatencyInfo of a LatencyInfoSwapPromise | 57 // Trace the original LatencyInfo of a LatencyInfoSwapPromise |
54 void LatencyInfoSwapPromise::OnCommit() { | 58 void LatencyInfoSwapPromise::OnCommit() { |
55 TRACE_EVENT_WITH_FLOW1("input,benchmark", | 59 TRACE_EVENT_WITH_FLOW1("input,benchmark", |
56 "LatencyInfo.Flow", | 60 "LatencyInfo.Flow", |
57 TRACE_ID_DONT_MANGLE(TraceId()), | 61 TRACE_ID_DONT_MANGLE(TraceId()), |
58 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, | 62 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, |
59 "step", "HandleInputEventMainCommit"); | 63 "step", "HandleInputEventMainCommit"); |
| 64 |
| 65 int64 trace_id = TraceId(); |
| 66 if (InputLatencyMap.find(trace_id) != InputLatencyMap.end()) { |
| 67 int64 dom_node = InputLatencyMap[trace_id].dom_node; |
| 68 if (dom_node) { |
| 69 base::TimeTicks layout_end_ts = base::TimeTicks::Now(); |
| 70 base::TimeDelta latency = layout_end_ts - InputLatencyMap[trace_id].callba
ck_start; |
| 71 InputLatencyMap[trace_id].latency = latency.InMilliseconds(); |
| 72 |
| 73 DOMLatencyMap[dom_node].latency = InputLatencyMap[trace_id].latency; |
| 74 |
| 75 content::process_freq_stat(&(InputLatencyMap[trace_id].FreqStatStartMap),
&(DOMLatencyMap[dom_node].FreqStatMap)); |
| 76 |
| 77 #ifdef EBS_DEBUG_TRACE_EVENT |
| 78 TRACE_EVENT2("devtools.timeline", "GreenWeb:StyleLayout", |
| 79 "trace_id", TraceId(), |
| 80 "latency", DOMLatencyMap[dom_node].latency); |
| 81 std::cout << "Thd: " << base::PlatformThread::CurrentId() << |
| 82 " (" << base::PlatformThread::GetName() << ")" << |
| 83 " StyleLayout " |
| 84 " trace_id " << trace_id << |
| 85 " dom_node " << dom_node << |
| 86 " latency " << DOMLatencyMap[dom_node].latency << std::endl; |
| 87 #endif |
| 88 } |
| 89 // Erase this trace_id because it will not used in the future |
| 90 InputLatencyMap.erase(trace_id); |
| 91 } |
60 } | 92 } |
61 | 93 |
62 } // namespace cc | 94 } // namespace cc |
OLD | NEW |