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/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 Send(new ViewHostMsg_RenderViewReady(routing_id_)); | 505 Send(new ViewHostMsg_RenderViewReady(routing_id_)); |
506 } | 506 } |
507 | 507 |
508 void RenderWidget::SetSwappedOut(bool is_swapped_out) { | 508 void RenderWidget::SetSwappedOut(bool is_swapped_out) { |
509 // We should only toggle between states. | 509 // We should only toggle between states. |
510 DCHECK(is_swapped_out_ != is_swapped_out); | 510 DCHECK(is_swapped_out_ != is_swapped_out); |
511 is_swapped_out_ = is_swapped_out; | 511 is_swapped_out_ = is_swapped_out; |
512 | 512 |
513 // If we are swapping out, we will call ReleaseProcess, allowing the process | 513 // If we are swapping out, we will call ReleaseProcess, allowing the process |
514 // to exit if all of its RenderViews are swapped out. We wait until the | 514 // to exit if all of its RenderViews are swapped out. We wait until the |
515 // WasSwappedOut call to do this, to avoid showing the sad tab. | 515 // WasSwappedOut call to do this, to allow the unload handler to finish. |
516 // If we are swapping in, we call AddRefProcess to prevent the process from | 516 // If we are swapping in, we call AddRefProcess to prevent the process from |
517 // exiting. | 517 // exiting. |
518 if (!is_swapped_out) | 518 if (!is_swapped_out_) |
519 RenderProcess::current()->AddRefProcess(); | 519 RenderProcess::current()->AddRefProcess(); |
520 } | 520 } |
521 | 521 |
| 522 void RenderWidget::WasSwappedOut() { |
| 523 // If we have been swapped out and no one else is using this process, |
| 524 // it's safe to exit now. |
| 525 CHECK(is_swapped_out_); |
| 526 RenderProcess::current()->ReleaseProcess(); |
| 527 } |
| 528 |
522 void RenderWidget::EnableScreenMetricsEmulation( | 529 void RenderWidget::EnableScreenMetricsEmulation( |
523 const WebDeviceEmulationParams& params) { | 530 const WebDeviceEmulationParams& params) { |
524 if (!screen_metrics_emulator_) | 531 if (!screen_metrics_emulator_) |
525 screen_metrics_emulator_.reset(new ScreenMetricsEmulator(this, params)); | 532 screen_metrics_emulator_.reset(new ScreenMetricsEmulator(this, params)); |
526 else | 533 else |
527 screen_metrics_emulator_->ChangeEmulationParams(params); | 534 screen_metrics_emulator_->ChangeEmulationParams(params); |
528 } | 535 } |
529 | 536 |
530 void RenderWidget::DisableScreenMetricsEmulation() { | 537 void RenderWidget::DisableScreenMetricsEmulation() { |
531 screen_metrics_emulator_.reset(); | 538 screen_metrics_emulator_.reset(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) | 598 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) |
592 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) | 599 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) |
593 IPC_MESSAGE_HANDLER(InputMsg_SyntheticGestureCompleted, | 600 IPC_MESSAGE_HANDLER(InputMsg_SyntheticGestureCompleted, |
594 OnSyntheticGestureCompleted) | 601 OnSyntheticGestureCompleted) |
595 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) | 602 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) |
596 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck) | 603 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck) |
597 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) | 604 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) |
598 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect) | 605 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect) |
599 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) | 606 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) |
600 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) | 607 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) |
601 IPC_MESSAGE_HANDLER(ViewMsg_WasSwappedOut, OnWasSwappedOut) | |
602 IPC_MESSAGE_HANDLER(ViewMsg_SetInputMethodActive, OnSetInputMethodActive) | 608 IPC_MESSAGE_HANDLER(ViewMsg_SetInputMethodActive, OnSetInputMethodActive) |
603 IPC_MESSAGE_HANDLER(ViewMsg_CandidateWindowShown, OnCandidateWindowShown) | 609 IPC_MESSAGE_HANDLER(ViewMsg_CandidateWindowShown, OnCandidateWindowShown) |
604 IPC_MESSAGE_HANDLER(ViewMsg_CandidateWindowUpdated, | 610 IPC_MESSAGE_HANDLER(ViewMsg_CandidateWindowUpdated, |
605 OnCandidateWindowUpdated) | 611 OnCandidateWindowUpdated) |
606 IPC_MESSAGE_HANDLER(ViewMsg_CandidateWindowHidden, OnCandidateWindowHidden) | 612 IPC_MESSAGE_HANDLER(ViewMsg_CandidateWindowHidden, OnCandidateWindowHidden) |
607 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) | 613 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) |
608 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) | 614 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) |
609 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) | 615 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) |
610 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) | 616 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) |
611 #if defined(OS_ANDROID) | 617 #if defined(OS_ANDROID) |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 // Generate a full repaint. | 803 // Generate a full repaint. |
798 if (compositor_) { | 804 if (compositor_) { |
799 ui::LatencyInfo swap_latency_info(latency_info); | 805 ui::LatencyInfo swap_latency_info(latency_info); |
800 scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor( | 806 scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor( |
801 compositor_->CreateLatencyInfoSwapPromiseMonitor(&swap_latency_info)); | 807 compositor_->CreateLatencyInfoSwapPromiseMonitor(&swap_latency_info)); |
802 compositor_->SetNeedsForcedRedraw(); | 808 compositor_->SetNeedsForcedRedraw(); |
803 } | 809 } |
804 scheduleComposite(); | 810 scheduleComposite(); |
805 } | 811 } |
806 | 812 |
807 void RenderWidget::OnWasSwappedOut() { | |
808 // If we have been swapped out and no one else is using this process, | |
809 // it's safe to exit now. If we get swapped back in, we will call | |
810 // AddRefProcess in SetSwappedOut. | |
811 if (is_swapped_out_) | |
812 RenderProcess::current()->ReleaseProcess(); | |
813 } | |
814 | |
815 void RenderWidget::OnRequestMoveAck() { | 813 void RenderWidget::OnRequestMoveAck() { |
816 DCHECK(pending_window_rect_count_); | 814 DCHECK(pending_window_rect_count_); |
817 pending_window_rect_count_--; | 815 pending_window_rect_count_--; |
818 } | 816 } |
819 | 817 |
820 GURL RenderWidget::GetURLForGraphicsContext3D() { | 818 GURL RenderWidget::GetURLForGraphicsContext3D() { |
821 return GURL(); | 819 return GURL(); |
822 } | 820 } |
823 | 821 |
824 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) { | 822 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) { |
(...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2156 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2154 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
2157 video_hole_frames_.AddObserver(frame); | 2155 video_hole_frames_.AddObserver(frame); |
2158 } | 2156 } |
2159 | 2157 |
2160 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2158 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
2161 video_hole_frames_.RemoveObserver(frame); | 2159 video_hole_frames_.RemoveObserver(frame); |
2162 } | 2160 } |
2163 #endif // defined(VIDEO_HOLE) | 2161 #endif // defined(VIDEO_HOLE) |
2164 | 2162 |
2165 } // namespace content | 2163 } // namespace content |
OLD | NEW |