| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "content/browser/renderer_host/render_widget_host.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 bool handled = true; | 191 bool handled = true; |
| 192 bool msg_is_ok = true; | 192 bool msg_is_ok = true; |
| 193 IPC_BEGIN_MESSAGE_MAP_EX(RenderWidgetHost, msg, msg_is_ok) | 193 IPC_BEGIN_MESSAGE_MAP_EX(RenderWidgetHost, msg, msg_is_ok) |
| 194 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnMsgRenderViewReady) | 194 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnMsgRenderViewReady) |
| 195 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewGone, OnMsgRenderViewGone) | 195 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewGone, OnMsgRenderViewGone) |
| 196 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnMsgClose) | 196 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnMsgClose) |
| 197 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnMsgRequestMove) | 197 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnMsgRequestMove) |
| 198 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText) | 198 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText) |
| 199 IPC_MESSAGE_HANDLER(ViewHostMsg_PaintAtSize_ACK, OnMsgPaintAtSizeAck) | 199 IPC_MESSAGE_HANDLER(ViewHostMsg_PaintAtSize_ACK, OnMsgPaintAtSizeAck) |
| 200 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnMsgUpdateRect) | 200 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnMsgUpdateRect) |
| 201 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateIsDelayed, OnMsgUpdateIsDelayed) |
| 201 IPC_MESSAGE_HANDLER(ViewHostMsg_HandleInputEvent_ACK, OnMsgInputEventAck) | 202 IPC_MESSAGE_HANDLER(ViewHostMsg_HandleInputEvent_ACK, OnMsgInputEventAck) |
| 202 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnMsgFocus) | 203 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnMsgFocus) |
| 203 IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnMsgBlur) | 204 IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnMsgBlur) |
| 204 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnMsgSetCursor) | 205 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnMsgSetCursor) |
| 205 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, | 206 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, |
| 206 OnMsgTextInputStateChanged) | 207 OnMsgTextInputStateChanged) |
| 207 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCompositionRangeChanged, | 208 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCompositionRangeChanged, |
| 208 OnMsgImeCompositionRangeChanged) | 209 OnMsgImeCompositionRangeChanged) |
| 209 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCancelComposition, | 210 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCancelComposition, |
| 210 OnMsgImeCancelComposition) | 211 OnMsgImeCancelComposition) |
| (...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 OnRenderAutoResized(params.view_size); | 1078 OnRenderAutoResized(params.view_size); |
| 1078 } | 1079 } |
| 1079 | 1080 |
| 1080 // Log the time delta for processing a paint message. On platforms that don't | 1081 // Log the time delta for processing a paint message. On platforms that don't |
| 1081 // support asynchronous painting, this is equivalent to | 1082 // support asynchronous painting, this is equivalent to |
| 1082 // MPArch.RWH_TotalPaintTime. | 1083 // MPArch.RWH_TotalPaintTime. |
| 1083 TimeDelta delta = TimeTicks::Now() - paint_start; | 1084 TimeDelta delta = TimeTicks::Now() - paint_start; |
| 1084 UMA_HISTOGRAM_TIMES("MPArch.RWH_OnMsgUpdateRect", delta); | 1085 UMA_HISTOGRAM_TIMES("MPArch.RWH_OnMsgUpdateRect", delta); |
| 1085 } | 1086 } |
| 1086 | 1087 |
| 1088 void RenderWidgetHost::OnMsgUpdateIsDelayed() { |
| 1089 // Nothing to do, this message was just to unblock the UI thread. |
| 1090 } |
| 1091 |
| 1087 void RenderWidgetHost::DidUpdateBackingStore( | 1092 void RenderWidgetHost::DidUpdateBackingStore( |
| 1088 const ViewHostMsg_UpdateRect_Params& params, | 1093 const ViewHostMsg_UpdateRect_Params& params, |
| 1089 const TimeTicks& paint_start) { | 1094 const TimeTicks& paint_start) { |
| 1090 TRACE_EVENT0("renderer_host", "RenderWidgetHost::DidUpdateBackingStore"); | 1095 TRACE_EVENT0("renderer_host", "RenderWidgetHost::DidUpdateBackingStore"); |
| 1091 TimeTicks update_start = TimeTicks::Now(); | 1096 TimeTicks update_start = TimeTicks::Now(); |
| 1092 | 1097 |
| 1093 // ACK early so we can prefetch the next PaintRect if there is a next one. | 1098 if (params.needs_ack) { |
| 1094 // This must be done AFTER we're done painting with the bitmap supplied by the | 1099 // ACK early so we can prefetch the next PaintRect if there is a next one. |
| 1095 // renderer. This ACK is a signal to the renderer that the backing store can | 1100 // This must be done AFTER we're done painting with the bitmap supplied by |
| 1096 // be re-used, so the bitmap may be invalid after this call. | 1101 // the renderer. This ACK is a signal to the renderer that the backing store |
| 1097 Send(new ViewMsg_UpdateRect_ACK(routing_id_)); | 1102 // can be re-used, so the bitmap may be invalid after this call. |
| 1103 Send(new ViewMsg_UpdateRect_ACK(routing_id_)); |
| 1104 } |
| 1098 | 1105 |
| 1099 // Move the plugins if the view hasn't already been destroyed. Plugin moves | 1106 // Move the plugins if the view hasn't already been destroyed. Plugin moves |
| 1100 // will not be re-issued, so must move them now, regardless of whether we | 1107 // will not be re-issued, so must move them now, regardless of whether we |
| 1101 // paint or not. MovePluginWindows attempts to move the plugin windows and | 1108 // paint or not. MovePluginWindows attempts to move the plugin windows and |
| 1102 // in the process could dispatch other window messages which could cause the | 1109 // in the process could dispatch other window messages which could cause the |
| 1103 // view to be destroyed. | 1110 // view to be destroyed. |
| 1104 if (view_) | 1111 if (view_) |
| 1105 view_->MovePluginWindows(params.plugin_window_moves); | 1112 view_->MovePluginWindows(params.plugin_window_moves); |
| 1106 | 1113 |
| 1107 // We don't need to update the view if the view is hidden. We must do this | 1114 // We don't need to update the view if the view is hidden. We must do this |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1534 if (!view_ || !view_->HasFocus()|| !view_->LockMouse()) { | 1541 if (!view_ || !view_->HasFocus()|| !view_->LockMouse()) { |
| 1535 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); | 1542 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); |
| 1536 return false; | 1543 return false; |
| 1537 } else { | 1544 } else { |
| 1538 Send(new ViewMsg_LockMouse_ACK(routing_id_, true)); | 1545 Send(new ViewMsg_LockMouse_ACK(routing_id_, true)); |
| 1539 return true; | 1546 return true; |
| 1540 } | 1547 } |
| 1541 } | 1548 } |
| 1542 } | 1549 } |
| 1543 | 1550 |
| 1544 #if defined(OS_MACOSX) || defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | |
| 1545 // static | 1551 // static |
| 1546 void RenderWidgetHost::AcknowledgeSwapBuffers(int32 route_id, int gpu_host_id) { | 1552 void RenderWidgetHost::AcknowledgeSwapBuffers(int32 route_id, int gpu_host_id) { |
| 1547 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(gpu_host_id); | 1553 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(gpu_host_id); |
| 1548 if (ui_shim) | 1554 if (ui_shim) |
| 1549 ui_shim->Send(new AcceleratedSurfaceMsg_BuffersSwappedACK(route_id)); | 1555 ui_shim->Send(new AcceleratedSurfaceMsg_BuffersSwappedACK(route_id)); |
| 1550 } | 1556 } |
| 1551 | 1557 |
| 1552 // static | 1558 // static |
| 1553 void RenderWidgetHost::AcknowledgePostSubBuffer(int32 route_id, | 1559 void RenderWidgetHost::AcknowledgePostSubBuffer(int32 route_id, |
| 1554 int gpu_host_id) { | 1560 int gpu_host_id) { |
| 1555 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(gpu_host_id); | 1561 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(gpu_host_id); |
| 1556 if (ui_shim) | 1562 if (ui_shim) |
| 1557 ui_shim->Send(new AcceleratedSurfaceMsg_PostSubBufferACK(route_id)); | 1563 ui_shim->Send(new AcceleratedSurfaceMsg_PostSubBufferACK(route_id)); |
| 1558 } | 1564 } |
| 1559 #endif | |
| OLD | NEW |