summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authortommycli <tommycli@chromium.org>2015-02-09 13:08:56 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-09 21:10:04 +0000
commitd7798e13906ebb1b531043738446eb378da369b1 (patch)
tree283271f0ad280c0a93effc339a2e2e449f459ea2 /components
parentab7392a1539409dce6691a5f26c872bf93b1edfe (diff)
downloadchromium_src-d7798e13906ebb1b531043738446eb378da369b1.zip
chromium_src-d7798e13906ebb1b531043738446eb378da369b1.tar.gz
chromium_src-d7798e13906ebb1b531043738446eb378da369b1.tar.bz2
Plugin Power Saver: Fix implicitly sized and below the fold plugins.
This patch changes a few behaviors. 1. Make implicitly sized (e.g. width="100%") plugins work with Plugin Power Saver. Previously sizes were read from plugin parameters, which doesn't work for implicitly sized plugins. Now, we look at the actual blink::WebRect view bounds. 2. Timeout keyframe extraction after 150 frames rather than a fixed 5 seconds. The previous behavior was broken for plugins that are loaded off-screen. (The countdown begins even though no frames are being generated until the plugin goes on-screen). 3. When "Detect and run..." is on, always respect the 'poster' parameter. This is a tweak to the existing behavior, which is to use the 'poster' param only for peripheral plugins. This should have no user impact, since no one actually uses the 'poster' param right now. 4. Clean up metric collection in LoadablePluginPlaceholder. Previous behavior was overcounting in some circumstances. 5. Reduces RenderFrame public interface and total SLOC. BUG=443431,456217, 403800 Review URL: https://codereview.chromium.org/904913003 Cr-Commit-Position: refs/heads/master@{#315393}
Diffstat (limited to 'components')
-rw-r--r--components/plugins/renderer/loadable_plugin_placeholder.cc28
-rw-r--r--components/plugins/renderer/loadable_plugin_placeholder.h11
2 files changed, 21 insertions, 18 deletions
diff --git a/components/plugins/renderer/loadable_plugin_placeholder.cc b/components/plugins/renderer/loadable_plugin_placeholder.cc
index 89c8258..5b33949 100644
--- a/components/plugins/renderer/loadable_plugin_placeholder.cc
+++ b/components/plugins/renderer/loadable_plugin_placeholder.cc
@@ -32,7 +32,6 @@ using blink::WebPluginParams;
using blink::WebScriptSource;
using blink::WebURLRequest;
using content::PluginInstanceThrottler;
-using content::PluginPowerSaverMode;
using content::RenderThread;
namespace plugins {
@@ -44,7 +43,7 @@ void LoadablePluginPlaceholder::BlockForPowerSaverPoster() {
render_frame()->RegisterPeripheralPlugin(
GURL(GetPluginParams().url).GetOrigin(),
- base::Bind(&LoadablePluginPlaceholder::DisablePowerSaverForInstance,
+ base::Bind(&LoadablePluginPlaceholder::MarkPluginEssential,
weak_factory_.GetWeakPtr(),
PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_WHITELIST));
}
@@ -77,7 +76,8 @@ LoadablePluginPlaceholder::LoadablePluginPlaceholder(
is_blocked_for_background_tab_(false),
is_blocked_for_prerendering_(false),
is_blocked_for_power_saver_poster_(false),
- power_saver_mode_(PluginPowerSaverMode::POWER_SAVER_MODE_ESSENTIAL),
+ power_saver_enabled_(false),
+ plugin_marked_essential_(false),
premade_plugin_(nullptr),
premade_throttler_(nullptr),
allow_loading_(false),
@@ -92,8 +92,8 @@ LoadablePluginPlaceholder::~LoadablePluginPlaceholder() {
DCHECK(!premade_plugin_);
DCHECK(!premade_throttler_);
- if (!placeholder_was_replaced_ && !is_blocked_for_prerendering_ &&
- power_saver_mode_ != PluginPowerSaverMode::POWER_SAVER_MODE_ESSENTIAL) {
+ if (!plugin_marked_essential_ && !placeholder_was_replaced_ &&
+ !is_blocked_for_prerendering_ && is_blocked_for_power_saver_poster_) {
PluginInstanceThrottler::RecordUnthrottleMethodMetric(
PluginInstanceThrottler::UNTHROTTLE_METHOD_NEVER);
}
@@ -101,20 +101,19 @@ LoadablePluginPlaceholder::~LoadablePluginPlaceholder() {
}
#if defined(ENABLE_PLUGINS)
-void LoadablePluginPlaceholder::DisablePowerSaverForInstance(
+void LoadablePluginPlaceholder::MarkPluginEssential(
PluginInstanceThrottler::PowerSaverUnthrottleMethod method) {
- if (power_saver_mode_ == PluginPowerSaverMode::POWER_SAVER_MODE_ESSENTIAL)
+ if (plugin_marked_essential_)
return;
- power_saver_mode_ = PluginPowerSaverMode::POWER_SAVER_MODE_ESSENTIAL;
+ plugin_marked_essential_ = true;
if (premade_throttler_) {
premade_throttler_->MarkPluginEssential(method);
- } else {
- PluginInstanceThrottler::RecordUnthrottleMethodMetric(method);
}
if (is_blocked_for_power_saver_poster_) {
is_blocked_for_power_saver_poster_ = false;
+ PluginInstanceThrottler::RecordUnthrottleMethodMetric(method);
if (!LoadingBlocked())
LoadPlugin();
}
@@ -307,8 +306,10 @@ void LoadablePluginPlaceholder::LoadPlugin() {
// reduce the chance of future regressions.
scoped_ptr<PluginInstanceThrottler> throttler;
#if defined(ENABLE_PLUGINS)
- throttler = PluginInstanceThrottler::Get(
- render_frame(), GetPluginParams().url, power_saver_mode_);
+ // If the plugin has already been marked essential in its placeholder form,
+ // we shouldn't create a new throttler and start the process all over again.
+ if (!plugin_marked_essential_)
+ throttler = PluginInstanceThrottler::Create(power_saver_enabled_);
#endif
WebPlugin* plugin = render_frame()->CreatePlugin(
GetFrame(), plugin_info_, GetPluginParams(), throttler.Pass());
@@ -322,8 +323,7 @@ void LoadablePluginPlaceholder::LoadCallback() {
#if defined(ENABLE_PLUGINS)
// If the user specifically clicks on the plug-in content's placeholder,
// disable power saver throttling for this instance.
- DisablePowerSaverForInstance(
- PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_CLICK);
+ MarkPluginEssential(PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_CLICK);
#endif
LoadPlugin();
}
diff --git a/components/plugins/renderer/loadable_plugin_placeholder.h b/components/plugins/renderer/loadable_plugin_placeholder.h
index 401ec7d..ee24663 100644
--- a/components/plugins/renderer/loadable_plugin_placeholder.h
+++ b/components/plugins/renderer/loadable_plugin_placeholder.h
@@ -26,8 +26,8 @@ class LoadablePluginPlaceholder
}
#if defined(ENABLE_PLUGINS)
- void set_power_saver_mode(content::PluginPowerSaverMode power_saver_mode) {
- power_saver_mode_ = power_saver_mode;
+ void set_power_saver_enabled(bool power_saver_enabled) {
+ power_saver_enabled_ = power_saver_enabled;
}
// Defer loading of plug-in, and instead show the Power Saver poster image.
@@ -50,7 +50,7 @@ class LoadablePluginPlaceholder
~LoadablePluginPlaceholder() override;
#if defined(ENABLE_PLUGINS)
- void DisablePowerSaverForInstance(
+ void MarkPluginEssential(
content::PluginInstanceThrottler::PowerSaverUnthrottleMethod method);
#endif
@@ -117,7 +117,10 @@ class LoadablePluginPlaceholder
bool is_blocked_for_power_saver_poster_;
// This is independent of deferred plugin load due to a Power Saver poster.
- content::PluginPowerSaverMode power_saver_mode_;
+ bool power_saver_enabled_;
+
+ // True if the plugin has been marked essential.
+ bool plugin_marked_essential_;
// When we load, uses this premade plugin instead of creating a new one.
blink::WebPlugin* premade_plugin_;