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

Side by Side Diff: content/public/renderer/plugin_instance_throttler.h

Issue 904913003: Plugin Power Saver: Fix implicitly sized and below the fold plugins. (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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_PUBLIC_RENDERER_PLUGIN_INSTANCE_THROTTLER_H_ 5 #ifndef CONTENT_PUBLIC_RENDERER_PLUGIN_INSTANCE_THROTTLER_H_
6 #define CONTENT_PUBLIC_RENDERER_PLUGIN_INSTANCE_THROTTLER_H_ 6 #define CONTENT_PUBLIC_RENDERER_PLUGIN_INSTANCE_THROTTLER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
11 11
12 namespace blink {
13 struct WebPluginParams;
14 }
15
12 class GURL; 16 class GURL;
13 class SkBitmap; 17 class SkBitmap;
14 18
15 namespace content { 19 namespace content {
16 20
17 class RenderFrame;
18
19 // Plugin instances are "peripheral" if they are heuristically determined to be
20 // not "essential" to the web page content. See comments on
21 // RenderFrame::ShouldThrottleContent for details on these heuristics.
22 enum PluginPowerSaverMode {
23 // Plugin content is main content, and therefore never throttled.
24 POWER_SAVER_MODE_ESSENTIAL = 0,
25 // Plugin content is peripheral, but throttling is disabled.
26 POWER_SAVER_MODE_PERIPHERAL_UNTHROTTLED = 1,
27 // Plugin content is peripheral, and throttling is enabled.
28 POWER_SAVER_MODE_PERIPHERAL_THROTTLED = 2
29 };
30
31 // This class manages the metric collection, throttling, and unthrottling of a 21 // This class manages the metric collection, throttling, and unthrottling of a
32 // single peripheral plugin instance. If the Power Saver feature is disabled, 22 // single peripheral plugin instance. If the Power Saver feature is disabled,
33 // the plugin instance will never actually be throttled, but still collects 23 // the plugin instance will never actually be throttled, but still collects
34 // user interaction metrics. 24 // user interaction metrics.
35 // 25 //
36 // The process for throttling a plugin is as follows: 26 // The process for throttling a plugin is as follows:
37 // 1) Attempt to find a representative keyframe to display as a placeholder for 27 // 1) Attempt to find a representative keyframe to display as a placeholder for
38 // the plugin. 28 // the plugin.
39 // 2) a) If a representative keyframe is found, throttle the plugin at that 29 // 2) a) If a representative keyframe is found, throttle the plugin at that
40 // keyframe. 30 // keyframe.
(...skipping 25 matching lines...) Expand all
66 virtual void OnKeyframeExtracted(const SkBitmap* bitmap) {} 56 virtual void OnKeyframeExtracted(const SkBitmap* bitmap) {}
67 57
68 virtual void OnThrottleStateChange() {} 58 virtual void OnThrottleStateChange() {}
69 59
70 // Called when the plugin should be hidden due to a placeholder. 60 // Called when the plugin should be hidden due to a placeholder.
71 virtual void OnHiddenForPlaceholder(bool hidden) {} 61 virtual void OnHiddenForPlaceholder(bool hidden) {}
72 62
73 virtual void OnThrottlerDestroyed() {} 63 virtual void OnThrottlerDestroyed() {}
74 }; 64 };
75 65
76 // Returns a nullptr if no throttler needed based on |power_saver_mode|. 66 static scoped_ptr<PluginInstanceThrottler> Create(bool power_saver_enabled);
77 static scoped_ptr<PluginInstanceThrottler> Get(
78 RenderFrame* frame,
79 const GURL& plugin_url,
80 PluginPowerSaverMode power_saver_mode);
81 67
82 static void RecordUnthrottleMethodMetric(PowerSaverUnthrottleMethod method); 68 static void RecordUnthrottleMethodMetric(PowerSaverUnthrottleMethod method);
83 69
84 virtual ~PluginInstanceThrottler() {} 70 virtual ~PluginInstanceThrottler() {}
85 71
86 virtual void AddObserver(Observer* observer) = 0; 72 virtual void AddObserver(Observer* observer) = 0;
87 virtual void RemoveObserver(Observer* observer) = 0; 73 virtual void RemoveObserver(Observer* observer) = 0;
88 74
89 virtual bool IsThrottled() const = 0; 75 virtual bool IsThrottled() const = 0;
90 virtual bool IsHiddenForPlaceholder() const = 0; 76 virtual bool IsHiddenForPlaceholder() const = 0;
91 77
92 // Marks the plugin as essential. Unthrottles the plugin if already throttled. 78 // Marks the plugin as essential. Unthrottles the plugin if already throttled.
93 virtual void MarkPluginEssential(PowerSaverUnthrottleMethod method) = 0; 79 virtual void MarkPluginEssential(PowerSaverUnthrottleMethod method) = 0;
94 80
95 // Called by the placeholder when the plugin should temporarily be hidden. 81 // Called by the placeholder when the plugin should temporarily be hidden.
96 virtual void SetHiddenForPlaceholder(bool hidden) = 0; 82 virtual void SetHiddenForPlaceholder(bool hidden) = 0;
97 83
98 protected: 84 protected:
99 PluginInstanceThrottler() {} 85 PluginInstanceThrottler() {}
100 86
101 private: 87 private:
102 DISALLOW_COPY_AND_ASSIGN(PluginInstanceThrottler); 88 DISALLOW_COPY_AND_ASSIGN(PluginInstanceThrottler);
103 }; 89 };
104 } 90 }
105 91
106 #endif // CONTENT_PUBLIC_RENDERER_PLUGIN_INSTANCE_THROTTLER_H_ 92 #endif // CONTENT_PUBLIC_RENDERER_PLUGIN_INSTANCE_THROTTLER_H_
OLDNEW
« no previous file with comments | « components/plugins/renderer/loadable_plugin_placeholder.cc ('k') | content/public/renderer/render_frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698