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

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 83483007: Expose synthetic delays through the GPU benchmarking extension (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/auto_reset.h" 11 #include "base/auto_reset.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/containers/hash_tables.h" 14 #include "base/containers/hash_tables.h"
15 #include "base/debug/trace_event.h" 15 #include "base/debug/trace_event.h"
16 #include "base/debug/trace_event.h"
16 #include "base/i18n/rtl.h" 17 #include "base/i18n/rtl.h"
17 #include "base/lazy_instance.h" 18 #include "base/lazy_instance.h"
18 #include "base/message_loop/message_loop.h" 19 #include "base/message_loop/message_loop.h"
19 #include "base/metrics/field_trial.h" 20 #include "base/metrics/field_trial.h"
20 #include "base/metrics/histogram.h" 21 #include "base/metrics/histogram.h"
21 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/utf_string_conversions.h" 23 #include "base/strings/utf_string_conversions.h"
23 #include "cc/output/compositor_frame.h" 24 #include "cc/output/compositor_frame.h"
24 #include "cc/output/compositor_frame_ack.h" 25 #include "cc/output/compositor_frame_ack.h"
25 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 26 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
26 #include "content/browser/gpu/compositor_util.h" 27 #include "content/browser/gpu/compositor_util.h"
27 #include "content/browser/gpu/gpu_process_host.h" 28 #include "content/browser/gpu/gpu_process_host.h"
28 #include "content/browser/gpu/gpu_process_host_ui_shim.h" 29 #include "content/browser/gpu/gpu_process_host_ui_shim.h"
29 #include "content/browser/gpu/gpu_surface_tracker.h" 30 #include "content/browser/gpu/gpu_surface_tracker.h"
30 #include "content/browser/renderer_host/backing_store.h" 31 #include "content/browser/renderer_host/backing_store.h"
31 #include "content/browser/renderer_host/backing_store_manager.h" 32 #include "content/browser/renderer_host/backing_store_manager.h"
32 #include "content/browser/renderer_host/dip_util.h" 33 #include "content/browser/renderer_host/dip_util.h"
33 #include "content/browser/renderer_host/input/immediate_input_router.h" 34 #include "content/browser/renderer_host/input/immediate_input_router.h"
34 #include "content/browser/renderer_host/overscroll_controller.h" 35 #include "content/browser/renderer_host/overscroll_controller.h"
35 #include "content/browser/renderer_host/render_process_host_impl.h" 36 #include "content/browser/renderer_host/render_process_host_impl.h"
36 #include "content/browser/renderer_host/render_view_host_impl.h" 37 #include "content/browser/renderer_host/render_view_host_impl.h"
37 #include "content/browser/renderer_host/render_widget_helper.h" 38 #include "content/browser/renderer_host/render_widget_helper.h"
38 #include "content/browser/renderer_host/render_widget_host_delegate.h" 39 #include "content/browser/renderer_host/render_widget_host_delegate.h"
40 #include "content/browser/tracing/tracing_controller_impl.h"
39 #include "content/common/accessibility_messages.h" 41 #include "content/common/accessibility_messages.h"
40 #include "content/common/content_constants_internal.h" 42 #include "content/common/content_constants_internal.h"
41 #include "content/common/gpu/gpu_messages.h" 43 #include "content/common/gpu/gpu_messages.h"
42 #include "content/common/input_messages.h" 44 #include "content/common/input_messages.h"
43 #include "content/common/view_messages.h" 45 #include "content/common/view_messages.h"
44 #include "content/port/browser/render_widget_host_view_port.h" 46 #include "content/port/browser/render_widget_host_view_port.h"
45 #include "content/public/browser/native_web_keyboard_event.h" 47 #include "content/public/browser/native_web_keyboard_event.h"
46 #include "content/public/browser/notification_service.h" 48 #include "content/public/browser/notification_service.h"
47 #include "content/public/browser/notification_types.h" 49 #include "content/public/browser/notification_types.h"
48 #include "content/public/browser/render_widget_host_iterator.h" 50 #include "content/public/browser/render_widget_host_iterator.h"
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 IPC_MESSAGE_HANDLER(ViewHostMsg_CompositorSurfaceBuffersSwapped, 462 IPC_MESSAGE_HANDLER(ViewHostMsg_CompositorSurfaceBuffersSwapped,
461 OnCompositorSurfaceBuffersSwapped) 463 OnCompositorSurfaceBuffersSwapped)
462 #endif 464 #endif
463 IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_SwapCompositorFrame, 465 IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_SwapCompositorFrame,
464 msg_is_ok = OnSwapCompositorFrame(msg)) 466 msg_is_ok = OnSwapCompositorFrame(msg))
465 IPC_MESSAGE_HANDLER(ViewHostMsg_DidOverscroll, OnOverscrolled) 467 IPC_MESSAGE_HANDLER(ViewHostMsg_DidOverscroll, OnOverscrolled)
466 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) 468 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect)
467 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateIsDelayed, OnUpdateIsDelayed) 469 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateIsDelayed, OnUpdateIsDelayed)
468 IPC_MESSAGE_HANDLER(ViewHostMsg_BeginSmoothScroll, OnBeginSmoothScroll) 470 IPC_MESSAGE_HANDLER(ViewHostMsg_BeginSmoothScroll, OnBeginSmoothScroll)
469 IPC_MESSAGE_HANDLER(ViewHostMsg_BeginPinch, OnBeginPinch) 471 IPC_MESSAGE_HANDLER(ViewHostMsg_BeginPinch, OnBeginPinch)
472 IPC_MESSAGE_HANDLER(ViewHostMsg_ConfigureSyntheticDelay,
473 OnConfigureSyntheticDelay)
470 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnFocus) 474 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnFocus)
471 IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnBlur) 475 IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnBlur)
472 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) 476 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor)
473 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputTypeChanged, 477 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputTypeChanged,
474 OnTextInputTypeChanged) 478 OnTextInputTypeChanged)
475 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCancelComposition, 479 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCancelComposition,
476 OnImeCancelComposition) 480 OnImeCancelComposition)
477 IPC_MESSAGE_HANDLER(ViewHostMsg_DidActivateAcceleratedCompositing, 481 IPC_MESSAGE_HANDLER(ViewHostMsg_DidActivateAcceleratedCompositing,
478 OnDidActivateAcceleratedCompositing) 482 OnDidActivateAcceleratedCompositing)
479 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) 483 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse)
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 synthetic_gesture_controller_.BeginSmoothScroll(view_, params); 1723 synthetic_gesture_controller_.BeginSmoothScroll(view_, params);
1720 } 1724 }
1721 1725
1722 void RenderWidgetHostImpl::OnBeginPinch( 1726 void RenderWidgetHostImpl::OnBeginPinch(
1723 const ViewHostMsg_BeginPinch_Params& params) { 1727 const ViewHostMsg_BeginPinch_Params& params) {
1724 if (!view_) 1728 if (!view_)
1725 return; 1729 return;
1726 synthetic_gesture_controller_.BeginPinch(view_, params); 1730 synthetic_gesture_controller_.BeginPinch(view_, params);
1727 } 1731 }
1728 1732
1733 void RenderWidgetHostImpl::OnConfigureSyntheticDelay(
1734 const ViewHostMsg_ConfigureSyntheticDelay_Params& params) {
1735 TracingControllerImpl::GetInstance()->ConfigureSyntheticDelay(
1736 params.name, params.target_duration,
1737 static_cast<base::debug::TraceEventSyntheticDelay::Mode>(params.mode),
1738 base::Bind(&RenderWidgetHostImpl::DidConfigureSyntheticDelay,
1739 weak_factory_.GetWeakPtr()));
1740 }
1741
1729 void RenderWidgetHostImpl::OnFocus() { 1742 void RenderWidgetHostImpl::OnFocus() {
1730 // Only RenderViewHost can deal with that message. 1743 // Only RenderViewHost can deal with that message.
1731 RecordAction(UserMetricsAction("BadMessageTerminate_RWH4")); 1744 RecordAction(UserMetricsAction("BadMessageTerminate_RWH4"));
1732 GetProcess()->ReceivedBadMessage(); 1745 GetProcess()->ReceivedBadMessage();
1733 } 1746 }
1734 1747
1735 void RenderWidgetHostImpl::OnBlur() { 1748 void RenderWidgetHostImpl::OnBlur() {
1736 // Only RenderViewHost can deal with that message. 1749 // Only RenderViewHost can deal with that message.
1737 RecordAction(UserMetricsAction("BadMessageTerminate_RWH5")); 1750 RecordAction(UserMetricsAction("BadMessageTerminate_RWH5"));
1738 GetProcess()->ReceivedBadMessage(); 1751 GetProcess()->ReceivedBadMessage();
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
2450 Send(new ViewMsg_WindowSnapshotCompleted( 2463 Send(new ViewMsg_WindowSnapshotCompleted(
2451 GetRoutingID(), snapshot_id, snapshot_size, png)); 2464 GetRoutingID(), snapshot_id, snapshot_size, png));
2452 return; 2465 return;
2453 } 2466 }
2454 } 2467 }
2455 2468
2456 Send(new ViewMsg_WindowSnapshotCompleted( 2469 Send(new ViewMsg_WindowSnapshotCompleted(
2457 GetRoutingID(), snapshot_id, gfx::Size(), png)); 2470 GetRoutingID(), snapshot_id, gfx::Size(), png));
2458 } 2471 }
2459 2472
2473 void RenderWidgetHostImpl::DidConfigureSyntheticDelay() {
2474 Send(new ViewMsg_ConfigureSyntheticDelayAck(GetRoutingID()));
2475 }
2476
2460 // static 2477 // static
2461 void RenderWidgetHostImpl::CompositorFrameDrawn( 2478 void RenderWidgetHostImpl::CompositorFrameDrawn(
2462 const ui::LatencyInfo& latency_info) { 2479 const ui::LatencyInfo& latency_info) {
2463 std::set<RenderWidgetHostImpl*> rwhi_set; 2480 std::set<RenderWidgetHostImpl*> rwhi_set;
2464 2481
2465 for (ui::LatencyInfo::LatencyMap::const_iterator b = 2482 for (ui::LatencyInfo::LatencyMap::const_iterator b =
2466 latency_info.latency_components.begin(); 2483 latency_info.latency_components.begin();
2467 b != latency_info.latency_components.end(); 2484 b != latency_info.latency_components.end();
2468 ++b) { 2485 ++b) {
2469 if (b->first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT || 2486 if (b->first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT ||
2470 b->first.first == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT) { 2487 b->first.first == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT) {
2471 // Matches with GetLatencyComponentId 2488 // Matches with GetLatencyComponentId
2472 int routing_id = b->first.second & 0xffffffff; 2489 int routing_id = b->first.second & 0xffffffff;
2473 int process_id = (b->first.second >> 32) & 0xffffffff; 2490 int process_id = (b->first.second >> 32) & 0xffffffff;
2474 RenderWidgetHost* rwh = 2491 RenderWidgetHost* rwh =
2475 RenderWidgetHost::FromID(process_id, routing_id); 2492 RenderWidgetHost::FromID(process_id, routing_id);
2476 if (!rwh) { 2493 if (!rwh) {
2477 continue; 2494 continue;
2478 } 2495 }
2479 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh); 2496 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh);
2480 if (rwhi_set.insert(rwhi).second) 2497 if (rwhi_set.insert(rwhi).second)
2481 rwhi->FrameSwapped(latency_info); 2498 rwhi->FrameSwapped(latency_info);
2482 } 2499 }
2483 } 2500 }
2484 } 2501 }
2485 2502
2486 } // namespace content 2503 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698