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

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 compile error 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 304
305 void ImmediateInputRouter::OnTouchEventAck( 305 void ImmediateInputRouter::OnTouchEventAck(
306 const TouchEventWithLatencyInfo& event, 306 const TouchEventWithLatencyInfo& event,
307 InputEventAckState ack_result) { 307 InputEventAckState ack_result) {
308 ack_handler_->OnTouchEventAck(event, ack_result); 308 ack_handler_->OnTouchEventAck(event, ack_result);
309 } 309 }
310 310
311 void ImmediateInputRouter::OnGestureEventAck( 311 void ImmediateInputRouter::OnGestureEventAck(
312 const GestureEventWithLatencyInfo& event, 312 const GestureEventWithLatencyInfo& event,
313 InputEventAckState ack_result) { 313 InputEventAckState ack_result) {
314 ack_handler_->OnGestureEventAck(event.event, ack_result); 314 ack_handler_->OnGestureEventAck(event, ack_result);
315 } 315 }
316 316
317 bool ImmediateInputRouter::SendSelectRange(scoped_ptr<IPC::Message> message) { 317 bool ImmediateInputRouter::SendSelectRange(scoped_ptr<IPC::Message> message) {
318 DCHECK(message->type() == InputMsg_SelectRange::ID); 318 DCHECK(message->type() == InputMsg_SelectRange::ID);
319 if (select_range_pending_) { 319 if (select_range_pending_) {
320 next_selection_range_ = message.Pass(); 320 next_selection_range_ = message.Pass();
321 return true; 321 return true;
322 } 322 }
323 323
324 select_range_pending_ = true; 324 select_range_pending_ = true;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 } else if (input_event.type == WebKit::WebInputEvent::MouseWheel) { 383 } else if (input_event.type == WebKit::WebInputEvent::MouseWheel) {
384 // Reset the wheel-event state when appropriate. 384 // Reset the wheel-event state when appropriate.
385 mouse_wheel_pending_ = false; 385 mouse_wheel_pending_ = false;
386 } else if (WebInputEvent::isGestureEventType(input_event.type) && 386 } else if (WebInputEvent::isGestureEventType(input_event.type) &&
387 gesture_event_filter_->HasQueuedGestureEvents()) { 387 gesture_event_filter_->HasQueuedGestureEvents()) {
388 // If the gesture-event filter has queued gesture events, that implies 388 // If the gesture-event filter has queued gesture events, that implies
389 // it's awaiting an ack for the event. Since the event is being dropped, 389 // it's awaiting an ack for the event. Since the event is being dropped,
390 // it is never sent to the renderer, and so it won't receive any ACKs. 390 // it is never sent to the renderer, and so it won't receive any ACKs.
391 // So send the ACK to the gesture event filter immediately, and mark it 391 // So send the ACK to the gesture event filter immediately, and mark it
392 // as having been processed. 392 // as having been processed.
393 ProcessGestureAck(input_event.type, INPUT_EVENT_ACK_STATE_CONSUMED); 393 ProcessGestureAck(input_event.type, INPUT_EVENT_ACK_STATE_CONSUMED,
394 latency_info);
394 } else if (WebInputEvent::isTouchEventType(input_event.type)) { 395 } else if (WebInputEvent::isTouchEventType(input_event.type)) {
395 // During an overscroll gesture initiated by touch-scrolling, the 396 // During an overscroll gesture initiated by touch-scrolling, the
396 // touch-events do not reset or contribute to the overscroll gesture. 397 // touch-events do not reset or contribute to the overscroll gesture.
397 // However, the touch-events are not sent to the renderer. So send an 398 // However, the touch-events are not sent to the renderer. So send an
398 // ACK to the touch-event queue immediately. Mark the event as not 399 // ACK to the touch-event queue immediately. Mark the event as not
399 // processed, to make sure that the touch-scroll gesture that initiated 400 // processed, to make sure that the touch-scroll gesture that initiated
400 // the overscroll is updated properly. 401 // the overscroll is updated properly.
401 ProcessTouchAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, latency_info); 402 ProcessTouchAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, latency_info);
402 } 403 }
403 return; 404 return;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 // now, we can send the next mouse move event 477 // now, we can send the next mouse move event
477 if (next_mouse_move_) { 478 if (next_mouse_move_) {
478 DCHECK(next_mouse_move_->event.type == WebInputEvent::MouseMove); 479 DCHECK(next_mouse_move_->event.type == WebInputEvent::MouseMove);
479 scoped_ptr<MouseEventWithLatencyInfo> next_mouse_move 480 scoped_ptr<MouseEventWithLatencyInfo> next_mouse_move
480 = next_mouse_move_.Pass(); 481 = next_mouse_move_.Pass();
481 SendMouseEvent(*next_mouse_move); 482 SendMouseEvent(*next_mouse_move);
482 } 483 }
483 } else if (WebInputEvent::isKeyboardEventType(type)) { 484 } else if (WebInputEvent::isKeyboardEventType(type)) {
484 ProcessKeyboardAck(event_type, ack_result); 485 ProcessKeyboardAck(event_type, ack_result);
485 } else if (type == WebInputEvent::MouseWheel) { 486 } else if (type == WebInputEvent::MouseWheel) {
486 ProcessWheelAck(ack_result); 487 ProcessWheelAck(ack_result, latency_info);
487 } else if (WebInputEvent::isTouchEventType(type)) { 488 } else if (WebInputEvent::isTouchEventType(type)) {
488 ProcessTouchAck(ack_result, latency_info); 489 ProcessTouchAck(ack_result, latency_info);
489 } else if (WebInputEvent::isGestureEventType(type)) { 490 } else if (WebInputEvent::isGestureEventType(type)) {
490 ProcessGestureAck(event_type, ack_result); 491 ProcessGestureAck(event_type, ack_result, latency_info);
491 } 492 }
492 493
493 // WARNING: |this| may be deleted at this point. 494 // WARNING: |this| may be deleted at this point.
494 495
495 // This is used only for testing, and the other end does not use the 496 // This is used only for testing, and the other end does not use the
496 // source object. On linux, specifying 497 // source object. On linux, specifying
497 // Source<RenderWidgetHost> results in a very strange 498 // Source<RenderWidgetHost> results in a very strange
498 // runtime error in the epilogue of the enclosing 499 // runtime error in the epilogue of the enclosing
499 // (ProcessInputEventAck) method, but not on other platforms; using 500 // (ProcessInputEventAck) method, but not on other platforms; using
500 // 'void' instead is just as safe (since NotificationSource 501 // 'void' instead is just as safe (since NotificationSource
(...skipping 18 matching lines...) Expand all
519 NativeWebKeyboardEvent front_item = key_queue_.front(); 520 NativeWebKeyboardEvent front_item = key_queue_.front();
520 key_queue_.pop_front(); 521 key_queue_.pop_front();
521 522
522 ack_handler_->OnKeyboardEventAck(front_item, ack_result); 523 ack_handler_->OnKeyboardEventAck(front_item, ack_result);
523 // WARNING: This ImmediateInputRouter can be deallocated at this point 524 // WARNING: This ImmediateInputRouter can be deallocated at this point
524 // (i.e. in the case of Ctrl+W, where the call to 525 // (i.e. in the case of Ctrl+W, where the call to
525 // HandleKeyboardEvent destroys this ImmediateInputRouter). 526 // HandleKeyboardEvent destroys this ImmediateInputRouter).
526 } 527 }
527 } 528 }
528 529
529 void ImmediateInputRouter::ProcessWheelAck(InputEventAckState ack_result) { 530 void ImmediateInputRouter::ProcessWheelAck(InputEventAckState ack_result,
530 mouse_wheel_pending_ = false; 531 const ui::LatencyInfo& latency) {
531 532 // TODO(miletus): Add renderer side latency to each uncoalesced mouse
533 // wheel event and add terminal component to each of them.
534 current_wheel_event_.latency.AddNewLatencyFrom(latency);
532 // Process the unhandled wheel event here before calling 535 // Process the unhandled wheel event here before calling
533 // ForwardWheelEventWithLatencyInfo() since it will mutate 536 // ForwardWheelEventWithLatencyInfo() since it will mutate
534 // current_wheel_event_. 537 // current_wheel_event_.
535 ack_handler_->OnWheelEventAck(current_wheel_event_.event, ack_result); 538 ack_handler_->OnWheelEventAck(current_wheel_event_, ack_result);
539 mouse_wheel_pending_ = false;
536 540
537 // Now send the next (coalesced) mouse wheel event. 541 // Now send the next (coalesced) mouse wheel event.
538 if (!coalesced_mouse_wheel_events_.empty()) { 542 if (!coalesced_mouse_wheel_events_.empty()) {
539 MouseWheelEventWithLatencyInfo next_wheel_event = 543 MouseWheelEventWithLatencyInfo next_wheel_event =
540 coalesced_mouse_wheel_events_.front(); 544 coalesced_mouse_wheel_events_.front();
541 coalesced_mouse_wheel_events_.pop_front(); 545 coalesced_mouse_wheel_events_.pop_front();
542 SendWheelEvent(next_wheel_event); 546 SendWheelEvent(next_wheel_event);
543 } 547 }
544 } 548 }
545 549
546 void ImmediateInputRouter::ProcessGestureAck(WebInputEvent::Type type, 550 void ImmediateInputRouter::ProcessGestureAck(WebInputEvent::Type type,
547 InputEventAckState ack_result) { 551 InputEventAckState ack_result,
552 const ui::LatencyInfo& latency) {
548 // |gesture_event_filter_| will forward to OnGestureEventAck when appropriate. 553 // |gesture_event_filter_| will forward to OnGestureEventAck when appropriate.
549 gesture_event_filter_->ProcessGestureAck(ack_result, type); 554 gesture_event_filter_->ProcessGestureAck(ack_result, type, latency);
550 } 555 }
551 556
552 void ImmediateInputRouter::ProcessTouchAck( 557 void ImmediateInputRouter::ProcessTouchAck(
553 InputEventAckState ack_result, 558 InputEventAckState ack_result,
554 const ui::LatencyInfo& latency_info) { 559 const ui::LatencyInfo& latency) {
555 // |touch_event_queue_| will forward to OnTouchEventAck when appropriate. 560 // |touch_event_queue_| will forward to OnTouchEventAck when appropriate.
556 touch_event_queue_->ProcessTouchAck(ack_result, latency_info); 561 touch_event_queue_->ProcessTouchAck(ack_result, latency);
557 } 562 }
558 563
559 void ImmediateInputRouter::HandleGestureScroll( 564 void ImmediateInputRouter::HandleGestureScroll(
560 const GestureEventWithLatencyInfo& gesture_event) { 565 const GestureEventWithLatencyInfo& gesture_event) {
561 touch_event_queue_->OnGestureScrollEvent(gesture_event); 566 touch_event_queue_->OnGestureScrollEvent(gesture_event);
562 } 567 }
563 568
564 } // namespace content 569 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/immediate_input_router.h ('k') | content/browser/renderer_host/input/input_ack_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698