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

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

Issue 866173002: Plugin Power Saver: Add UI Overlay to throttled plugin using placeholder. (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
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 a95f6db47aef47039b6c9696a87917f53b36f5da..05303d5853aeb0624b3701aaf6a441e2c9289ee1 100644
--- a/content/renderer/pepper/plugin_instance_throttler_impl.cc
+++ b/content/renderer/pepper/plugin_instance_throttler_impl.cc
@@ -60,6 +60,7 @@ PluginInstanceThrottlerImpl::PluginInstanceThrottlerImpl(
: state_(power_saver_enabled ? POWER_SAVER_ENABLED_AWAITING_KEYFRAME
: POWER_SAVER_DISABLED),
consecutive_interesting_frames_(0),
+ keyframe_extraction_timed_out_(false),
weak_factory_(this) {
// To collect UMAs, register peripheral content even if power saver disabled.
if (frame) {
@@ -71,13 +72,15 @@ PluginInstanceThrottlerImpl::PluginInstanceThrottlerImpl(
if (power_saver_enabled) {
base::MessageLoop::current()->PostDelayedTask(
- FROM_HERE, base::Bind(&PluginInstanceThrottlerImpl::EngageThrottle,
- weak_factory_.GetWeakPtr()),
+ FROM_HERE,
+ base::Bind(&PluginInstanceThrottlerImpl::TimeoutKeyframeExtraction,
+ weak_factory_.GetWeakPtr()),
base::TimeDelta::FromMilliseconds(kThrottleTimeout));
}
}
PluginInstanceThrottlerImpl::~PluginInstanceThrottlerImpl() {
+ FOR_EACH_OBSERVER(Observer, observer_list_, OnThrottlerDestroyed());
if (state_ != PLUGIN_INSTANCE_MARKED_ESSENTIAL)
RecordUnthrottleMethodMetric(UNTHROTTLE_METHOD_NEVER);
}
@@ -118,8 +121,11 @@ void PluginInstanceThrottlerImpl::OnImageFlush(const SkBitmap* bitmap) {
else
consecutive_interesting_frames_ = 0;
- if (consecutive_interesting_frames_ >= kMinimumConsecutiveInterestingFrames)
+ if (keyframe_extraction_timed_out_ ||
+ consecutive_interesting_frames_ >= kMinimumConsecutiveInterestingFrames) {
+ FOR_EACH_OBSERVER(Observer, observer_list_, OnKeyframeExtracted(bitmap));
groby-ooo-7-16 2015/01/30 02:22:44 Do we expect multiple observers?
tommycli 2015/01/30 17:02:40 In general, yes. For this particular call, there's
EngageThrottle();
+ }
}
bool PluginInstanceThrottlerImpl::ConsumeInputEvent(
@@ -150,4 +156,9 @@ void PluginInstanceThrottlerImpl::EngageThrottle() {
FOR_EACH_OBSERVER(Observer, observer_list_, OnThrottleStateChange());
}
+void PluginInstanceThrottlerImpl::TimeoutKeyframeExtraction() {
+ DCHECK(!keyframe_extraction_timed_out_);
groby-ooo-7-16 2015/01/30 02:22:44 Why do we care about this as a precondition? Will
tommycli 2015/01/30 17:02:40 Done.
+ keyframe_extraction_timed_out_ = true;
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698