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

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

Issue 1873783003: Convert //content/renderer from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/render_widget_input_handler.h" 5 #include "content/renderer/input/render_widget_input_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 const WebInputEvent& input_event, 181 const WebInputEvent& input_event,
182 const ui::LatencyInfo& latency_info, 182 const ui::LatencyInfo& latency_info,
183 InputEventDispatchType dispatch_type) { 183 InputEventDispatchType dispatch_type) {
184 base::AutoReset<bool> handling_input_event_resetter(&handling_input_event_, 184 base::AutoReset<bool> handling_input_event_resetter(&handling_input_event_,
185 true); 185 true);
186 base::AutoReset<WebInputEvent::Type> handling_event_type_resetter( 186 base::AutoReset<WebInputEvent::Type> handling_event_type_resetter(
187 &handling_event_type_, input_event.type); 187 &handling_event_type_, input_event.type);
188 188
189 // Calls into |didOverscroll()| while handling this event will populate 189 // Calls into |didOverscroll()| while handling this event will populate
190 // |event_overscroll|, which in turn will be bundled with the event ack. 190 // |event_overscroll|, which in turn will be bundled with the event ack.
191 scoped_ptr<DidOverscrollParams> event_overscroll; 191 std::unique_ptr<DidOverscrollParams> event_overscroll;
192 base::AutoReset<scoped_ptr<DidOverscrollParams>*> 192 base::AutoReset<std::unique_ptr<DidOverscrollParams>*>
193 handling_event_overscroll_resetter(&handling_event_overscroll_, 193 handling_event_overscroll_resetter(&handling_event_overscroll_,
194 &event_overscroll); 194 &event_overscroll);
195 195
196 #if defined(OS_ANDROID) 196 #if defined(OS_ANDROID)
197 bool from_ime = false; 197 bool from_ime = false;
198 198
199 // For most keyboard events, we want the change source to be FROM_IME because 199 // For most keyboard events, we want the change source to be FROM_IME because
200 // we don't need to update IME states in ReplicaInputConnection. 200 // we don't need to update IME states in ReplicaInputConnection.
201 if (!widget_->IsUsingImeThread() && 201 if (!widget_->IsUsingImeThread() &&
202 WebInputEvent::isKeyboardEventType(input_event.type)) { 202 WebInputEvent::isKeyboardEventType(input_event.type)) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 TRACE_EVENT_WITH_FLOW1("input,benchmark", "LatencyInfo.Flow", 234 TRACE_EVENT_WITH_FLOW1("input,benchmark", "LatencyInfo.Flow",
235 TRACE_ID_DONT_MANGLE(latency_info.trace_id()), 235 TRACE_ID_DONT_MANGLE(latency_info.trace_id()),
236 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, 236 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT,
237 "step", "HandleInputEventMain"); 237 "step", "HandleInputEventMain");
238 238
239 // If we don't have a high res timer, these metrics won't be accurate enough 239 // If we don't have a high res timer, these metrics won't be accurate enough
240 // to be worth collecting. Note that this does introduce some sampling bias. 240 // to be worth collecting. Note that this does introduce some sampling bias.
241 if (!start_time.is_null()) 241 if (!start_time.is_null())
242 LogInputEventLatencyUma(input_event, start_time); 242 LogInputEventLatencyUma(input_event, start_time);
243 243
244 scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor; 244 std::unique_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor;
245 ui::LatencyInfo swap_latency_info(latency_info); 245 ui::LatencyInfo swap_latency_info(latency_info);
246 246
247 if (widget_->compositor()) { 247 if (widget_->compositor()) {
248 latency_info_swap_promise_monitor = 248 latency_info_swap_promise_monitor =
249 widget_->compositor()->CreateLatencyInfoSwapPromiseMonitor( 249 widget_->compositor()->CreateLatencyInfoSwapPromiseMonitor(
250 &swap_latency_info); 250 &swap_latency_info);
251 } 251 }
252 252
253 bool prevent_default = false; 253 bool prevent_default = false;
254 if (WebInputEvent::isMouseEventType(input_event.type)) { 254 if (WebInputEvent::isMouseEventType(input_event.type)) {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 if (dispatch_type == DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN || 404 if (dispatch_type == DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN ||
405 dispatch_type == DISPATCH_TYPE_NON_BLOCKING_NOTIFY_MAIN) { 405 dispatch_type == DISPATCH_TYPE_NON_BLOCKING_NOTIFY_MAIN) {
406 // |non_blocking| means it was ack'd already by the InputHandlerProxy 406 // |non_blocking| means it was ack'd already by the InputHandlerProxy
407 // so let the delegate know the event has been handled. 407 // so let the delegate know the event has been handled.
408 delegate_->NotifyInputEventHandled(input_event.type); 408 delegate_->NotifyInputEventHandled(input_event.type);
409 } 409 }
410 410
411 if ((dispatch_type == DISPATCH_TYPE_BLOCKING || 411 if ((dispatch_type == DISPATCH_TYPE_BLOCKING ||
412 dispatch_type == DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN) && 412 dispatch_type == DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN) &&
413 can_send_ack) { 413 can_send_ack) {
414 scoped_ptr<InputEventAck> response(new InputEventAck( 414 std::unique_ptr<InputEventAck> response(new InputEventAck(
415 input_event.type, ack_result, swap_latency_info, 415 input_event.type, ack_result, swap_latency_info,
416 std::move(event_overscroll), 416 std::move(event_overscroll),
417 WebInputEventTraits::GetUniqueTouchEventId(input_event))); 417 WebInputEventTraits::GetUniqueTouchEventId(input_event)));
418 if (rate_limiting_wanted && frame_pending && !widget_->is_hidden()) { 418 if (rate_limiting_wanted && frame_pending && !widget_->is_hidden()) {
419 // We want to rate limit the input events in this case, so we'll wait for 419 // We want to rate limit the input events in this case, so we'll wait for
420 // painting to finish before ACKing this message. 420 // painting to finish before ACKing this message.
421 TRACE_EVENT_INSTANT0( 421 TRACE_EVENT_INSTANT0(
422 "renderer", 422 "renderer",
423 "RenderWidgetInputHandler::OnHandleInputEvent ack throttled", 423 "RenderWidgetInputHandler::OnHandleInputEvent ack throttled",
424 TRACE_EVENT_SCOPE_THREAD); 424 TRACE_EVENT_SCOPE_THREAD);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 delegate_->FocusChangeComplete(); 482 delegate_->FocusChangeComplete();
483 } 483 }
484 #endif 484 #endif
485 } 485 }
486 486
487 void RenderWidgetInputHandler::DidOverscrollFromBlink( 487 void RenderWidgetInputHandler::DidOverscrollFromBlink(
488 const WebFloatSize& unusedDelta, 488 const WebFloatSize& unusedDelta,
489 const WebFloatSize& accumulatedRootOverScroll, 489 const WebFloatSize& accumulatedRootOverScroll,
490 const WebFloatPoint& position, 490 const WebFloatPoint& position,
491 const WebFloatSize& velocity) { 491 const WebFloatSize& velocity) {
492 scoped_ptr<DidOverscrollParams> params(new DidOverscrollParams()); 492 std::unique_ptr<DidOverscrollParams> params(new DidOverscrollParams());
493 params->accumulated_overscroll = gfx::Vector2dF( 493 params->accumulated_overscroll = gfx::Vector2dF(
494 accumulatedRootOverScroll.width, accumulatedRootOverScroll.height); 494 accumulatedRootOverScroll.width, accumulatedRootOverScroll.height);
495 params->latest_overscroll_delta = 495 params->latest_overscroll_delta =
496 gfx::Vector2dF(unusedDelta.width, unusedDelta.height); 496 gfx::Vector2dF(unusedDelta.width, unusedDelta.height);
497 // TODO(sataya.m): don't negate velocity once http://crbug.com/499743 is 497 // TODO(sataya.m): don't negate velocity once http://crbug.com/499743 is
498 // fixed. 498 // fixed.
499 params->current_fling_velocity = 499 params->current_fling_velocity =
500 gfx::Vector2dF(-velocity.width, -velocity.height); 500 gfx::Vector2dF(-velocity.width, -velocity.height);
501 params->causal_event_viewport_point = gfx::PointF(position.x, position.y); 501 params->causal_event_viewport_point = gfx::PointF(position.x, position.y);
502 502
503 // If we're currently handling an event, stash the overscroll data such that 503 // If we're currently handling an event, stash the overscroll data such that
504 // it can be bundled in the event ack. 504 // it can be bundled in the event ack.
505 if (handling_event_overscroll_) { 505 if (handling_event_overscroll_) {
506 *handling_event_overscroll_ = std::move(params); 506 *handling_event_overscroll_ = std::move(params);
507 return; 507 return;
508 } 508 }
509 509
510 delegate_->OnDidOverscroll(*params); 510 delegate_->OnDidOverscroll(*params);
511 } 511 }
512 512
513 bool RenderWidgetInputHandler::SendAckForMouseMoveFromDebugger() { 513 bool RenderWidgetInputHandler::SendAckForMouseMoveFromDebugger() {
514 if (handling_event_type_ == WebInputEvent::MouseMove) { 514 if (handling_event_type_ == WebInputEvent::MouseMove) {
515 // If we pause multiple times during a single mouse move event, we should 515 // If we pause multiple times during a single mouse move event, we should
516 // only send ACK once. 516 // only send ACK once.
517 if (!ignore_ack_for_mouse_move_from_debugger_) { 517 if (!ignore_ack_for_mouse_move_from_debugger_) {
518 scoped_ptr<InputEventAck> ack(new InputEventAck( 518 std::unique_ptr<InputEventAck> ack(new InputEventAck(
519 handling_event_type_, INPUT_EVENT_ACK_STATE_CONSUMED)); 519 handling_event_type_, INPUT_EVENT_ACK_STATE_CONSUMED));
520 delegate_->OnInputEventAck(std::move(ack)); 520 delegate_->OnInputEventAck(std::move(ack));
521 return true; 521 return true;
522 } 522 }
523 } 523 }
524 return false; 524 return false;
525 } 525 }
526 526
527 void RenderWidgetInputHandler::IgnoreAckForMouseMoveFromDebugger() { 527 void RenderWidgetInputHandler::IgnoreAckForMouseMoveFromDebugger() {
528 ignore_ack_for_mouse_move_from_debugger_ = true; 528 ignore_ack_for_mouse_move_from_debugger_ = true;
529 } 529 }
530 530
531 void RenderWidgetInputHandler::FlushPendingInputEventAck() { 531 void RenderWidgetInputHandler::FlushPendingInputEventAck() {
532 if (pending_input_event_ack_) { 532 if (pending_input_event_ack_) {
533 TRACE_EVENT_ASYNC_END0("input", 533 TRACE_EVENT_ASYNC_END0("input",
534 "RenderWidgetInputHandler::ThrottledInputEventAck", 534 "RenderWidgetInputHandler::ThrottledInputEventAck",
535 pending_input_event_ack_.get()); 535 pending_input_event_ack_.get());
536 delegate_->OnInputEventAck(std::move(pending_input_event_ack_)); 536 delegate_->OnInputEventAck(std::move(pending_input_event_ack_));
537 } 537 }
538 total_input_handling_time_this_frame_ = base::TimeDelta(); 538 total_input_handling_time_this_frame_ = base::TimeDelta();
539 } 539 }
540 540
541 } // namespace content 541 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/input/render_widget_input_handler.h ('k') | content/renderer/input/render_widget_input_handler_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698