Index: content/browser/renderer_host/render_view_host_impl.cc |
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc |
index b9be7b032dcabeef778a274ec66878a06b339e7e..27a678463ec0fd64746a09107394d0eea55a4216 100644 |
--- a/content/browser/renderer_host/render_view_host_impl.cc |
+++ b/content/browser/renderer_host/render_view_host_impl.cc |
@@ -213,6 +213,7 @@ RenderViewHostImpl::RenderViewHostImpl( |
sudden_termination_allowed_(false), |
render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
virtual_keyboard_requested_(false), |
+ copy_requests_(0), |
weak_factory_(this) { |
DCHECK(instance_.get()); |
CHECK(delegate_); // http://crbug.com/82827 |
@@ -644,7 +645,8 @@ void RenderViewHostImpl::OnSwappedOut(bool timed_out) { |
break; |
case STATE_PENDING_SHUTDOWN: |
DCHECK(!pending_shutdown_on_swap_out_.is_null()); |
- pending_shutdown_on_swap_out_.Run(); |
+ if (copy_requests_ == 0) |
+ pending_shutdown_on_swap_out_.Run(); |
break; |
default: |
NOTREACHED(); |
@@ -653,11 +655,14 @@ void RenderViewHostImpl::OnSwappedOut(bool timed_out) { |
void RenderViewHostImpl::WasSwappedOut( |
const base::Closure& pending_delete_on_swap_out) { |
- Send(new ViewMsg_WasSwappedOut(GetRoutingID())); |
+ if (copy_requests_ == 0) |
nasko
2014/03/26 22:48:27
nit: A comment explaining why we aren't sending th
mfomitchev
2014/03/27 21:51:34
Done.
|
+ Send(new ViewMsg_WasSwappedOut(GetRoutingID())); |
if (rvh_state_ == STATE_WAITING_FOR_UNLOAD_ACK) { |
SetState(STATE_PENDING_SWAP_OUT); |
- if (!instance_->active_view_count()) |
+ if (!instance_->active_view_count() || |
+ (instance_->active_view_count() - copy_requests_) == 0) { |
clamy
2014/03/27 15:59:36
I don't think this is correct. If you have 2 copy
mfomitchev
2014/03/27 21:51:34
Ok, so the reason we were doing this was that RVH
|
SetPendingShutdown(pending_delete_on_swap_out); |
+ } |
} else if (rvh_state_ == STATE_WAITING_FOR_COMMIT) { |
SetState(STATE_SWAPPED_OUT); |
} else if (rvh_state_ == STATE_DEFAULT) { |
@@ -1709,6 +1714,44 @@ void RenderViewHostImpl::ClearFocusedElement() { |
Send(new ViewMsg_ClearFocusedElement(GetRoutingID())); |
} |
+void RenderViewHostImpl::CopyFromBackingStoreCallback( |
+ const base::Callback<void(bool, const SkBitmap&)>& callback, |
+ bool success, |
+ const SkBitmap& bitmap) { |
+ --copy_requests_; |
+ callback.Run(success, bitmap); |
+ if (copy_requests_ == 0) { |
+ if (!IsRVHStateActive(rvh_state_)) { |
nasko
2014/03/26 22:48:27
Since we are only trying to delay the shutdown, th
mfomitchev
2014/03/27 21:51:34
This looks fine to me, maybe I am missing somethin
|
+ Send(new ViewMsg_WasSwappedOut(GetRoutingID())); |
+ instance_->decrement_active_view_count(); |
nasko
2014/03/26 22:48:27
A comment explaining what we are doing here is def
mfomitchev
2014/03/27 21:51:34
Think it should be more clear now with pending_shu
|
+ } |
+ |
+ if (rvh_state_ == STATE_PENDING_SHUTDOWN) { |
+ DCHECK(!pending_shutdown_on_swap_out_.is_null()); |
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
mfomitchev
2014/03/26 18:59:30
I am wondering if we can have a situation where th
clamy
2014/03/27 15:59:36
What pending_shutdown_on_swap_out_ does is remove
mfomitchev
2014/03/27 21:51:34
Added pending_shutdown_on_copy_requests_done_ to a
|
+ pending_shutdown_on_swap_out_); |
nasko
2014/03/26 22:48:27
I don't see why we need to delay the shutdown here
mfomitchev
2014/03/27 21:51:34
Done. Sadrul mentioned that he saw something on th
|
+ } |
+ } |
+} |
+ |
+void RenderViewHostImpl::CopyFromBackingStore( |
+ const gfx::Rect& src_rect, |
+ const gfx::Size& accelerated_dst_size, |
+ const base::Callback<void(bool, const SkBitmap&)>& callback, |
+ const SkBitmap::Config& bitmap_config) { |
+ DCHECK(IsRVHStateActive(rvh_state_)); |
+ if (!IsRVHStateActive(rvh_state_)) { |
+ callback.Run(false, SkBitmap()); |
+ return; |
+ } |
+ ++copy_requests_; |
+ RenderWidgetHostImpl::CopyFromBackingStore(src_rect, accelerated_dst_size, |
+ base::Bind(&RenderViewHostImpl::CopyFromBackingStoreCallback, |
+ weak_factory_.GetWeakPtr(), |
+ callback), |
+ bitmap_config); |
+} |
+ |
void RenderViewHostImpl::Zoom(PageZoom zoom) { |
Send(new ViewMsg_Zoom(GetRoutingID(), zoom)); |
} |
@@ -1902,7 +1945,8 @@ void RenderViewHostImpl::SetState(RenderViewHostImplState rvh_state) { |
// swapped out status of this RenderView gets flipped to/from live. |
if (!IsRVHStateActive(rvh_state_) && IsRVHStateActive(rvh_state)) |
instance_->increment_active_view_count(); |
- else if (IsRVHStateActive(rvh_state_) && !IsRVHStateActive(rvh_state)) |
+ else if (IsRVHStateActive(rvh_state_) && !IsRVHStateActive(rvh_state) && |
+ copy_requests_ == 0) |
instance_->decrement_active_view_count(); |
// Whenever we change the RVH state to and from live or swapped out state, we |