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 |