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( ...@@ -890,9 +890,9 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
break; break;
} }
scoped_ptr<content::PluginInstanceThrottler> throttler = scoped_ptr<content::PluginInstanceThrottler> throttler;
PluginInstanceThrottler::Create(power_saver_enabled);
if (power_saver_enabled) { if (power_saver_enabled) {
throttler = PluginInstanceThrottler::Create();
// PluginPreroller manages its own lifetime. // PluginPreroller manages its own lifetime.
new PluginPreroller( new PluginPreroller(
render_frame, frame, params, info, identifier, group_name, render_frame, frame, params, info, identifier, group_name,
......
...@@ -101,13 +101,13 @@ void LoadablePluginPlaceholder::MarkPluginEssential( ...@@ -101,13 +101,13 @@ void LoadablePluginPlaceholder::MarkPluginEssential(
return; return;
plugin_marked_essential_ = true; plugin_marked_essential_ = true;
if (premade_throttler_) { if (premade_throttler_)
premade_throttler_->MarkPluginEssential(method); premade_throttler_->MarkPluginEssential(method);
} else
PluginInstanceThrottler::RecordUnthrottleMethodMetric(method);
if (is_blocked_for_power_saver_poster_) { if (is_blocked_for_power_saver_poster_) {
is_blocked_for_power_saver_poster_ = false; is_blocked_for_power_saver_poster_ = false;
PluginInstanceThrottler::RecordUnthrottleMethodMetric(method);
if (!LoadingBlocked()) if (!LoadingBlocked())
LoadPlugin(); LoadPlugin();
} }
...@@ -299,8 +299,8 @@ void LoadablePluginPlaceholder::LoadPlugin() { ...@@ -299,8 +299,8 @@ void LoadablePluginPlaceholder::LoadPlugin() {
#if defined(ENABLE_PLUGINS) #if defined(ENABLE_PLUGINS)
// If the plugin has already been marked essential in its placeholder form, // 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. // we shouldn't create a new throttler and start the process all over again.
if (!plugin_marked_essential_) if (!plugin_marked_essential_ && power_saver_enabled_)
throttler = PluginInstanceThrottler::Create(power_saver_enabled_); throttler = PluginInstanceThrottler::Create();
#endif #endif
WebPlugin* plugin = render_frame()->CreatePlugin( WebPlugin* plugin = render_frame()->CreatePlugin(
GetFrame(), plugin_info_, GetPluginParams(), throttler.Pass()); GetFrame(), plugin_info_, GetPluginParams(), throttler.Pass());
......
...@@ -64,7 +64,7 @@ class CONTENT_EXPORT PluginInstanceThrottler { ...@@ -64,7 +64,7 @@ class CONTENT_EXPORT PluginInstanceThrottler {
virtual void OnThrottlerDestroyed() {} virtual void OnThrottlerDestroyed() {}
}; };
static scoped_ptr<PluginInstanceThrottler> Create(bool power_saver_enabled); static scoped_ptr<PluginInstanceThrottler> Create();
static void RecordUnthrottleMethodMetric(PowerSaverUnthrottleMethod method); static void RecordUnthrottleMethodMetric(PowerSaverUnthrottleMethod method);
......
...@@ -37,9 +37,8 @@ const int kAudioThrottledFrameTimeoutMilliseconds = 500; ...@@ -37,9 +37,8 @@ const int kAudioThrottledFrameTimeoutMilliseconds = 500;
const int PluginInstanceThrottlerImpl::kMaximumFramesToExamine = 150; const int PluginInstanceThrottlerImpl::kMaximumFramesToExamine = 150;
// static // static
scoped_ptr<PluginInstanceThrottler> PluginInstanceThrottler::Create( scoped_ptr<PluginInstanceThrottler> PluginInstanceThrottler::Create() {
bool power_saver_enabled) { return make_scoped_ptr(new PluginInstanceThrottlerImpl);
return make_scoped_ptr(new PluginInstanceThrottlerImpl(power_saver_enabled));
} }
// static // static
...@@ -50,10 +49,8 @@ void PluginInstanceThrottler::RecordUnthrottleMethodMetric( ...@@ -50,10 +49,8 @@ void PluginInstanceThrottler::RecordUnthrottleMethodMetric(
PluginInstanceThrottler::UNTHROTTLE_METHOD_NUM_ITEMS); PluginInstanceThrottler::UNTHROTTLE_METHOD_NUM_ITEMS);
} }
PluginInstanceThrottlerImpl::PluginInstanceThrottlerImpl( PluginInstanceThrottlerImpl::PluginInstanceThrottlerImpl()
bool power_saver_enabled) : state_(THROTTLER_STATE_AWAITING_KEYFRAME),
: state_(power_saver_enabled ? THROTTLER_STATE_AWAITING_KEYFRAME
: THROTTLER_STATE_POWER_SAVER_DISABLED),
is_hidden_for_placeholder_(false), is_hidden_for_placeholder_(false),
web_plugin_(nullptr), web_plugin_(nullptr),
consecutive_interesting_frames_(0), consecutive_interesting_frames_(0),
......
...@@ -26,7 +26,7 @@ class RenderFrameImpl; ...@@ -26,7 +26,7 @@ class RenderFrameImpl;
class CONTENT_EXPORT PluginInstanceThrottlerImpl class CONTENT_EXPORT PluginInstanceThrottlerImpl
: public PluginInstanceThrottler { : public PluginInstanceThrottler {
public: public:
PluginInstanceThrottlerImpl(bool power_saver_enabled); PluginInstanceThrottlerImpl();
~PluginInstanceThrottlerImpl() override; ~PluginInstanceThrottlerImpl() override;
...@@ -47,8 +47,7 @@ class CONTENT_EXPORT PluginInstanceThrottlerImpl ...@@ -47,8 +47,7 @@ class CONTENT_EXPORT PluginInstanceThrottlerImpl
} }
bool power_saver_enabled() const { bool power_saver_enabled() const {
return state_ == THROTTLER_STATE_AWAITING_KEYFRAME || return state_ != THROTTLER_STATE_MARKED_ESSENTIAL;
state_ == THROTTLER_STATE_PLUGIN_THROTTLED;
} }
// Throttler needs to be initialized with the real plugin's view bounds. // Throttler needs to be initialized with the real plugin's view bounds.
...@@ -68,8 +67,6 @@ class CONTENT_EXPORT PluginInstanceThrottlerImpl ...@@ -68,8 +67,6 @@ class CONTENT_EXPORT PluginInstanceThrottlerImpl
friend class PluginInstanceThrottlerImplTest; friend class PluginInstanceThrottlerImplTest;
enum ThrottlerState { 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, // Plugin has been found to be peripheral, Plugin Power Saver is enabled,
// and throttler is awaiting a representative keyframe. // and throttler is awaiting a representative keyframe.
THROTTLER_STATE_AWAITING_KEYFRAME, THROTTLER_STATE_AWAITING_KEYFRAME,
......
...@@ -39,8 +39,7 @@ class PluginInstanceThrottlerImplTest ...@@ -39,8 +39,7 @@ class PluginInstanceThrottlerImplTest
blink::WebRect rect; blink::WebRect rect;
rect.width = 100; rect.width = 100;
rect.height = 100; rect.height = 100;
throttler_.reset( throttler_.reset(new PluginInstanceThrottlerImpl);
new PluginInstanceThrottlerImpl(true /* power_saver_enabled */));
throttler_->Initialize(nullptr, GURL("http://example.com"), throttler_->Initialize(nullptr, GURL("http://example.com"),
"Shockwave Flash", rect); "Shockwave Flash", rect);
throttler_->AddObserver(this); 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