| OLD | NEW |
| 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 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // RenderWidgetHostImpl | 141 // RenderWidgetHostImpl |
| 142 | 142 |
| 143 RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, | 143 RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, |
| 144 RenderProcessHost* process, | 144 RenderProcessHost* process, |
| 145 int32_t routing_id, | 145 int32_t routing_id, |
| 146 int32_t surface_id, | 146 int32_t surface_id, |
| 147 bool hidden) | 147 bool hidden) |
| 148 : view_(NULL), | 148 : view_(NULL), |
| 149 hung_renderer_delay_( | 149 hung_renderer_delay_( |
| 150 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), | 150 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), |
| 151 new_content_rendering_delay_( |
| 152 base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)), |
| 151 renderer_initialized_(false), | 153 renderer_initialized_(false), |
| 152 delegate_(delegate), | 154 delegate_(delegate), |
| 153 process_(process), | 155 process_(process), |
| 154 routing_id_(routing_id), | 156 routing_id_(routing_id), |
| 155 surface_id_(surface_id), | 157 surface_id_(surface_id), |
| 156 is_loading_(false), | 158 is_loading_(false), |
| 157 is_hidden_(hidden), | 159 is_hidden_(hidden), |
| 158 repaint_ack_pending_(false), | 160 repaint_ack_pending_(false), |
| 159 resize_ack_pending_(false), | 161 resize_ack_pending_(false), |
| 160 color_profile_out_of_date_(false), | 162 color_profile_out_of_date_(false), |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 203 |
| 202 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 204 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 203 IsRenderView() ? RenderViewHost::From(this) : NULL); | 205 IsRenderView() ? RenderViewHost::From(this) : NULL); |
| 204 if (BrowserPluginGuest::IsGuest(rvh) || | 206 if (BrowserPluginGuest::IsGuest(rvh) || |
| 205 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 207 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 206 switches::kDisableHangMonitor)) { | 208 switches::kDisableHangMonitor)) { |
| 207 hang_monitor_timeout_.reset(new TimeoutMonitor( | 209 hang_monitor_timeout_.reset(new TimeoutMonitor( |
| 208 base::Bind(&RenderWidgetHostImpl::RendererIsUnresponsive, | 210 base::Bind(&RenderWidgetHostImpl::RendererIsUnresponsive, |
| 209 weak_factory_.GetWeakPtr()))); | 211 weak_factory_.GetWeakPtr()))); |
| 210 } | 212 } |
| 213 |
| 214 new_content_rendering_timeout_.reset(new TimeoutMonitor( |
| 215 base::Bind(&RenderWidgetHostImpl::ClearDisplayedGraphics, |
| 216 weak_factory_.GetWeakPtr()))); |
| 211 } | 217 } |
| 212 | 218 |
| 213 RenderWidgetHostImpl::~RenderWidgetHostImpl() { | 219 RenderWidgetHostImpl::~RenderWidgetHostImpl() { |
| 214 if (view_weak_) | 220 if (view_weak_) |
| 215 view_weak_->RenderWidgetHostGone(); | 221 view_weak_->RenderWidgetHostGone(); |
| 216 SetView(NULL); | 222 SetView(NULL); |
| 217 | 223 |
| 218 GpuSurfaceTracker::Get()->RemoveSurface(surface_id_); | 224 GpuSurfaceTracker::Get()->RemoveSurface(surface_id_); |
| 219 surface_id_ = 0; | 225 surface_id_ = 0; |
| 220 | 226 |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 if (hang_monitor_timeout_) | 906 if (hang_monitor_timeout_) |
| 901 hang_monitor_timeout_->Restart(hung_renderer_delay_); | 907 hang_monitor_timeout_->Restart(hung_renderer_delay_); |
| 902 } | 908 } |
| 903 | 909 |
| 904 void RenderWidgetHostImpl::StopHangMonitorTimeout() { | 910 void RenderWidgetHostImpl::StopHangMonitorTimeout() { |
| 905 if (hang_monitor_timeout_) | 911 if (hang_monitor_timeout_) |
| 906 hang_monitor_timeout_->Stop(); | 912 hang_monitor_timeout_->Stop(); |
| 907 RendererIsResponsive(); | 913 RendererIsResponsive(); |
| 908 } | 914 } |
| 909 | 915 |
| 916 void RenderWidgetHostImpl::StartNewContentRenderingTimeout() { |
| 917 if (new_content_rendering_timeout_) |
| 918 new_content_rendering_timeout_->Start(new_content_rendering_delay_); |
| 919 } |
| 920 |
| 921 void RenderWidgetHostImpl::StopNewContentRenderingTimeout() { |
| 922 if (new_content_rendering_timeout_) |
| 923 new_content_rendering_timeout_->Stop(); |
| 924 } |
| 925 |
| 910 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { | 926 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { |
| 911 ForwardMouseEventWithLatencyInfo(mouse_event, ui::LatencyInfo()); | 927 ForwardMouseEventWithLatencyInfo(mouse_event, ui::LatencyInfo()); |
| 912 } | 928 } |
| 913 | 929 |
| 914 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( | 930 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( |
| 915 const blink::WebMouseEvent& mouse_event, | 931 const blink::WebMouseEvent& mouse_event, |
| 916 const ui::LatencyInfo& ui_latency) { | 932 const ui::LatencyInfo& ui_latency) { |
| 917 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", | 933 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", |
| 918 "x", mouse_event.x, "y", mouse_event.y); | 934 "x", mouse_event.x, "y", mouse_event.y); |
| 919 | 935 |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1380 NotifyRendererUnresponsive(); | 1396 NotifyRendererUnresponsive(); |
| 1381 } | 1397 } |
| 1382 | 1398 |
| 1383 void RenderWidgetHostImpl::RendererIsResponsive() { | 1399 void RenderWidgetHostImpl::RendererIsResponsive() { |
| 1384 if (is_unresponsive_) { | 1400 if (is_unresponsive_) { |
| 1385 is_unresponsive_ = false; | 1401 is_unresponsive_ = false; |
| 1386 NotifyRendererResponsive(); | 1402 NotifyRendererResponsive(); |
| 1387 } | 1403 } |
| 1388 } | 1404 } |
| 1389 | 1405 |
| 1406 void RenderWidgetHostImpl::ClearDisplayedGraphics() { |
| 1407 NotifyNewContentRenderingTimeoutForTesting(); |
| 1408 if (view_) |
| 1409 view_->ClearCompositorFrame(); |
| 1410 } |
| 1411 |
| 1390 void RenderWidgetHostImpl::OnRenderViewReady() { | 1412 void RenderWidgetHostImpl::OnRenderViewReady() { |
| 1391 SendScreenRects(); | 1413 SendScreenRects(); |
| 1392 WasResized(); | 1414 WasResized(); |
| 1393 } | 1415 } |
| 1394 | 1416 |
| 1395 void RenderWidgetHostImpl::OnRenderProcessGone(int status, int exit_code) { | 1417 void RenderWidgetHostImpl::OnRenderProcessGone(int status, int exit_code) { |
| 1396 // RenderFrameHost owns a RenderWidgetHost when it needs one, in which case | 1418 // RenderFrameHost owns a RenderWidgetHost when it needs one, in which case |
| 1397 // it handles destruction. | 1419 // it handles destruction. |
| 1398 if (!owned_by_render_frame_host_) { | 1420 if (!owned_by_render_frame_host_) { |
| 1399 // TODO(evanm): This synchronously ends up calling "delete this". | 1421 // TODO(evanm): This synchronously ends up calling "delete this". |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1459 view_->SetBounds(pos); | 1481 view_->SetBounds(pos); |
| 1460 Send(new ViewMsg_Move_ACK(routing_id_)); | 1482 Send(new ViewMsg_Move_ACK(routing_id_)); |
| 1461 } | 1483 } |
| 1462 } | 1484 } |
| 1463 | 1485 |
| 1464 bool RenderWidgetHostImpl::OnSwapCompositorFrame( | 1486 bool RenderWidgetHostImpl::OnSwapCompositorFrame( |
| 1465 const IPC::Message& message) { | 1487 const IPC::Message& message) { |
| 1466 // This trace event is used in | 1488 // This trace event is used in |
| 1467 // chrome/browser/extensions/api/cast_streaming/performance_test.cc | 1489 // chrome/browser/extensions/api/cast_streaming/performance_test.cc |
| 1468 TRACE_EVENT0("test_fps,benchmark", "OnSwapCompositorFrame"); | 1490 TRACE_EVENT0("test_fps,benchmark", "OnSwapCompositorFrame"); |
| 1491 |
| 1492 StopNewContentRenderingTimeout(); |
| 1493 |
| 1469 ViewHostMsg_SwapCompositorFrame::Param param; | 1494 ViewHostMsg_SwapCompositorFrame::Param param; |
| 1470 if (!ViewHostMsg_SwapCompositorFrame::Read(&message, ¶m)) | 1495 if (!ViewHostMsg_SwapCompositorFrame::Read(&message, ¶m)) |
| 1471 return false; | 1496 return false; |
| 1472 scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); | 1497 scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); |
| 1473 uint32_t output_surface_id = base::get<0>(param); | 1498 uint32_t output_surface_id = base::get<0>(param); |
| 1474 base::get<1>(param).AssignTo(frame.get()); | 1499 base::get<1>(param).AssignTo(frame.get()); |
| 1475 std::vector<IPC::Message> messages_to_deliver_with_frame; | 1500 std::vector<IPC::Message> messages_to_deliver_with_frame; |
| 1476 messages_to_deliver_with_frame.swap(base::get<2>(param)); | 1501 messages_to_deliver_with_frame.swap(base::get<2>(param)); |
| 1477 | 1502 |
| 1478 if (!ui::LatencyInfo::Verify(frame->metadata.latency_info, | 1503 if (!ui::LatencyInfo::Verify(frame->metadata.latency_info, |
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2131 } | 2156 } |
| 2132 | 2157 |
| 2133 #if defined(OS_WIN) | 2158 #if defined(OS_WIN) |
| 2134 gfx::NativeViewAccessible | 2159 gfx::NativeViewAccessible |
| 2135 RenderWidgetHostImpl::GetParentNativeViewAccessible() { | 2160 RenderWidgetHostImpl::GetParentNativeViewAccessible() { |
| 2136 return delegate_ ? delegate_->GetParentNativeViewAccessible() : NULL; | 2161 return delegate_ ? delegate_->GetParentNativeViewAccessible() : NULL; |
| 2137 } | 2162 } |
| 2138 #endif | 2163 #endif |
| 2139 | 2164 |
| 2140 } // namespace content | 2165 } // namespace content |
| OLD | NEW |