OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/debug/trace_event_synthetic_delay.h" | 10 #include "base/debug/trace_event_synthetic_delay.h" |
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 if (!animation_update_pending_ && !paint_aggregator_.HasPendingUpdate()) { | 1030 if (!animation_update_pending_ && !paint_aggregator_.HasPendingUpdate()) { |
1031 TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate"); | 1031 TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate"); |
1032 return; | 1032 return; |
1033 } | 1033 } |
1034 | 1034 |
1035 // Continue painting if necessary... | 1035 // Continue painting if necessary... |
1036 DoDeferredUpdateAndSendInputAck(); | 1036 DoDeferredUpdateAndSendInputAck(); |
1037 } | 1037 } |
1038 | 1038 |
1039 void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, | 1039 void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, |
1040 ui::LatencyInfo latency_info, | 1040 const ui::LatencyInfo& latency_info, |
1041 bool is_keyboard_shortcut) { | 1041 bool is_keyboard_shortcut) { |
1042 handling_input_event_ = true; | 1042 handling_input_event_ = true; |
1043 if (!input_event) { | 1043 if (!input_event) { |
1044 handling_input_event_ = false; | 1044 handling_input_event_ = false; |
1045 return; | 1045 return; |
1046 } | 1046 } |
1047 | 1047 |
1048 base::TimeTicks start_time; | 1048 base::TimeTicks start_time; |
1049 if (base::TimeTicks::IsHighResNowFastAndReliable()) | 1049 if (base::TimeTicks::IsHighResNowFastAndReliable()) |
1050 start_time = base::TimeTicks::HighResNow(); | 1050 start_time = base::TimeTicks::HighResNow(); |
1051 | 1051 |
1052 const char* const event_name = | 1052 const char* const event_name = |
1053 WebInputEventTraits::GetName(input_event->type); | 1053 WebInputEventTraits::GetName(input_event->type); |
1054 TRACE_EVENT1("renderer", "RenderWidget::OnHandleInputEvent", | 1054 TRACE_EVENT1("renderer", "RenderWidget::OnHandleInputEvent", |
1055 "event", event_name); | 1055 "event", event_name); |
1056 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("blink.HandleInputEvent"); | 1056 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("blink.HandleInputEvent"); |
1057 | 1057 |
1058 scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor; | 1058 scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor; |
1059 | 1059 ui::LatencyInfo swap_latency_info(latency_info); |
1060 if (compositor_) { | 1060 if (compositor_) { |
1061 latency_info_swap_promise_monitor = | 1061 latency_info_swap_promise_monitor = |
1062 compositor_->CreateLatencyInfoSwapPromiseMonitor(&latency_info).Pass(); | 1062 compositor_->CreateLatencyInfoSwapPromiseMonitor(&swap_latency_info) |
| 1063 .Pass(); |
1063 } else { | 1064 } else { |
1064 latency_info_.push_back(latency_info); | 1065 latency_info_.push_back(latency_info); |
1065 } | 1066 } |
1066 | 1067 |
1067 base::TimeDelta now = base::TimeDelta::FromInternalValue( | 1068 base::TimeDelta now = base::TimeDelta::FromInternalValue( |
1068 base::TimeTicks::Now().ToInternalValue()); | 1069 base::TimeTicks::Now().ToInternalValue()); |
1069 | 1070 |
1070 int64 delta = static_cast<int64>( | 1071 int64 delta = static_cast<int64>( |
1071 (now.InSecondsF() - input_event->timeStampSeconds) * | 1072 (now.InSecondsF() - input_event->timeStampSeconds) * |
1072 base::Time::kMicrosecondsPerSecond); | 1073 base::Time::kMicrosecondsPerSecond); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 rate_limiting_wanted = | 1163 rate_limiting_wanted = |
1163 total_input_handling_time_this_frame_.InMicroseconds() > | 1164 total_input_handling_time_this_frame_.InMicroseconds() > |
1164 kInputHandlingTimeThrottlingThresholdMicroseconds; | 1165 kInputHandlingTimeThrottlingThresholdMicroseconds; |
1165 } | 1166 } |
1166 | 1167 |
1167 if (!WebInputEventTraits::IgnoresAckDisposition(input_event->type)) { | 1168 if (!WebInputEventTraits::IgnoresAckDisposition(input_event->type)) { |
1168 scoped_ptr<IPC::Message> response( | 1169 scoped_ptr<IPC::Message> response( |
1169 new InputHostMsg_HandleInputEvent_ACK(routing_id_, | 1170 new InputHostMsg_HandleInputEvent_ACK(routing_id_, |
1170 input_event->type, | 1171 input_event->type, |
1171 ack_result, | 1172 ack_result, |
1172 latency_info)); | 1173 swap_latency_info)); |
1173 if (rate_limiting_wanted && event_type_can_be_rate_limited && | 1174 if (rate_limiting_wanted && event_type_can_be_rate_limited && |
1174 frame_pending && !is_hidden_) { | 1175 frame_pending && !is_hidden_) { |
1175 // We want to rate limit the input events in this case, so we'll wait for | 1176 // We want to rate limit the input events in this case, so we'll wait for |
1176 // painting to finish before ACKing this message. | 1177 // painting to finish before ACKing this message. |
1177 TRACE_EVENT_INSTANT0("renderer", | 1178 TRACE_EVENT_INSTANT0("renderer", |
1178 "RenderWidget::OnHandleInputEvent ack throttled", | 1179 "RenderWidget::OnHandleInputEvent ack throttled", |
1179 TRACE_EVENT_SCOPE_THREAD); | 1180 TRACE_EVENT_SCOPE_THREAD); |
1180 if (pending_input_event_ack_) { | 1181 if (pending_input_event_ack_) { |
1181 // As two different kinds of events could cause us to postpone an ack | 1182 // As two different kinds of events could cause us to postpone an ack |
1182 // we send it now, if we have one pending. The Browser should never | 1183 // we send it now, if we have one pending. The Browser should never |
(...skipping 1649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2832 | 2833 |
2833 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) { | 2834 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) { |
2834 swapped_out_frames_.AddObserver(frame); | 2835 swapped_out_frames_.AddObserver(frame); |
2835 } | 2836 } |
2836 | 2837 |
2837 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) { | 2838 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) { |
2838 swapped_out_frames_.RemoveObserver(frame); | 2839 swapped_out_frames_.RemoveObserver(frame); |
2839 } | 2840 } |
2840 | 2841 |
2841 } // namespace content | 2842 } // namespace content |
OLD | NEW |