Commit db0458c2 authored by tommycli's avatar tommycli Committed by Commit bot

Plugin Power Saver: Record PPS UMAs only for users with PPS enabled.

Previously, we collected PPS UMAs across all users. We created a throttler and used it in a 'simulated' mode.

Now that real PPS users exist, collect UMAs only on actual PPS users. This is accomplished by only creating a throttler when PPS is enabled.

BUG=470731

Review URL: https://codereview.chromium.org/1024493004

Cr-Commit-Position: refs/heads/master@{#322462}
parent 065f7af5
......@@ -890,9 +890,9 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
break;
}
scoped_ptr<content::PluginInstanceThrottler> throttler =
PluginInstanceThrottler::Create(power_saver_enabled);
scoped_ptr<content::PluginInstanceThrottler> throttler;
if (power_saver_enabled) {
throttler = PluginInstanceThrottler::Create();
// PluginPreroller manages its own lifetime.
new PluginPreroller(
render_frame, frame, params, info, identifier, group_name,
......
......@@ -101,13 +101,13 @@ void LoadablePluginPlaceholder::MarkPluginEssential(
return;
plugin_marked_essential_ = true;
if (premade_throttler_) {
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();
}
......@@ -299,8 +299,8 @@ void LoadablePluginPlaceholder::LoadPlugin() {
#if defined(ENABLE_PLUGINS)
// 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_);
if (!plugin_marked_essential_ && power_saver_enabled_)
throttler = PluginInstanceThrottler::Create();
#endif
WebPlugin* plugin = render_frame()->CreatePlugin(
GetFrame(), plugin_info_, GetPluginParams(), throttler.Pass());
......
......@@ -64,7 +64,7 @@ class CONTENT_EXPORT PluginInstanceThrottler {
virtual void OnThrottlerDestroyed() {}
};
static scoped_ptr<PluginInstanceThrottler> Create(bool power_saver_enabled);
static scoped_ptr<PluginInstanceThrottler> Create();
static void RecordUnthrottleMethodMetric(PowerSaverUnthrottleMethod method);
......
......@@ -37,9 +37,8 @@ const int kAudioThrottledFrameTimeoutMilliseconds = 500;
const int PluginInstanceThrottlerImpl::kMaximumFramesToExamine = 150;
// static
scoped_ptr<PluginInstanceThrottler> PluginInstanceThrottler::Create(
bool power_saver_enabled) {
return make_scoped_ptr(new PluginInstanceThrottlerImpl(power_saver_enabled));
scoped_ptr<PluginInstanceThrottler> PluginInstanceThrottler::Create() {
return make_scoped_ptr(new PluginInstanceThrottlerImpl);
}
// static
......@@ -50,10 +49,8 @@ void PluginInstanceThrottler::RecordUnthrottleMethodMetric(
PluginInstanceThrottler::UNTHROTTLE_METHOD_NUM_ITEMS);
}
PluginInstanceThrottlerImpl::PluginInstanceThrottlerImpl(
bool power_saver_enabled)
: state_(power_saver_enabled ? THROTTLER_STATE_AWAITING_KEYFRAME
: THROTTLER_STATE_POWER_SAVER_DISABLED),
PluginInstanceThrottlerImpl::PluginInstanceThrottlerImpl()
: state_(THROTTLER_STATE_AWAITING_KEYFRAME),
is_hidden_for_placeholder_(false),
web_plugin_(nullptr),
consecutive_interesting_frames_(0),
......
......@@ -26,7 +26,7 @@ class RenderFrameImpl;
class CONTENT_EXPORT PluginInstanceThrottlerImpl
: public PluginInstanceThrottler {
public:
PluginInstanceThrottlerImpl(bool power_saver_enabled);
PluginInstanceThrottlerImpl();
~PluginInstanceThrottlerImpl() override;
......@@ -47,8 +47,7 @@ class CONTENT_EXPORT PluginInstanceThrottlerImpl
}
bool power_saver_enabled() const {
return state_ == THROTTLER_STATE_AWAITING_KEYFRAME ||
state_ == THROTTLER_STATE_PLUGIN_THROTTLED;
return state_ != THROTTLER_STATE_MARKED_ESSENTIAL;
}
// Throttler needs to be initialized with the real plugin's view bounds.
......@@ -68,8 +67,6 @@ class CONTENT_EXPORT PluginInstanceThrottlerImpl
friend class PluginInstanceThrottlerImplTest;
enum ThrottlerState {
// Power saver is disabled, but the plugin instance is still peripheral.
THROTTLER_STATE_POWER_SAVER_DISABLED,
// Plugin has been found to be peripheral, Plugin Power Saver is enabled,
// and throttler is awaiting a representative keyframe.
THROTTLER_STATE_AWAITING_KEYFRAME,
......
......@@ -39,8 +39,7 @@ class PluginInstanceThrottlerImplTest
blink::WebRect rect;
rect.width = 100;
rect.height = 100;
throttler_.reset(
new PluginInstanceThrottlerImpl(true /* power_saver_enabled */));
throttler_.reset(new PluginInstanceThrottlerImpl);
throttler_->Initialize(nullptr, GURL("http://example.com"),
"Shockwave Flash", rect);
throttler_->AddObserver(this);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment