| Index: content/renderer/pepper/pepper_plugin_instance_throttler.h
|
| diff --git a/content/renderer/pepper/pepper_plugin_instance_throttler.h b/content/renderer/pepper/pepper_plugin_instance_throttler.h
|
| index 15a5c10af3c60f7495b83ddebffecad1d9f60e1f..961cfae15cd17244c149137547c9bb69d3f83f15 100644
|
| --- a/content/renderer/pepper/pepper_plugin_instance_throttler.h
|
| +++ b/content/renderer/pepper/pepper_plugin_instance_throttler.h
|
| @@ -5,23 +5,71 @@
|
| #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_THROTTLER_H_
|
| #define CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_THROTTLER_H_
|
|
|
| -#include "base/callback_forward.h"
|
| +#include "base/callback.h"
|
| #include "base/macros.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "content/common/content_export.h"
|
| +#include "ppapi/shared_impl/ppb_view_shared.h"
|
| +
|
| +namespace blink {
|
| +class WebInputEvent;
|
| +}
|
|
|
| namespace content {
|
|
|
| -// Throttles Pepper Plugin instances in Power Saver mode. Currently just a
|
| -// stub implementation that engages throttling after a fixed timeout.
|
| -// In the future, will examine plugin frames to find a suitable preview
|
| -// image before engaging throttling.
|
| -class PepperPluginInstanceThrottler {
|
| +class PepperPluginInstanceImpl;
|
| +
|
| +// Manages the Plugin Power Saver feature for a single Pepper plugin instance.
|
| +class CONTENT_EXPORT PepperPluginInstanceThrottler {
|
| public:
|
| - // |throttle_closure| is called to engage throttling.
|
| - explicit PepperPluginInstanceThrottler(const base::Closure& throttle_closure);
|
| + PepperPluginInstanceThrottler(PepperPluginInstanceImpl* instance,
|
| + const base::Closure& throttle_change_callback);
|
|
|
| virtual ~PepperPluginInstanceThrottler();
|
|
|
| + bool is_throttled() const { return plugin_throttled_; }
|
| + const ppapi::ViewData& throttled_view_data() const {
|
| + return empty_view_data_;
|
| + }
|
| +
|
| + // Returns true if |event| was handled and shouldn't be further processed.
|
| + bool ConsumeInputEvent(const blink::WebInputEvent& event);
|
| +
|
| + protected:
|
| + // Used only for testing.
|
| + PepperPluginInstanceThrottler(const base::Closure& throttle_change_callback,
|
| + bool power_saver_enabled,
|
| + bool is_peripheral_content);
|
| +
|
| + void SetPluginThrottled(bool throttled);
|
| + void DisablePowerSaverByRetroactiveWhitelist();
|
| +
|
| private:
|
| + PepperPluginInstanceImpl* instance_;
|
| +
|
| + // Called when the throttle state changes.
|
| + base::Closure throttle_change_callback_;
|
| +
|
| + // Set to true first time plugin is clicked. Used to collect metrics.
|
| + bool has_been_clicked_;
|
| +
|
| + // Indicates whether this plugin may be throttled to reduce power consumption.
|
| + // |power_saver_enabled_| implies |is_peripheral_content_|.
|
| + bool power_saver_enabled_;
|
| +
|
| + // Indicates whether this plugin was found to be peripheral content.
|
| + // This is separately tracked from |power_saver_enabled_| to collect UMAs.
|
| + // Always true if |power_saver_enabled_| is true.
|
| + bool is_peripheral_content_;
|
| +
|
| + // Indicates if the plugin is currently throttled.
|
| + bool plugin_throttled_;
|
| +
|
| + // Fake view data used by the Power Saver feature to throttle plugins.
|
| + const ppapi::ViewData empty_view_data_;
|
| +
|
| + base::WeakPtrFactory<PepperPluginInstanceThrottler> weak_factory_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(PepperPluginInstanceThrottler);
|
| };
|
| }
|
|
|