| Index: content/public/renderer/plugin_instance_throttler.h
|
| diff --git a/content/renderer/pepper/pepper_plugin_instance_throttler.h b/content/public/renderer/plugin_instance_throttler.h
|
| similarity index 39%
|
| copy from content/renderer/pepper/pepper_plugin_instance_throttler.h
|
| copy to content/public/renderer/plugin_instance_throttler.h
|
| index af5794e60e1da4ffae54faefd674e7ef887d03a4..86963bb655cc610776e114b06a309500d6176e65 100644
|
| --- a/content/renderer/pepper/pepper_plugin_instance_throttler.h
|
| +++ b/content/public/renderer/plugin_instance_throttler.h
|
| @@ -1,27 +1,20 @@
|
| -// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_THROTTLER_H_
|
| -#define CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_THROTTLER_H_
|
| +#ifndef CONTENT_PUBLIC_RENDERER_PLUGIN_INSTANCE_THROTTLER_H_
|
| +#define CONTENT_PUBLIC_RENDERER_PLUGIN_INSTANCE_THROTTLER_H_
|
|
|
| -#include "base/callback.h"
|
| #include "base/macros.h"
|
| -#include "base/memory/weak_ptr.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| #include "content/common/content_export.h"
|
| -#include "content/public/renderer/render_frame.h"
|
| -#include "ppapi/shared_impl/ppb_view_shared.h"
|
| -#include "third_party/WebKit/public/platform/WebRect.h"
|
| -
|
| -namespace blink {
|
| -class WebInputEvent;
|
| -}
|
|
|
| class GURL;
|
| -class SkBitmap;
|
|
|
| namespace content {
|
|
|
| +class RenderFrame;
|
| +
|
| // Manages the Plugin Power Saver feature for a single Pepper plugin instance.
|
| //
|
| // A plugin must meet certain criteria in order to be throttled (e.g. it must
|
| @@ -41,8 +34,17 @@ namespace content {
|
| // interesting if it meets some heuristic. After we have seen a certain number
|
| // of interesting frames, we throttle the plugin and use that frame as the
|
| // representative keyframe.
|
| -class CONTENT_EXPORT PepperPluginInstanceThrottler {
|
| +class CONTENT_EXPORT PluginInstanceThrottler {
|
| public:
|
| + enum PluginPowerSaverMode {
|
| + // Plugin content is main content, and therefore never throttled.
|
| + POWER_SAVER_MODE_ESSENTIAL = 0,
|
| + // Plugin content is peripheral, but throttling is disabled.
|
| + POWER_SAVER_MODE_PERIPHERAL_UNTHROTTLED = 1,
|
| + // Plugin content is peripheral, and throttling is enabled.
|
| + POWER_SAVER_MODE_PERIPHERAL_THROTTLED = 2
|
| + };
|
| +
|
| // How the throttled power saver is unthrottled, if ever.
|
| // These numeric values are used in UMA logs; do not change them.
|
| enum PowerSaverUnthrottleMethod {
|
| @@ -53,74 +55,32 @@ class CONTENT_EXPORT PepperPluginInstanceThrottler {
|
| UNTHROTTLE_METHOD_NUM_ITEMS
|
| };
|
|
|
| - PepperPluginInstanceThrottler(
|
| + class Observer {
|
| + public:
|
| + virtual void OnThrottleStateChange() = 0;
|
| + };
|
| +
|
| + static scoped_ptr<PluginInstanceThrottler> Create(
|
| RenderFrame* frame,
|
| - const blink::WebRect& bounds,
|
| - bool is_flash_plugin,
|
| const GURL& plugin_url,
|
| - RenderFrame::PluginPowerSaverMode power_saver_mode,
|
| - const base::Closure& throttle_change_callback);
|
| -
|
| - virtual ~PepperPluginInstanceThrottler();
|
| -
|
| - bool needs_representative_keyframe() const {
|
| - return needs_representative_keyframe_;
|
| - }
|
| + PluginPowerSaverMode power_saver_mode);
|
|
|
| - bool power_saver_enabled() const {
|
| - return power_saver_enabled_;
|
| - }
|
| + virtual ~PluginInstanceThrottler() {}
|
|
|
| - // Called when the plugin flushes it's graphics context. Supplies the
|
| - // throttler with a candidate to use as the representative keyframe.
|
| - void OnImageFlush(const SkBitmap* bitmap);
|
| + virtual void AddObserver(Observer* observer) = 0;
|
| + virtual void RemoveObserver(Observer* observer) = 0;
|
|
|
| - bool is_throttled() const { return plugin_throttled_; }
|
| -
|
| - // Returns true if |event| was handled and shouldn't be further processed.
|
| - bool ConsumeInputEvent(const blink::WebInputEvent& event);
|
| + virtual bool IsThrottled() const = 0;
|
|
|
| // Disables Power Saver and unthrottles the plugin if already throttled.
|
| - void DisablePowerSaver(PowerSaverUnthrottleMethod method);
|
| -
|
| - private:
|
| - friend class PepperPluginInstanceThrottlerTest;
|
| + virtual void DisablePowerSaver(PowerSaverUnthrottleMethod method) = 0;
|
|
|
| - void SetPluginThrottled(bool throttled);
|
| + protected:
|
| + PluginInstanceThrottler() {}
|
|
|
| - // Plugin's bounds in view space.
|
| - blink::WebRect bounds_;
|
| -
|
| - // Called when the throttle state changes.
|
| - base::Closure throttle_change_callback_;
|
| -
|
| - bool is_flash_plugin_;
|
| -
|
| - // True if throttler is still waiting to find a representative keyframe.
|
| - bool needs_representative_keyframe_;
|
| -
|
| - // Number of consecutive interesting frames we've encountered.
|
| - int consecutive_interesting_frames_;
|
| -
|
| - // 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_;
|
| -
|
| - base::WeakPtrFactory<PepperPluginInstanceThrottler> weak_factory_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(PepperPluginInstanceThrottler);
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(PluginInstanceThrottler);
|
| };
|
| }
|
|
|
| -#endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_INSTANCE_THROTTLER_H_
|
| +#endif // CONTENT_PUBLIC_RENDERER_PLUGIN_INSTANCE_THROTTLER_H_
|
|
|