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

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, 10 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/renderer/pepper/plugin_instance_throttler_impl.h ('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 a95f6db47aef47039b6c9696a87917f53b36f5da..f1fe7c4a574bc54933278bd1157ab305b35d705f 100644
--- a/content/renderer/pepper/plugin_instance_throttler_impl.cc
+++ b/content/renderer/pepper/plugin_instance_throttler_impl.cc
@@ -59,7 +59,9 @@ PluginInstanceThrottlerImpl::PluginInstanceThrottlerImpl(
bool power_saver_enabled)
: state_(power_saver_enabled ? POWER_SAVER_ENABLED_AWAITING_KEYFRAME
: POWER_SAVER_DISABLED),
+ is_hidden_for_placeholder_(false),
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 +73,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);
}
@@ -94,6 +98,10 @@ bool PluginInstanceThrottlerImpl::IsThrottled() const {
return state_ == POWER_SAVER_ENABLED_PLUGIN_THROTTLED;
}
+bool PluginInstanceThrottlerImpl::IsHiddenForPlaceholder() const {
+ return is_hidden_for_placeholder_;
+}
+
void PluginInstanceThrottlerImpl::MarkPluginEssential(
PowerSaverUnthrottleMethod method) {
if (state_ == PLUGIN_INSTANCE_MARKED_ESSENTIAL)
@@ -107,6 +115,11 @@ void PluginInstanceThrottlerImpl::MarkPluginEssential(
FOR_EACH_OBSERVER(Observer, observer_list_, OnThrottleStateChange());
}
+void PluginInstanceThrottlerImpl::SetHiddenForPlaceholder(bool hidden) {
+ is_hidden_for_placeholder_ = hidden;
+ FOR_EACH_OBSERVER(Observer, observer_list_, OnHiddenForPlaceholder(hidden));
+}
+
void PluginInstanceThrottlerImpl::OnImageFlush(const SkBitmap* bitmap) {
DCHECK(needs_representative_keyframe());
if (!bitmap)
@@ -118,8 +131,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));
EngageThrottle();
+ }
}
bool PluginInstanceThrottlerImpl::ConsumeInputEvent(
@@ -150,4 +166,8 @@ void PluginInstanceThrottlerImpl::EngageThrottle() {
FOR_EACH_OBSERVER(Observer, observer_list_, OnThrottleStateChange());
}
+void PluginInstanceThrottlerImpl::TimeoutKeyframeExtraction() {
+ keyframe_extraction_timed_out_ = true;
+}
+
} // namespace content
« no previous file with comments | « content/renderer/pepper/plugin_instance_throttler_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698