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

Side by Side Diff: content/browser/renderer_host/input/immediate_input_router.cc

Issue 25022003: Report LatencyInfo through trace buffer (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix nits Created 7 years, 2 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 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 "content/browser/renderer_host/input/immediate_input_router.h" 5 #include "content/browser/renderer_host/input/immediate_input_router.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "content/browser/renderer_host/input/gesture_event_filter.h" 9 #include "content/browser/renderer_host/input/gesture_event_filter.h"
10 #include "content/browser/renderer_host/input/input_ack_handler.h" 10 #include "content/browser/renderer_host/input/input_ack_handler.h"
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 const WebInputEvent& input_event, 351 const WebInputEvent& input_event,
352 const ui::LatencyInfo& latency_info, 352 const ui::LatencyInfo& latency_info,
353 bool is_keyboard_shortcut) { 353 bool is_keyboard_shortcut) {
354 TRACE_EVENT0("input", "ImmediateInputRouter::FilterAndSendWebInputEvent"); 354 TRACE_EVENT0("input", "ImmediateInputRouter::FilterAndSendWebInputEvent");
355 355
356 if (!process_->HasConnection()) 356 if (!process_->HasConnection())
357 return; 357 return;
358 358
359 DCHECK(!process_->IgnoreInputEvents()); 359 DCHECK(!process_->IgnoreInputEvents());
360 360
361 ui::LatencyInfo renderer_latency;
jdduke (slow) 2013/10/08 20:58:50 Why not use the original |latency_info| as before?
Yufeng Shen (Slow to review) 2013/10/08 21:35:18 right. forgot to clean this. done.
361 // Perform optional, synchronous event handling, sending ACK messages for 362 // Perform optional, synchronous event handling, sending ACK messages for
362 // processed events, or proceeding as usual. 363 // processed events, or proceeding as usual.
363 InputEventAckState filter_ack = client_->FilterInputEvent(input_event, 364 InputEventAckState filter_ack = client_->FilterInputEvent(input_event,
364 latency_info); 365 latency_info);
365 switch (filter_ack) { 366 switch (filter_ack) {
366 // Send the ACK and early exit. 367 // Send the ACK and early exit.
367 case INPUT_EVENT_ACK_STATE_CONSUMED: 368 case INPUT_EVENT_ACK_STATE_CONSUMED:
368 case INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS: 369 case INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS:
369 next_mouse_move_.reset(); 370 next_mouse_move_.reset();
370 ProcessInputEventAck(input_event.type, filter_ack, latency_info); 371 ProcessInputEventAck(input_event.type, filter_ack, renderer_latency);
371 // WARNING: |this| may be deleted at this point. 372 // WARNING: |this| may be deleted at this point.
372 return; 373 return;
373 374
374 case INPUT_EVENT_ACK_STATE_UNKNOWN: { 375 case INPUT_EVENT_ACK_STATE_UNKNOWN: {
375 if (input_event.type == WebKit::WebInputEvent::MouseMove) { 376 if (input_event.type == WebKit::WebInputEvent::MouseMove) {
376 // Since this mouse-move event has been consumed, there will be no ACKs. 377 // Since this mouse-move event has been consumed, there will be no ACKs.
377 // So reset the state here so that future mouse-move events do reach the 378 // So reset the state here so that future mouse-move events do reach the
378 // renderer. 379 // renderer.
379 mouse_move_pending_ = false; 380 mouse_move_pending_ = false;
380 } else if (input_event.type == WebKit::WebInputEvent::MouseWheel) { 381 } else if (input_event.type == WebKit::WebInputEvent::MouseWheel) {
381 // Reset the wheel-event state when appropriate. 382 // Reset the wheel-event state when appropriate.
382 mouse_wheel_pending_ = false; 383 mouse_wheel_pending_ = false;
383 } else if (WebInputEvent::isGestureEventType(input_event.type) && 384 } else if (WebInputEvent::isGestureEventType(input_event.type) &&
384 gesture_event_filter_->HasQueuedGestureEvents()) { 385 gesture_event_filter_->HasQueuedGestureEvents()) {
385 // If the gesture-event filter has queued gesture events, that implies 386 // If the gesture-event filter has queued gesture events, that implies
386 // it's awaiting an ack for the event. Since the event is being dropped, 387 // it's awaiting an ack for the event. Since the event is being dropped,
387 // it is never sent to the renderer, and so it won't receive any ACKs. 388 // it is never sent to the renderer, and so it won't receive any ACKs.
388 // So send the ACK to the gesture event filter immediately, and mark it 389 // So send the ACK to the gesture event filter immediately, and mark it
389 // as having been processed. 390 // as having been processed.
390 gesture_event_filter_->ProcessGestureAck(true, input_event.type); 391 gesture_event_filter_->ProcessGestureAck(true, input_event.type);
391 } else if (WebInputEvent::isTouchEventType(input_event.type)) { 392 } else if (WebInputEvent::isTouchEventType(input_event.type)) {
392 // During an overscroll gesture initiated by touch-scrolling, the 393 // During an overscroll gesture initiated by touch-scrolling, the
393 // touch-events do not reset or contribute to the overscroll gesture. 394 // touch-events do not reset or contribute to the overscroll gesture.
394 // However, the touch-events are not sent to the renderer. So send an 395 // However, the touch-events are not sent to the renderer. So send an
395 // ACK to the touch-event queue immediately. Mark the event as not 396 // ACK to the touch-event queue immediately. Mark the event as not
396 // processed, to make sure that the touch-scroll gesture that initiated 397 // processed, to make sure that the touch-scroll gesture that initiated
397 // the overscroll is updated properly. 398 // the overscroll is updated properly.
398 touch_event_queue_->ProcessTouchAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, 399 touch_event_queue_->ProcessTouchAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED,
399 latency_info); 400 renderer_latency);
400 } 401 }
401 return; 402 return;
402 } 403 }
403 404
404 // Proceed as normal. 405 // Proceed as normal.
405 case INPUT_EVENT_ACK_STATE_NOT_CONSUMED: 406 case INPUT_EVENT_ACK_STATE_NOT_CONSUMED:
406 break; 407 break;
407 } 408 }
408 409
409 // Transmit any pending wheel events on a non-wheel event. This ensures that 410 // Transmit any pending wheel events on a non-wheel event. This ensures that
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 // now, we can send the next mouse move event 475 // now, we can send the next mouse move event
475 if (next_mouse_move_) { 476 if (next_mouse_move_) {
476 DCHECK(next_mouse_move_->event.type == WebInputEvent::MouseMove); 477 DCHECK(next_mouse_move_->event.type == WebInputEvent::MouseMove);
477 scoped_ptr<MouseEventWithLatencyInfo> next_mouse_move 478 scoped_ptr<MouseEventWithLatencyInfo> next_mouse_move
478 = next_mouse_move_.Pass(); 479 = next_mouse_move_.Pass();
479 SendMouseEvent(*next_mouse_move); 480 SendMouseEvent(*next_mouse_move);
480 } 481 }
481 } else if (WebInputEvent::isKeyboardEventType(type)) { 482 } else if (WebInputEvent::isKeyboardEventType(type)) {
482 ProcessKeyboardAck(type, ack_result); 483 ProcessKeyboardAck(type, ack_result);
483 } else if (type == WebInputEvent::MouseWheel) { 484 } else if (type == WebInputEvent::MouseWheel) {
484 ProcessWheelAck(ack_result); 485 ProcessWheelAck(ack_result, latency_info);
485 } else if (WebInputEvent::isTouchEventType(type)) { 486 } else if (WebInputEvent::isTouchEventType(type)) {
486 ProcessTouchAck(ack_result, latency_info); 487 ProcessTouchAck(ack_result, latency_info);
487 } else if (WebInputEvent::isGestureEventType(type)) { 488 } else if (WebInputEvent::isGestureEventType(type)) {
488 ProcessGestureAck(type, ack_result); 489 ProcessGestureAck(type, ack_result, latency_info);
489 } 490 }
490 491
491 // WARNING: |this| may be deleted at this point. 492 // WARNING: |this| may be deleted at this point.
492 493
493 // This is used only for testing, and the other end does not use the 494 // This is used only for testing, and the other end does not use the
494 // source object. On linux, specifying 495 // source object. On linux, specifying
495 // Source<RenderWidgetHost> results in a very strange 496 // Source<RenderWidgetHost> results in a very strange
496 // runtime error in the epilogue of the enclosing 497 // runtime error in the epilogue of the enclosing
497 // (ProcessInputEventAck) method, but not on other platforms; using 498 // (ProcessInputEventAck) method, but not on other platforms; using
498 // 'void' instead is just as safe (since NotificationSource 499 // 'void' instead is just as safe (since NotificationSource
(...skipping 18 matching lines...) Expand all
517 NativeWebKeyboardEvent front_item = key_queue_.front(); 518 NativeWebKeyboardEvent front_item = key_queue_.front();
518 key_queue_.pop_front(); 519 key_queue_.pop_front();
519 520
520 ack_handler_->OnKeyboardEventAck(front_item, ack_result); 521 ack_handler_->OnKeyboardEventAck(front_item, ack_result);
521 // WARNING: This ImmediateInputRouter can be deallocated at this point 522 // WARNING: This ImmediateInputRouter can be deallocated at this point
522 // (i.e. in the case of Ctrl+W, where the call to 523 // (i.e. in the case of Ctrl+W, where the call to
523 // HandleKeyboardEvent destroys this ImmediateInputRouter). 524 // HandleKeyboardEvent destroys this ImmediateInputRouter).
524 } 525 }
525 } 526 }
526 527
527 void ImmediateInputRouter::ProcessWheelAck(InputEventAckState ack_result) { 528 void ImmediateInputRouter::ProcessWheelAck(InputEventAckState ack_result,
529 const ui::LatencyInfo& latency) {
528 mouse_wheel_pending_ = false; 530 mouse_wheel_pending_ = false;
jdduke (slow) 2013/10/08 20:58:50 Could you move |mouse_wheel_pending_ = false| down
Yufeng Shen (Slow to review) 2013/10/08 21:35:18 Done.
529 531
532 // TODO(miletus): Add renderer side latency to each uncoalesced mouse
533 // wheel event and add terminal component to each of them.
534 ui::LatencyInfo combined_latency = current_wheel_event_.latency;
jdduke (slow) 2013/10/08 20:58:50 I don't think you need the temporary |combined_lat
Yufeng Shen (Slow to review) 2013/10/08 21:35:18 Done.
535 combined_latency.AddNewLatencyFrom(latency);
536 MouseWheelEventWithLatencyInfo event(
537 current_wheel_event_.event, combined_latency);
530 // Process the unhandled wheel event here before calling 538 // Process the unhandled wheel event here before calling
531 // ForwardWheelEventWithLatencyInfo() since it will mutate 539 // ForwardWheelEventWithLatencyInfo() since it will mutate
532 // current_wheel_event_. 540 // current_wheel_event_.
533 ack_handler_->OnWheelEventAck(current_wheel_event_.event, ack_result); 541 ack_handler_->OnWheelEventAck(event, ack_result);
534 542
535 // Now send the next (coalesced) mouse wheel event. 543 // Now send the next (coalesced) mouse wheel event.
536 if (!coalesced_mouse_wheel_events_.empty()) { 544 if (!coalesced_mouse_wheel_events_.empty()) {
537 MouseWheelEventWithLatencyInfo next_wheel_event = 545 MouseWheelEventWithLatencyInfo next_wheel_event =
538 coalesced_mouse_wheel_events_.front(); 546 coalesced_mouse_wheel_events_.front();
539 coalesced_mouse_wheel_events_.pop_front(); 547 coalesced_mouse_wheel_events_.pop_front();
540 SendWheelEvent(next_wheel_event); 548 SendWheelEvent(next_wheel_event);
541 } 549 }
542 } 550 }
543 551
544 void ImmediateInputRouter::ProcessGestureAck(int type, 552 void ImmediateInputRouter::ProcessGestureAck(int type,
545 InputEventAckState ack_result) { 553 InputEventAckState ack_result,
554 const ui::LatencyInfo& latency) {
546 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result); 555 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result);
547 ack_handler_->OnGestureEventAck( 556 // TODO(miletus): Add renderer side latency to each uncoalesced gesture
548 gesture_event_filter_->GetGestureEventAwaitingAck(), ack_result); 557 // event event and add terminal component to each of them.
jdduke (slow) 2013/10/08 20:58:50 You'll need to rebase to crrev.com/26376002 after
558 GestureEventWithLatencyInfo event(
559 gesture_event_filter_->GetGestureEventAwaitingAck(), latency);
560 ack_handler_->OnGestureEventAck(event, ack_result);
549 gesture_event_filter_->ProcessGestureAck(processed, type); 561 gesture_event_filter_->ProcessGestureAck(processed, type);
550 } 562 }
551 563
552 void ImmediateInputRouter::ProcessTouchAck( 564 void ImmediateInputRouter::ProcessTouchAck(
553 InputEventAckState ack_result, 565 InputEventAckState ack_result,
554 const ui::LatencyInfo& latency_info) { 566 const ui::LatencyInfo& latency) {
555 // |touch_event_queue_| will forward to OnTouchEventAck when appropriate. 567 // |touch_event_queue_| will forward to OnTouchEventAck when appropriate.
556 touch_event_queue_->ProcessTouchAck(ack_result, latency_info); 568 touch_event_queue_->ProcessTouchAck(ack_result, latency);
557 } 569 }
558 570
559 void ImmediateInputRouter::HandleGestureScroll( 571 void ImmediateInputRouter::HandleGestureScroll(
560 const GestureEventWithLatencyInfo& gesture_event) { 572 const GestureEventWithLatencyInfo& gesture_event) {
561 if (!enable_no_touch_to_renderer_while_scrolling_) 573 if (!enable_no_touch_to_renderer_while_scrolling_)
562 return; 574 return;
563 575
564 // Once scrolling is started stop forwarding touch move events to renderer. 576 // Once scrolling is started stop forwarding touch move events to renderer.
565 if (gesture_event.event.type == WebInputEvent::GestureScrollBegin) 577 if (gesture_event.event.type == WebInputEvent::GestureScrollBegin)
566 touch_event_queue_->set_no_touch_move_to_renderer(true); 578 touch_event_queue_->set_no_touch_move_to_renderer(true);
567 579
568 if (gesture_event.event.type == WebInputEvent::GestureScrollEnd || 580 if (gesture_event.event.type == WebInputEvent::GestureScrollEnd ||
569 gesture_event.event.type == WebInputEvent::GestureFlingStart) { 581 gesture_event.event.type == WebInputEvent::GestureFlingStart) {
570 touch_event_queue_->set_no_touch_move_to_renderer(false); 582 touch_event_queue_->set_no_touch_move_to_renderer(false);
571 } 583 }
572 } 584 }
573 585
574 } // namespace content 586 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698