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

Unified Diff: content/renderer/pepper/pepper_plugin_instance_impl.cc

Issue 703453004: Plugin Power Saver: Add some UMAs to test plugins in wild. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add back plugininstancecreated uma Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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 31ad5fc8edf55520dcb39ec2f3bf96e03c52f515..21bfc5de733cffe026f00e3e515a63495afca672 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),
@@ -856,22 +857,28 @@ bool PepperPluginInstanceImpl::Initialize(
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,
+ bounds.height, &cross_origin);
- if (power_saver_enabled_) {
+ power_saver_enabled_ = is_peripheral_content_ &&
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ 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,
- weak_factory_.GetWeakPtr()));
-
- throttler_.reset(new PepperPluginInstanceThrottler(
- base::Bind(&PepperPluginInstanceImpl::SetPluginThrottled,
- weak_factory_.GetWeakPtr(), true /* throttled */)));
+ base::Bind(
+ &PepperPluginInstanceImpl::DisablePowerSaverByRetroactiveWhitelist,
+ weak_factory_.GetWeakPtr()));
+
+ 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);
}
@@ -1131,14 +1138,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_)
@@ -3332,10 +3342,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

Powered by Google App Engine
This is Rietveld 408576698