Chromium Code Reviews| Index: content/renderer/pepper/pepper_plugin_instance_impl.cc |
| diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc |
| index 7cdda79ded3e579a64a7bb53c1a5044599e42790..7f0f5d0a638a83ea146a6cec947a7b288eddccf9 100644 |
| --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc |
| +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc |
| @@ -495,6 +495,7 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl( |
| layer_is_hardware_(false), |
| plugin_url_(plugin_url), |
| power_saver_enabled_(false), |
| + is_peripheral_content_(false), |
| plugin_throttled_(false), |
| full_frame_(false), |
| sent_initial_did_change_view_(false), |
| @@ -587,22 +588,28 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl( |
| blink::WebRect bounds = container_->element().boundsInViewportSpace(); |
| bool cross_origin = false; |
| - power_saver_enabled_ = |
| - CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kEnablePluginPowerSaver) && |
| + is_peripheral_content_ = |
| IsFlashPlugin(module_.get()) && |
| - power_saver_helper->ShouldThrottleContent( |
| - content_origin, bounds.width, bounds.height, &cross_origin); |
| + power_saver_helper->ShouldThrottleContent(content_origin, bounds.width, |
|
Lei Zhang
2014/11/05 01:23:49
curious, is this part of the change due to git cl
tommycli
2014/11/05 19:01:41
Yes. It was a change by git cl format.
|
| + bounds.height, &cross_origin); |
| - if (power_saver_enabled_) { |
| + power_saver_enabled_ = is_peripheral_content_ && |
| + CommandLine::ForCurrentProcess()->HasSwitch( |
|
Lei Zhang
2014/11/05 01:23:49
nit: base::CommandLine
tommycli
2014/11/05 19:01:41
Done.
|
| + switches::kEnablePluginPowerSaver); |
| + |
| + if (is_peripheral_content_) { |
| + // To collect UMAs, register peripheral content even if we don't throttle. |
| power_saver_helper->RegisterPeripheralPlugin( |
| content_origin, |
| - base::Bind(&PepperPluginInstanceImpl::DisablePowerSaverAndUnthrottle, |
| + base::Bind(&PepperPluginInstanceImpl:: |
| + DisablePowerSaverByRetroactiveWhitelist, |
| weak_factory_.GetWeakPtr())); |
| - throttler_.reset(new PepperPluginInstanceThrottler( |
| - base::Bind(&PepperPluginInstanceImpl::SetPluginThrottled, |
| - weak_factory_.GetWeakPtr(), true /* throttled */))); |
| + if (power_saver_enabled_) { |
| + throttler_.reset(new PepperPluginInstanceThrottler( |
| + base::Bind(&PepperPluginInstanceImpl::SetPluginThrottled, |
| + weak_factory_.GetWeakPtr(), true /* throttled */))); |
| + } |
| } else if (cross_origin) { |
| power_saver_helper->WhitelistContentOrigin(content_origin); |
| } |
| @@ -614,11 +621,6 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl( |
| if (GetContentClient()->renderer() && // NULL in unit tests. |
| GetContentClient()->renderer()->IsExternalPepperPlugin(module->name())) |
| external_document_load_ = true; |
| - |
| - if (IsFlashPlugin(module_.get())) { |
| - RenderThread::Get()->RecordAction( |
|
Lei Zhang
2014/11/05 01:23:49
The sum of the Plugin.PowerSaverPeripheralHeuristi
tommycli
2014/11/05 19:01:41
I think we should keep it if you can think of any
|
| - base::UserMetricsAction("Flash.PluginInstanceCreated")); |
| - } |
| } |
| PepperPluginInstanceImpl::~PepperPluginInstanceImpl() { |
| @@ -1130,14 +1132,17 @@ bool PepperPluginInstanceImpl::HandleInputEvent( |
| WebCursorInfo* cursor_info) { |
| TRACE_EVENT0("ppapi", "PepperPluginInstanceImpl::HandleInputEvent"); |
| - if (event.type == blink::WebInputEvent::MouseUp && power_saver_enabled_) |
| + if (event.type == blink::WebInputEvent::MouseUp && is_peripheral_content_) { |
| + is_peripheral_content_ = false; |
| power_saver_enabled_ = false; |
| - if (plugin_throttled_) { |
| - if (event.type == blink::WebInputEvent::MouseUp) |
| - SetPluginThrottled(false /* throttled */); |
| + RenderThread::Get()->RecordAction( |
| + base::UserMetricsAction("Flash.PluginInstanceUnthrottledByClick")); |
| - return true; |
| + if (plugin_throttled_) { |
| + SetPluginThrottled(false /* throttled */); |
| + return true; |
| + } |
| } |
| if (!render_frame_) |
| @@ -3331,10 +3336,16 @@ void PepperPluginInstanceImpl::SetPluginThrottled(bool throttled) { |
| SendDidChangeView(); |
| } |
| -void PepperPluginInstanceImpl::DisablePowerSaverAndUnthrottle() { |
| - DCHECK(power_saver_enabled_); |
| +void PepperPluginInstanceImpl::DisablePowerSaverByRetroactiveWhitelist() { |
| + if (!is_peripheral_content_) |
| + return; |
| + |
| + is_peripheral_content_ = false; |
| power_saver_enabled_ = false; |
| SetPluginThrottled(false); |
| + |
| + RenderThread::Get()->RecordAction( |
| + base::UserMetricsAction("Flash.PluginInstanceUnthrottledByWhitelist")); |
| } |
| } // namespace content |