| Index: content/renderer/render_widget.cc
|
| diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
|
| index 26f3f99dd1de3f91fcfa39366323cf7913cefed3..294304951823c44ca5d7760939a80adfa67cc7cd 100644
|
| --- a/content/renderer/render_widget.cc
|
| +++ b/content/renderer/render_widget.cc
|
| @@ -72,6 +72,7 @@ RenderWidget::RenderWidget(RenderThreadBase* render_thread,
|
| has_focus_(false),
|
| handling_input_event_(false),
|
| closing_(false),
|
| + is_swapped_out_(false),
|
| input_method_is_active_(false),
|
| text_input_type_(WebKit::WebTextInputTypeNone),
|
| popup_type_(popup_type),
|
| @@ -90,7 +91,9 @@ RenderWidget::~RenderWidget() {
|
| RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_);
|
| current_paint_buf_ = NULL;
|
| }
|
| - RenderProcess::current()->ReleaseProcess();
|
| + // If we are swapped out, we have released already.
|
| + if (!is_swapped_out_)
|
| + RenderProcess::current()->ReleaseProcess();
|
| }
|
|
|
| // static
|
| @@ -158,6 +161,20 @@ void RenderWidget::CompleteInit(gfx::NativeViewId parent_hwnd,
|
| Send(new ViewHostMsg_RenderViewReady(routing_id_));
|
| }
|
|
|
| +void RenderWidget::SetSwappedOut(bool is_swapped_out) {
|
| + // We should only toggle between states.
|
| + DCHECK(is_swapped_out_ != is_swapped_out);
|
| + is_swapped_out_ = is_swapped_out;
|
| +
|
| + // If we are swapping out, we will call ReleaseProcess, allowing the process
|
| + // to exit if all of its RenderViews are swapped out. We wait until the
|
| + // WasSwappedOut call to do this, to avoid showing the sad tab.
|
| + // If we are swapping in, we call AddRefProcess to prevent the process from
|
| + // exiting.
|
| + if (!is_swapped_out)
|
| + RenderProcess::current()->AddRefProcess();
|
| +}
|
| +
|
| bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
|
| bool handled = true;
|
| IPC_BEGIN_MESSAGE_MAP(RenderWidget, message)
|
| @@ -166,6 +183,7 @@ bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
|
| IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize)
|
| IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden)
|
| IPC_MESSAGE_HANDLER(ViewMsg_WasRestored, OnWasRestored)
|
| + IPC_MESSAGE_HANDLER(ViewMsg_WasSwappedOut, OnWasSwappedOut)
|
| IPC_MESSAGE_HANDLER(ViewMsg_UpdateRect_ACK, OnUpdateRectAck)
|
| IPC_MESSAGE_HANDLER(ViewMsg_HandleInputEvent, OnHandleInputEvent)
|
| IPC_MESSAGE_HANDLER(ViewMsg_MouseCaptureLost, OnMouseCaptureLost)
|
| @@ -297,6 +315,14 @@ void RenderWidget::OnWasRestored(bool needs_repainting) {
|
| }
|
| }
|
|
|
| +void RenderWidget::OnWasSwappedOut() {
|
| + // If we have been swapped out and no one else is using this process,
|
| + // it's safe to exit now. If we get swapped back in, we will call
|
| + // AddRefProcess in SetSwappedOut.
|
| + if (is_swapped_out_)
|
| + RenderProcess::current()->ReleaseProcess();
|
| +}
|
| +
|
| void RenderWidget::OnRequestMoveAck() {
|
| DCHECK(pending_window_rect_count_);
|
| pending_window_rect_count_--;
|
|
|