Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: content/renderer/input/main_thread_event_queue.cc

Issue 2581243004: Pass main thread responsiveness threshold via Finch (Closed)
Patch Set: Use EXPECT_FALSE/TRUE - avoids compile error. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/field_trial.h"
7 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/strings/string_number_conversions.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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 enable_fling_passive_listener_flag_(base::FeatureList::IsEnabled( 68 enable_fling_passive_listener_flag_(base::FeatureList::IsEnabled(
67 features::kPassiveEventListenersDueToFling)), 69 features::kPassiveEventListenersDueToFling)),
68 enable_non_blocking_due_to_main_thread_responsiveness_flag_( 70 enable_non_blocking_due_to_main_thread_responsiveness_flag_(
69 base::FeatureList::IsEnabled( 71 base::FeatureList::IsEnabled(
70 features::kMainThreadBusyScrollIntervention)), 72 features::kMainThreadBusyScrollIntervention)),
71 handle_raf_aligned_touch_input_( 73 handle_raf_aligned_touch_input_(
72 base::FeatureList::IsEnabled(features::kRafAlignedTouchInputEvents)), 74 base::FeatureList::IsEnabled(features::kRafAlignedTouchInputEvents)),
73 handle_raf_aligned_mouse_input_( 75 handle_raf_aligned_mouse_input_(
74 base::FeatureList::IsEnabled(features::kRafAlignedMouseInputEvents)), 76 base::FeatureList::IsEnabled(features::kRafAlignedMouseInputEvents)),
75 main_task_runner_(main_task_runner), 77 main_task_runner_(main_task_runner),
76 renderer_scheduler_(renderer_scheduler) {} 78 renderer_scheduler_(renderer_scheduler) {
79 if (enable_non_blocking_due_to_main_thread_responsiveness_flag_) {
80 std::string group = base::FieldTrialList::FindFullName(
81 "MainThreadResponsivenessScrollIntervention");
82
83 // The group name will be of the form Enabled$THRESHOLD_MS. Trim the prefix
84 // "Enabled", and parse the threshold.
85 int threshold_ms = 0;
86 std::string prefix = "Enabled";
87 group.erase(0, prefix.length());
88 base::StringToInt(group, &threshold_ms);
89
90 if (threshold_ms <= 0) {
91 enable_non_blocking_due_to_main_thread_responsiveness_flag_ = false;
92 } else {
93 main_thread_responsiveness_threshold_ =
94 base::TimeDelta::FromMilliseconds(threshold_ms);
95 }
96 }
97 }
77 98
78 MainThreadEventQueue::~MainThreadEventQueue() {} 99 MainThreadEventQueue::~MainThreadEventQueue() {}
79 100
80 bool MainThreadEventQueue::HandleEvent( 101 bool MainThreadEventQueue::HandleEvent(
81 blink::WebScopedInputEvent event, 102 blink::WebScopedInputEvent event,
82 const ui::LatencyInfo& latency, 103 const ui::LatencyInfo& latency,
83 InputEventDispatchType original_dispatch_type, 104 InputEventDispatchType original_dispatch_type,
84 InputEventAckState ack_result) { 105 InputEventAckState ack_result) {
85 DCHECK(original_dispatch_type == DISPATCH_TYPE_BLOCKING || 106 DCHECK(original_dispatch_type == DISPATCH_TYPE_BLOCKING ||
86 original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING); 107 original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING);
(...skipping 29 matching lines...) Expand all
116 touch_event->dispatchType = 137 touch_event->dispatchType =
117 blink::WebInputEvent::ListenersForcedNonBlockingDueToFling; 138 blink::WebInputEvent::ListenersForcedNonBlockingDueToFling;
118 non_blocking = true; 139 non_blocking = true;
119 last_touch_start_forced_nonblocking_due_to_fling_ = true; 140 last_touch_start_forced_nonblocking_due_to_fling_ = true;
120 } 141 }
121 } 142 }
122 143
123 if (enable_non_blocking_due_to_main_thread_responsiveness_flag_ && 144 if (enable_non_blocking_due_to_main_thread_responsiveness_flag_ &&
124 touch_event->dispatchType == blink::WebInputEvent::Blocking) { 145 touch_event->dispatchType == blink::WebInputEvent::Blocking) {
125 bool passive_due_to_unresponsive_main = 146 bool passive_due_to_unresponsive_main =
126 renderer_scheduler_->MainThreadSeemsUnresponsive(); 147 renderer_scheduler_->MainThreadSeemsUnresponsive(
148 main_thread_responsiveness_threshold_);
127 if (passive_due_to_unresponsive_main) { 149 if (passive_due_to_unresponsive_main) {
128 touch_event->dispatchType = blink::WebInputEvent:: 150 touch_event->dispatchType = blink::WebInputEvent::
129 ListenersForcedNonBlockingDueToMainThreadResponsiveness; 151 ListenersForcedNonBlockingDueToMainThreadResponsiveness;
130 non_blocking = true; 152 non_blocking = true;
131 } 153 }
132 } 154 }
133 // If the event is non-cancelable ACK it right away. 155 // If the event is non-cancelable ACK it right away.
134 if (!non_blocking && 156 if (!non_blocking &&
135 touch_event->dispatchType != blink::WebInputEvent::Blocking) 157 touch_event->dispatchType != blink::WebInputEvent::Blocking)
136 non_blocking = true; 158 non_blocking = true;
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 case blink::WebInputEvent::MouseWheel: 358 case blink::WebInputEvent::MouseWheel:
337 return handle_raf_aligned_mouse_input_; 359 return handle_raf_aligned_mouse_input_;
338 case blink::WebInputEvent::TouchMove: 360 case blink::WebInputEvent::TouchMove:
339 return handle_raf_aligned_touch_input_; 361 return handle_raf_aligned_touch_input_;
340 default: 362 default:
341 return false; 363 return false;
342 } 364 }
343 } 365 }
344 366
345 } // namespace content 367 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/input/main_thread_event_queue.h ('k') | content/renderer/input/main_thread_event_queue_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698