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

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

Issue 863813002: Plugin Power Saver: Make Unthrottle metric collection more consistent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months 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
« no previous file with comments | « content/public/renderer/plugin_instance_throttler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/pepper/plugin_instance_throttler_impl.cc
diff --git a/content/renderer/pepper/plugin_instance_throttler_impl.cc b/content/renderer/pepper/plugin_instance_throttler_impl.cc
index ea06846f786539c2979415a4d0873229e898008b..a95f6db47aef47039b6c9696a87917f53b36f5da 100644
--- a/content/renderer/pepper/plugin_instance_throttler_impl.cc
+++ b/content/renderer/pepper/plugin_instance_throttler_impl.cc
@@ -17,15 +17,6 @@ namespace content {
namespace {
-const char kPowerSaverUnthrottleHistogram[] = "Plugin.PowerSaver.Unthrottle";
-
-void RecordUnthrottleMethodMetric(
- PluginInstanceThrottlerImpl::PowerSaverUnthrottleMethod method) {
- UMA_HISTOGRAM_ENUMERATION(
- kPowerSaverUnthrottleHistogram, method,
- PluginInstanceThrottler::UNTHROTTLE_METHOD_NUM_ITEMS);
-}
-
// When we give up waiting for a suitable preview frame, and simply suspend
// the plugin where it's at. In milliseconds.
const int kThrottleTimeout = 5000;
@@ -39,6 +30,29 @@ const int kMinimumConsecutiveInterestingFrames = 4;
} // namespace
+// static
+scoped_ptr<PluginInstanceThrottler> PluginInstanceThrottler::Get(
+ RenderFrame* frame,
+ const GURL& plugin_url,
+ PluginPowerSaverMode power_saver_mode) {
+ if (power_saver_mode == PluginPowerSaverMode::POWER_SAVER_MODE_ESSENTIAL)
+ return nullptr;
+
+ bool power_saver_enabled =
+ power_saver_mode ==
+ PluginPowerSaverMode::POWER_SAVER_MODE_PERIPHERAL_THROTTLED;
+ return make_scoped_ptr(
+ new PluginInstanceThrottlerImpl(frame, plugin_url, power_saver_enabled));
+}
+
+// static
+void PluginInstanceThrottler::RecordUnthrottleMethodMetric(
+ PluginInstanceThrottlerImpl::PowerSaverUnthrottleMethod method) {
+ UMA_HISTOGRAM_ENUMERATION(
+ "Plugin.PowerSaver.Unthrottle", method,
+ PluginInstanceThrottler::UNTHROTTLE_METHOD_NUM_ITEMS);
+}
+
PluginInstanceThrottlerImpl::PluginInstanceThrottlerImpl(
RenderFrame* frame,
const GURL& plugin_url,
@@ -64,6 +78,8 @@ PluginInstanceThrottlerImpl::PluginInstanceThrottlerImpl(
}
PluginInstanceThrottlerImpl::~PluginInstanceThrottlerImpl() {
+ if (state_ != PLUGIN_INSTANCE_MARKED_ESSENTIAL)
+ RecordUnthrottleMethodMetric(UNTHROTTLE_METHOD_NEVER);
}
void PluginInstanceThrottlerImpl::AddObserver(Observer* observer) {
« no previous file with comments | « content/public/renderer/plugin_instance_throttler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698