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_view_host_impl.h" | 5 #include "content/browser/renderer_host/render_view_host_impl.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 has_accessed_initial_document_(false), | 207 has_accessed_initial_document_(false), |
208 main_frame_routing_id_(main_frame_routing_id), | 208 main_frame_routing_id_(main_frame_routing_id), |
209 run_modal_reply_msg_(NULL), | 209 run_modal_reply_msg_(NULL), |
210 run_modal_opener_id_(MSG_ROUTING_NONE), | 210 run_modal_opener_id_(MSG_ROUTING_NONE), |
211 is_waiting_for_beforeunload_ack_(false), | 211 is_waiting_for_beforeunload_ack_(false), |
212 unload_ack_is_for_cross_site_transition_(false), | 212 unload_ack_is_for_cross_site_transition_(false), |
213 are_javascript_messages_suppressed_(false), | 213 are_javascript_messages_suppressed_(false), |
214 sudden_termination_allowed_(false), | 214 sudden_termination_allowed_(false), |
215 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 215 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
216 virtual_keyboard_requested_(false), | 216 virtual_keyboard_requested_(false), |
217 copy_requests_(0), | |
217 weak_factory_(this) { | 218 weak_factory_(this) { |
218 DCHECK(instance_.get()); | 219 DCHECK(instance_.get()); |
219 CHECK(delegate_); // http://crbug.com/82827 | 220 CHECK(delegate_); // http://crbug.com/82827 |
220 | 221 |
221 GetProcess()->EnableSendQueue(); | 222 GetProcess()->EnableSendQueue(); |
222 | 223 |
223 if (swapped_out) { | 224 if (swapped_out) { |
224 rvh_state_ = STATE_SWAPPED_OUT; | 225 rvh_state_ = STATE_SWAPPED_OUT; |
225 } else { | 226 } else { |
226 rvh_state_ = STATE_DEFAULT; | 227 rvh_state_ = STATE_DEFAULT; |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
729 | 730 |
730 switch (rvh_state_) { | 731 switch (rvh_state_) { |
731 case STATE_WAITING_FOR_UNLOAD_ACK: | 732 case STATE_WAITING_FOR_UNLOAD_ACK: |
732 SetState(STATE_WAITING_FOR_COMMIT); | 733 SetState(STATE_WAITING_FOR_COMMIT); |
733 break; | 734 break; |
734 case STATE_PENDING_SWAP_OUT: | 735 case STATE_PENDING_SWAP_OUT: |
735 SetState(STATE_SWAPPED_OUT); | 736 SetState(STATE_SWAPPED_OUT); |
736 break; | 737 break; |
737 case STATE_PENDING_SHUTDOWN: | 738 case STATE_PENDING_SHUTDOWN: |
738 DCHECK(!pending_shutdown_on_swap_out_.is_null()); | 739 DCHECK(!pending_shutdown_on_swap_out_.is_null()); |
739 pending_shutdown_on_swap_out_.Run(); | 740 if (copy_requests_ == 0) |
741 pending_shutdown_on_swap_out_.Run(); | |
740 break; | 742 break; |
741 default: | 743 default: |
742 NOTREACHED(); | 744 NOTREACHED(); |
743 } | 745 } |
744 } | 746 } |
745 | 747 |
746 void RenderViewHostImpl::WasSwappedOut( | 748 void RenderViewHostImpl::WasSwappedOut( |
747 const base::Closure& pending_delete_on_swap_out) { | 749 const base::Closure& pending_delete_on_swap_out) { |
748 Send(new ViewMsg_WasSwappedOut(GetRoutingID())); | 750 if (copy_requests_ == 0) |
751 Send(new ViewMsg_WasSwappedOut(GetRoutingID())); | |
749 if (rvh_state_ == STATE_WAITING_FOR_UNLOAD_ACK) { | 752 if (rvh_state_ == STATE_WAITING_FOR_UNLOAD_ACK) { |
750 if (instance_->active_view_count()) | 753 if (instance_->active_view_count()) |
751 SetState(STATE_PENDING_SWAP_OUT); | 754 SetState(STATE_PENDING_SWAP_OUT); |
752 else | 755 else |
753 SetPendingShutdown(pending_delete_on_swap_out); | 756 SetPendingShutdown(pending_delete_on_swap_out); |
754 } else if (rvh_state_ == STATE_WAITING_FOR_COMMIT) { | 757 } else if (rvh_state_ == STATE_WAITING_FOR_COMMIT) { |
755 SetState(STATE_SWAPPED_OUT); | 758 SetState(STATE_SWAPPED_OUT); |
756 } else if (rvh_state_ == STATE_DEFAULT) { | 759 } else if (rvh_state_ == STATE_DEFAULT) { |
757 // When the RenderView is not live, the RenderFrameHostManager will call | 760 // When the RenderView is not live, the RenderFrameHostManager will call |
758 // CommitPending directly, without calling SwapOut on the old RVH. This will | 761 // CommitPending directly, without calling SwapOut on the old RVH. This will |
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1852 Send(new ViewMsg_TimezoneChange(GetRoutingID())); | 1855 Send(new ViewMsg_TimezoneChange(GetRoutingID())); |
1853 } | 1856 } |
1854 | 1857 |
1855 void RenderViewHostImpl::GetAudioOutputControllers( | 1858 void RenderViewHostImpl::GetAudioOutputControllers( |
1856 const GetAudioOutputControllersCallback& callback) const { | 1859 const GetAudioOutputControllersCallback& callback) const { |
1857 AudioRendererHost* audio_host = | 1860 AudioRendererHost* audio_host = |
1858 static_cast<RenderProcessHostImpl*>(GetProcess())->audio_renderer_host(); | 1861 static_cast<RenderProcessHostImpl*>(GetProcess())->audio_renderer_host(); |
1859 audio_host->GetOutputControllers(GetRoutingID(), callback); | 1862 audio_host->GetOutputControllers(GetRoutingID(), callback); |
1860 } | 1863 } |
1861 | 1864 |
1865 void RenderViewHostImpl::CopyFromBackingStoreCallback( | |
1866 const base::Callback<void(bool, const SkBitmap&)>& callback, | |
1867 bool success, | |
1868 const SkBitmap& bitmap) { | |
1869 --copy_requests_; | |
1870 LOG(ERROR) << "Done with a request: " << copy_requests_; | |
1871 callback.Run(success, bitmap); | |
1872 if (copy_requests_ == 0) { | |
1873 if (!IsRVHStateActive(rvh_state_)) { | |
1874 Send(new ViewMsg_WasSwappedOut(GetRoutingID())); | |
1875 instance_->decrement_active_view_count(); | |
1876 } | |
1877 | |
1878 if (rvh_state_ == STATE_PENDING_SHUTDOWN) { | |
1879 DCHECK(!pending_shutdown_on_swap_out_.is_null()); | |
1880 pending_shutdown_on_swap_out_.Run(); | |
mfomitchev
2014/03/24 18:49:10
Can't we have a situation where this gets executed
| |
1881 } | |
1882 } | |
1883 } | |
1884 | |
1885 void RenderViewHostImpl::CopyFromBackingStore( | |
1886 const gfx::Rect& src_rect, | |
1887 const gfx::Size& accelerated_dst_size, | |
1888 const base::Callback<void(bool, const SkBitmap&)>& callback) { | |
1889 DCHECK(IsRVHStateActive(rvh_state_)); | |
1890 if (!IsRVHStateActive(rvh_state_)) { | |
1891 callback.Run(false, SkBitmap()); | |
1892 return; | |
1893 } | |
1894 ++copy_requests_; | |
1895 LOG(ERROR) << "Starting a request: " << copy_requests_; | |
1896 RenderWidgetHostImpl::CopyFromBackingStore(src_rect, accelerated_dst_size, | |
1897 base::Bind(&RenderViewHostImpl::CopyFromBackingStoreCallback, | |
1898 weak_factory_.GetWeakPtr(), | |
1899 callback)); | |
1900 } | |
1901 | |
1862 void RenderViewHostImpl::ClearFocusedNode() { | 1902 void RenderViewHostImpl::ClearFocusedNode() { |
1863 Send(new ViewMsg_ClearFocusedNode(GetRoutingID())); | 1903 Send(new ViewMsg_ClearFocusedNode(GetRoutingID())); |
1864 } | 1904 } |
1865 | 1905 |
1866 void RenderViewHostImpl::Zoom(PageZoom zoom) { | 1906 void RenderViewHostImpl::Zoom(PageZoom zoom) { |
1867 Send(new ViewMsg_Zoom(GetRoutingID(), zoom)); | 1907 Send(new ViewMsg_Zoom(GetRoutingID(), zoom)); |
1868 } | 1908 } |
1869 | 1909 |
1870 void RenderViewHostImpl::ReloadFrame() { | 1910 void RenderViewHostImpl::ReloadFrame() { |
1871 Send(new ViewMsg_ReloadFrame(GetRoutingID())); | 1911 Send(new ViewMsg_ReloadFrame(GetRoutingID())); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2042 params.allow_multiple_selection); | 2082 params.allow_multiple_selection); |
2043 } | 2083 } |
2044 } | 2084 } |
2045 #endif | 2085 #endif |
2046 | 2086 |
2047 void RenderViewHostImpl::SetState(RenderViewHostImplState rvh_state) { | 2087 void RenderViewHostImpl::SetState(RenderViewHostImplState rvh_state) { |
2048 // We update the number of RenderViews in a SiteInstance when the | 2088 // We update the number of RenderViews in a SiteInstance when the |
2049 // swapped out status of this RenderView gets flipped to/from live. | 2089 // swapped out status of this RenderView gets flipped to/from live. |
2050 if (!IsRVHStateActive(rvh_state_) && IsRVHStateActive(rvh_state)) | 2090 if (!IsRVHStateActive(rvh_state_) && IsRVHStateActive(rvh_state)) |
2051 instance_->increment_active_view_count(); | 2091 instance_->increment_active_view_count(); |
2052 else if (IsRVHStateActive(rvh_state_) && !IsRVHStateActive(rvh_state)) | 2092 else if (IsRVHStateActive(rvh_state_) && !IsRVHStateActive(rvh_state) && |
2093 copy_requests_ == 0) | |
clamy
2014/02/26 16:50:56
If the site instance is not decremented when the n
| |
2053 instance_->decrement_active_view_count(); | 2094 instance_->decrement_active_view_count(); |
2054 | 2095 |
2055 // Whenever we change the RVH state to and from live or swapped out state, we | 2096 // Whenever we change the RVH state to and from live or swapped out state, we |
2056 // should not be waiting for beforeunload or unload acks. We clear them here | 2097 // should not be waiting for beforeunload or unload acks. We clear them here |
2057 // to be safe, since they can cause navigations to be ignored in OnNavigate. | 2098 // to be safe, since they can cause navigations to be ignored in OnNavigate. |
2058 if (rvh_state == STATE_DEFAULT || | 2099 if (rvh_state == STATE_DEFAULT || |
2059 rvh_state == STATE_SWAPPED_OUT || | 2100 rvh_state == STATE_SWAPPED_OUT || |
2060 rvh_state_ == STATE_DEFAULT || | 2101 rvh_state_ == STATE_DEFAULT || |
2061 rvh_state_ == STATE_SWAPPED_OUT) { | 2102 rvh_state_ == STATE_SWAPPED_OUT) { |
2062 is_waiting_for_beforeunload_ack_ = false; | 2103 is_waiting_for_beforeunload_ack_ = false; |
(...skipping 16 matching lines...) Expand all Loading... | |
2079 return true; | 2120 return true; |
2080 } | 2121 } |
2081 | 2122 |
2082 void RenderViewHostImpl::AttachToFrameTree() { | 2123 void RenderViewHostImpl::AttachToFrameTree() { |
2083 FrameTree* frame_tree = delegate_->GetFrameTree(); | 2124 FrameTree* frame_tree = delegate_->GetFrameTree(); |
2084 | 2125 |
2085 frame_tree->ResetForMainFrameSwap(); | 2126 frame_tree->ResetForMainFrameSwap(); |
2086 } | 2127 } |
2087 | 2128 |
2088 } // namespace content | 2129 } // namespace content |
OLD | NEW |