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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 12179007: While screencasting a tab, do not disable rendering updates while hidden. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Execute delayed WasHidden() when capturer_count_ goes to zero. Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/browser/web_contents.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 opener_(opener), 302 opener_(opener),
303 ALLOW_THIS_IN_INITIALIZER_LIST(render_manager_(this, this, this)), 303 ALLOW_THIS_IN_INITIALIZER_LIST(render_manager_(this, this, this)),
304 is_loading_(false), 304 is_loading_(false),
305 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), 305 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING),
306 crashed_error_code_(0), 306 crashed_error_code_(0),
307 waiting_for_response_(false), 307 waiting_for_response_(false),
308 load_state_(net::LOAD_STATE_IDLE, string16()), 308 load_state_(net::LOAD_STATE_IDLE, string16()),
309 upload_size_(0), 309 upload_size_(0),
310 upload_position_(0), 310 upload_position_(0),
311 displayed_insecure_content_(false), 311 displayed_insecure_content_(false),
312 capturing_contents_(false), 312 capturer_count_(0),
313 should_normally_be_visible_(true),
313 is_being_destroyed_(false), 314 is_being_destroyed_(false),
314 notify_disconnection_(false), 315 notify_disconnection_(false),
315 dialog_manager_(NULL), 316 dialog_manager_(NULL),
316 is_showing_before_unload_dialog_(false), 317 is_showing_before_unload_dialog_(false),
317 opener_web_ui_type_(WebUI::kNoWebUI), 318 opener_web_ui_type_(WebUI::kNoWebUI),
318 closed_by_user_gesture_(false), 319 closed_by_user_gesture_(false),
319 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), 320 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)),
320 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), 321 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)),
321 temporary_zoom_settings_(false), 322 temporary_zoom_settings_(false),
322 content_restrictions_(0), 323 content_restrictions_(0),
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 } 1004 }
1004 1005
1005 const std::string& WebContentsImpl::GetEncoding() const { 1006 const std::string& WebContentsImpl::GetEncoding() const {
1006 return encoding_; 1007 return encoding_;
1007 } 1008 }
1008 1009
1009 bool WebContentsImpl::DisplayedInsecureContent() const { 1010 bool WebContentsImpl::DisplayedInsecureContent() const {
1010 return displayed_insecure_content_; 1011 return displayed_insecure_content_;
1011 } 1012 }
1012 1013
1013 void WebContentsImpl::SetCapturingContents(bool cap) { 1014 void WebContentsImpl::IncrementCapturerCount() {
1014 capturing_contents_ = cap; 1015 ++capturer_count_;
1016 DVLOG(1) << "There are now " << capturer_count_
1017 << " capturing(s) of WebContentsImpl@" << this;
1018 }
1019
1020 void WebContentsImpl::DecrementCapturerCount() {
1021 --capturer_count_;
1022 DVLOG(1) << "There are now " << capturer_count_
1023 << " capturing(s) of WebContentsImpl@" << this;
1024 DCHECK_LE(0, capturer_count_);
1025
1026 // While capturer_count_ was greater than zero, the WasHidden() calls to RWHV
1027 // were being prevented. If there are no more capturers, make the call now.
1028 if (capturer_count_ == 0 && !should_normally_be_visible_) {
1029 DVLOG(1) << "Executing delayed WasHidden().";
1030 WasHidden();
1031 }
1015 } 1032 }
1016 1033
1017 bool WebContentsImpl::IsCrashed() const { 1034 bool WebContentsImpl::IsCrashed() const {
1018 return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED || 1035 return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED ||
1019 crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION || 1036 crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION ||
1020 crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED); 1037 crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED);
1021 } 1038 }
1022 1039
1023 void WebContentsImpl::SetIsCrashed(base::TerminationStatus status, 1040 void WebContentsImpl::SetIsCrashed(base::TerminationStatus status,
1024 int error_code) { 1041 int error_code) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasShown()); 1080 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasShown());
1064 1081
1065 // The resize rect might have changed while this was inactive -- send the new 1082 // The resize rect might have changed while this was inactive -- send the new
1066 // one to make sure it's up to date. 1083 // one to make sure it's up to date.
1067 RenderViewHostImpl* rvh = 1084 RenderViewHostImpl* rvh =
1068 static_cast<RenderViewHostImpl*>(GetRenderViewHost()); 1085 static_cast<RenderViewHostImpl*>(GetRenderViewHost());
1069 if (rvh) { 1086 if (rvh) {
1070 rvh->ResizeRectChanged(GetRootWindowResizerRect()); 1087 rvh->ResizeRectChanged(GetRootWindowResizerRect());
1071 } 1088 }
1072 1089
1073 bool is_visible = true; 1090 should_normally_be_visible_ = true;
1074 NotificationService::current()->Notify( 1091 NotificationService::current()->Notify(
1075 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, 1092 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED,
1076 Source<WebContents>(this), 1093 Source<WebContents>(this),
1077 Details<bool>(&is_visible)); 1094 Details<const bool>(&should_normally_be_visible_));
1078 } 1095 }
1079 1096
1080 void WebContentsImpl::WasHidden() { 1097 void WebContentsImpl::WasHidden() {
1081 if (!capturing_contents_) { 1098 // If there are entities capturing screenshots or video (e.g., mirroring),
1099 // don't activate the "disable rendering" optimization.
1100 if (capturer_count_ == 0) {
1082 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to 1101 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to
1083 // open a tab in then background, then closes the tab before selecting it. 1102 // open a tab in the background, then closes the tab before selecting it.
1084 // This is because closing the tab calls WebContentsImpl::Destroy(), which 1103 // This is because closing the tab calls WebContentsImpl::Destroy(), which
1085 // removes the |GetRenderViewHost()|; then when we actually destroy the 1104 // removes the |GetRenderViewHost()|; then when we actually destroy the
1086 // window, OnWindowPosChanged() notices and calls WasHidden() (which 1105 // window, OnWindowPosChanged() notices and calls WasHidden() (which
1087 // calls us). 1106 // calls us).
1088 RenderWidgetHostViewPort* rwhv = 1107 RenderWidgetHostViewPort* rwhv =
1089 RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); 1108 RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView());
1090 if (rwhv) 1109 if (rwhv)
1091 rwhv->WasHidden(); 1110 rwhv->WasHidden();
1092 } 1111 }
1093 1112
1094 bool is_visible = false; 1113 should_normally_be_visible_ = false;
1095 NotificationService::current()->Notify( 1114 NotificationService::current()->Notify(
1096 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, 1115 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED,
1097 Source<WebContents>(this), 1116 Source<WebContents>(this),
1098 Details<bool>(&is_visible)); 1117 Details<const bool>(&should_normally_be_visible_));
1099 } 1118 }
1100 1119
1101 bool WebContentsImpl::NeedToFireBeforeUnload() { 1120 bool WebContentsImpl::NeedToFireBeforeUnload() {
1102 // TODO(creis): Should we fire even for interstitial pages? 1121 // TODO(creis): Should we fire even for interstitial pages?
1103 return WillNotifyDisconnection() && 1122 return WillNotifyDisconnection() &&
1104 !ShowingInterstitialPage() && 1123 !ShowingInterstitialPage() &&
1105 !static_cast<RenderViewHostImpl*>( 1124 !static_cast<RenderViewHostImpl*>(
1106 GetRenderViewHost())->SuddenTerminationAllowed(); 1125 GetRenderViewHost())->SuddenTerminationAllowed();
1107 } 1126 }
1108 1127
(...skipping 2343 matching lines...) Expand 10 before | Expand all | Expand 10 after
3452 3471
3453 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { 3472 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() {
3454 return browser_plugin_guest_.get(); 3473 return browser_plugin_guest_.get();
3455 } 3474 }
3456 3475
3457 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { 3476 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() {
3458 return browser_plugin_embedder_.get(); 3477 return browser_plugin_embedder_.get();
3459 } 3478 }
3460 3479
3461 } // namespace content 3480 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/browser/web_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698