Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Unified Diff: content/browser/renderer_host/render_view_host_impl.cc

Issue 178843004: [wip] Add some more state to RenderViewHost's lifetime. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/render_view_host_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ad30ee73edca301b794d6b96c75f2a5cd8bfe95c..9bef35c6f8d17de9143de5ca47d01a01d7346301 100644
--- a/content/browser/renderer_host/render_view_host_impl.cc
+++ b/content/browser/renderer_host/render_view_host_impl.cc
@@ -214,6 +214,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
@@ -736,7 +737,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();
@@ -745,7 +747,8 @@ 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)
+ Send(new ViewMsg_WasSwappedOut(GetRoutingID()));
if (rvh_state_ == STATE_WAITING_FOR_UNLOAD_ACK) {
if (instance_->active_view_count())
SetState(STATE_PENDING_SWAP_OUT);
@@ -1859,6 +1862,43 @@ void RenderViewHostImpl::GetAudioOutputControllers(
audio_host->GetOutputControllers(GetRoutingID(), callback);
}
+void RenderViewHostImpl::CopyFromBackingStoreCallback(
+ const base::Callback<void(bool, const SkBitmap&)>& callback,
+ bool success,
+ const SkBitmap& bitmap) {
+ --copy_requests_;
+ LOG(ERROR) << "Done with a request: " << copy_requests_;
+ callback.Run(success, bitmap);
+ if (copy_requests_ == 0) {
+ if (!IsRVHStateActive(rvh_state_)) {
+ Send(new ViewMsg_WasSwappedOut(GetRoutingID()));
+ instance_->decrement_active_view_count();
+ }
+
+ if (rvh_state_ == STATE_PENDING_SHUTDOWN) {
+ DCHECK(!pending_shutdown_on_swap_out_.is_null());
+ pending_shutdown_on_swap_out_.Run();
mfomitchev 2014/03/24 18:49:10 Can't we have a situation where this gets executed
+ }
+ }
+}
+
+void RenderViewHostImpl::CopyFromBackingStore(
+ const gfx::Rect& src_rect,
+ const gfx::Size& accelerated_dst_size,
+ const base::Callback<void(bool, const SkBitmap&)>& callback) {
+ DCHECK(IsRVHStateActive(rvh_state_));
+ if (!IsRVHStateActive(rvh_state_)) {
+ callback.Run(false, SkBitmap());
+ return;
+ }
+ ++copy_requests_;
+ LOG(ERROR) << "Starting a request: " << copy_requests_;
+ RenderWidgetHostImpl::CopyFromBackingStore(src_rect, accelerated_dst_size,
+ base::Bind(&RenderViewHostImpl::CopyFromBackingStoreCallback,
+ weak_factory_.GetWeakPtr(),
+ callback));
+}
+
void RenderViewHostImpl::ClearFocusedNode() {
Send(new ViewMsg_ClearFocusedNode(GetRoutingID()));
}
@@ -2049,7 +2089,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)
clamy 2014/02/26 16:50:56 If the site instance is not decremented when the n
instance_->decrement_active_view_count();
// Whenever we change the RVH state to and from live or swapped out state, we
« no previous file with comments | « content/browser/renderer_host/render_view_host_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698