Index: content/browser/web_contents/web_contents_impl.cc |
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc |
index 5c5289b355df8115e71cd8525d1d033727f47589..933004a224d587ce1880beb34af675a7192d9dc1 100644 |
--- a/content/browser/web_contents/web_contents_impl.cc |
+++ b/content/browser/web_contents/web_contents_impl.cc |
@@ -309,7 +309,7 @@ WebContentsImpl::WebContentsImpl( |
upload_size_(0), |
upload_position_(0), |
displayed_insecure_content_(false), |
- capturing_contents_(false), |
+ capturer_count_(0), |
is_being_destroyed_(false), |
notify_disconnection_(false), |
dialog_manager_(NULL), |
@@ -1008,8 +1008,17 @@ bool WebContentsImpl::DisplayedInsecureContent() const { |
return displayed_insecure_content_; |
} |
-void WebContentsImpl::SetCapturingContents(bool cap) { |
- capturing_contents_ = cap; |
+void WebContentsImpl::IncrementCapturerCount() { |
+ ++capturer_count_; |
+ DVLOG(1) << "There are now " << capturer_count_ |
+ << " capturing(s) of WebContentsImpl@" << this; |
+} |
+ |
+void WebContentsImpl::DecrementCapturerCount() { |
+ --capturer_count_; |
+ DVLOG(1) << "There are now " << capturer_count_ |
+ << " capturing(s) of WebContentsImpl@" << this; |
+ DCHECK_LE(0, capturer_count_); |
} |
bool WebContentsImpl::IsCrashed() const { |
@@ -1076,9 +1085,11 @@ void WebContentsImpl::WasShown() { |
} |
void WebContentsImpl::WasHidden() { |
- if (!capturing_contents_) { |
+ // If there are entities capturing screenshots or video (e.g., mirroring), |
+ // don't activate the "disable rendering" optimization. |
+ if (capturer_count_ == 0) { |
// |GetRenderViewHost()| can be NULL if the user middle clicks a link to |
- // open a tab in then background, then closes the tab before selecting it. |
+ // open a tab in the background, then closes the tab before selecting it. |
// This is because closing the tab calls WebContentsImpl::Destroy(), which |
// removes the |GetRenderViewHost()|; then when we actually destroy the |
// window, OnWindowPosChanged() notices and calls WasHidden() (which |