Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/input/main_thread_event_queue.h" | 5 #include "content/renderer/input/main_thread_event_queue.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
| 8 #include "base/strings/string_number_conversions.h" | |
| 9 #include "components/variations/variations_associated_data.h" | |
| 8 #include "content/common/input/event_with_latency_info.h" | 10 #include "content/common/input/event_with_latency_info.h" |
| 9 #include "content/common/input_messages.h" | 11 #include "content/common/input_messages.h" |
| 10 | 12 |
| 11 namespace content { | 13 namespace content { |
| 12 | 14 |
| 13 namespace { | 15 namespace { |
| 14 | 16 |
| 15 const size_t kTenSeconds = 10 * 1000 * 1000; | 17 const size_t kTenSeconds = 10 * 1000 * 1000; |
| 16 | 18 |
| 17 bool IsContinuousEvent(const std::unique_ptr<EventWithDispatchType>& event) { | 19 bool IsContinuousEvent(const std::unique_ptr<EventWithDispatchType>& event) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 enable_fling_passive_listener_flag_(base::FeatureList::IsEnabled( | 73 enable_fling_passive_listener_flag_(base::FeatureList::IsEnabled( |
| 72 features::kPassiveEventListenersDueToFling)), | 74 features::kPassiveEventListenersDueToFling)), |
| 73 enable_non_blocking_due_to_main_thread_responsiveness_flag_( | 75 enable_non_blocking_due_to_main_thread_responsiveness_flag_( |
| 74 base::FeatureList::IsEnabled( | 76 base::FeatureList::IsEnabled( |
| 75 features::kMainThreadBusyScrollIntervention)), | 77 features::kMainThreadBusyScrollIntervention)), |
| 76 handle_raf_aligned_touch_input_( | 78 handle_raf_aligned_touch_input_( |
| 77 base::FeatureList::IsEnabled(features::kRafAlignedTouchInputEvents)), | 79 base::FeatureList::IsEnabled(features::kRafAlignedTouchInputEvents)), |
| 78 handle_raf_aligned_mouse_input_( | 80 handle_raf_aligned_mouse_input_( |
| 79 base::FeatureList::IsEnabled(features::kRafAlignedMouseInputEvents)), | 81 base::FeatureList::IsEnabled(features::kRafAlignedMouseInputEvents)), |
| 80 main_task_runner_(main_task_runner), | 82 main_task_runner_(main_task_runner), |
| 81 renderer_scheduler_(renderer_scheduler) {} | 83 renderer_scheduler_(renderer_scheduler) { |
| 84 if (enable_non_blocking_due_to_main_thread_responsiveness_flag_) { | |
| 85 std::string threshold = variations::GetVariationParamValueByFeature( | |
| 86 features::kMainThreadBusyScrollIntervention, "threshold"); | |
| 87 int threshold_ms = 0; | |
| 88 base::StringToInt(threshold, &threshold_ms); | |
| 89 if (!threshold_ms) { | |
| 90 enable_non_blocking_due_to_main_thread_responsiveness_flag_ = false; | |
|
dtapuska
2016/12/16 19:59:46
What about negative values? And StringToInt failin
tdresser
2016/12/16 20:12:08
StringToInt saturates for overflow and underflow,
| |
| 91 } else { | |
| 92 main_thread_responsiveness_threshold_ = | |
| 93 base::TimeDelta::FromMilliseconds(threshold_ms); | |
| 94 } | |
| 95 } | |
| 96 } | |
| 82 | 97 |
| 83 MainThreadEventQueue::~MainThreadEventQueue() {} | 98 MainThreadEventQueue::~MainThreadEventQueue() {} |
| 84 | 99 |
| 85 bool MainThreadEventQueue::HandleEvent( | 100 bool MainThreadEventQueue::HandleEvent( |
| 86 ui::ScopedWebInputEvent event, | 101 ui::ScopedWebInputEvent event, |
| 87 const ui::LatencyInfo& latency, | 102 const ui::LatencyInfo& latency, |
| 88 InputEventDispatchType original_dispatch_type, | 103 InputEventDispatchType original_dispatch_type, |
| 89 InputEventAckState ack_result) { | 104 InputEventAckState ack_result) { |
| 90 DCHECK(original_dispatch_type == DISPATCH_TYPE_BLOCKING || | 105 DCHECK(original_dispatch_type == DISPATCH_TYPE_BLOCKING || |
| 91 original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING); | 106 original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 } | 141 } |
| 127 | 142 |
| 128 // If handling rAF aligned touch input ACK non-cancelable events right | 143 // If handling rAF aligned touch input ACK non-cancelable events right |
| 129 // away. | 144 // away. |
| 130 if (!non_blocking && IsRafAlignedEvent(*touch_event)) | 145 if (!non_blocking && IsRafAlignedEvent(*touch_event)) |
| 131 non_blocking = true; | 146 non_blocking = true; |
| 132 | 147 |
| 133 if (enable_non_blocking_due_to_main_thread_responsiveness_flag_ && | 148 if (enable_non_blocking_due_to_main_thread_responsiveness_flag_ && |
| 134 touch_event->dispatchType == blink::WebInputEvent::Blocking) { | 149 touch_event->dispatchType == blink::WebInputEvent::Blocking) { |
| 135 bool passive_due_to_unresponsive_main = | 150 bool passive_due_to_unresponsive_main = |
| 136 renderer_scheduler_->MainThreadSeemsUnresponsive(); | 151 renderer_scheduler_->MainThreadSeemsUnresponsive( |
| 152 main_thread_responsiveness_threshold_); | |
| 137 if (passive_due_to_unresponsive_main) { | 153 if (passive_due_to_unresponsive_main) { |
| 138 touch_event->dispatchType = blink::WebInputEvent:: | 154 touch_event->dispatchType = blink::WebInputEvent:: |
| 139 ListenersForcedNonBlockingDueToMainThreadResponsiveness; | 155 ListenersForcedNonBlockingDueToMainThreadResponsiveness; |
| 140 non_blocking = true; | 156 non_blocking = true; |
| 141 } | 157 } |
| 142 } | 158 } |
| 143 } | 159 } |
| 144 if (is_wheel && non_blocking) { | 160 if (is_wheel && non_blocking) { |
| 145 // Adjust the |dispatchType| on the event since the compositor | 161 // Adjust the |dispatchType| on the event since the compositor |
| 146 // determined all event listeners are passive. | 162 // determined all event listeners are passive. |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 345 // additional frame. | 361 // additional frame. |
| 346 return static_cast<const blink::WebTouchEvent&>(event).dispatchType != | 362 return static_cast<const blink::WebTouchEvent&>(event).dispatchType != |
| 347 blink::WebInputEvent::Blocking && | 363 blink::WebInputEvent::Blocking && |
| 348 handle_raf_aligned_touch_input_; | 364 handle_raf_aligned_touch_input_; |
| 349 default: | 365 default: |
| 350 return false; | 366 return false; |
| 351 } | 367 } |
| 352 } | 368 } |
| 353 | 369 |
| 354 } // namespace content | 370 } // namespace content |
| OLD | NEW |