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

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

Issue 1124173008: Plugin Power Saver: Unthrottle dynamically sized plugins correctly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add defines Created 5 years, 6 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"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // representative keyframe. 45 // representative keyframe.
46 class CONTENT_EXPORT PluginInstanceThrottler { 46 class CONTENT_EXPORT PluginInstanceThrottler {
47 public: 47 public:
48 // How the throttled power saver is unthrottled, if ever. 48 // How the throttled power saver is unthrottled, if ever.
49 // These numeric values are used in UMA logs; do not change them. 49 // These numeric values are used in UMA logs; do not change them.
50 enum PowerSaverUnthrottleMethod { 50 enum PowerSaverUnthrottleMethod {
51 UNTHROTTLE_METHOD_NEVER = 0, 51 UNTHROTTLE_METHOD_NEVER = 0,
52 UNTHROTTLE_METHOD_BY_CLICK = 1, 52 UNTHROTTLE_METHOD_BY_CLICK = 1,
53 UNTHROTTLE_METHOD_BY_WHITELIST = 2, 53 UNTHROTTLE_METHOD_BY_WHITELIST = 2,
54 UNTHROTTLE_METHOD_BY_AUDIO = 3, 54 UNTHROTTLE_METHOD_BY_AUDIO = 3,
55 UNTHROTTLE_METHOD_BY_SIZE_CHANGE = 4,
55 UNTHROTTLE_METHOD_NUM_ITEMS 56 UNTHROTTLE_METHOD_NUM_ITEMS
56 }; 57 };
57 58
58 class Observer { 59 class Observer {
59 public: 60 public:
60 // Guaranteed to be called before the throttle is engaged. 61 // Guaranteed to be called before the throttle is engaged.
61 virtual void OnKeyframeExtracted(const SkBitmap* bitmap) {} 62 virtual void OnKeyframeExtracted(const SkBitmap* bitmap) {}
62 63
63 virtual void OnThrottleStateChange() {} 64 virtual void OnThrottleStateChange() {}
64 65
65 virtual void OnPeripheralStateChange() {} 66 virtual void OnPeripheralStateChange() {}
66 67
67 // Called when the plugin should be hidden due to a placeholder. 68 // Called when the plugin should be hidden due to a placeholder.
68 virtual void OnHiddenForPlaceholder(bool hidden) {} 69 virtual void OnHiddenForPlaceholder(bool hidden) {}
69 70
70 virtual void OnThrottlerDestroyed() {} 71 virtual void OnThrottlerDestroyed() {}
71 }; 72 };
72 73
73 static scoped_ptr<PluginInstanceThrottler> Create(); 74 static scoped_ptr<PluginInstanceThrottler> Create();
74 75
75 static void RecordUnthrottleMethodMetric(PowerSaverUnthrottleMethod method); 76 static void RecordUnthrottleMethodMetric(PowerSaverUnthrottleMethod method);
76 77
78 // Returns true if content is considered "large", and thus essential.
79 static bool IsLargeContent(int width, int height);
80
77 virtual ~PluginInstanceThrottler() {} 81 virtual ~PluginInstanceThrottler() {}
78 82
79 virtual void AddObserver(Observer* observer) = 0; 83 virtual void AddObserver(Observer* observer) = 0;
80 virtual void RemoveObserver(Observer* observer) = 0; 84 virtual void RemoveObserver(Observer* observer) = 0;
81 85
82 virtual bool IsThrottled() const = 0; 86 virtual bool IsThrottled() const = 0;
83 virtual bool IsHiddenForPlaceholder() const = 0; 87 virtual bool IsHiddenForPlaceholder() const = 0;
84 88
85 // Marks the plugin as essential. Unthrottles the plugin if already throttled. 89 // Marks the plugin as essential. Unthrottles the plugin if already throttled.
86 virtual void MarkPluginEssential(PowerSaverUnthrottleMethod method) = 0; 90 virtual void MarkPluginEssential(PowerSaverUnthrottleMethod method) = 0;
(...skipping 12 matching lines...) Expand all
99 103
100 protected: 104 protected:
101 PluginInstanceThrottler() {} 105 PluginInstanceThrottler() {}
102 106
103 private: 107 private:
104 DISALLOW_COPY_AND_ASSIGN(PluginInstanceThrottler); 108 DISALLOW_COPY_AND_ASSIGN(PluginInstanceThrottler);
105 }; 109 };
106 } 110 }
107 111
108 #endif // CONTENT_PUBLIC_RENDERER_PLUGIN_INSTANCE_THROTTLER_H_ 112 #endif // CONTENT_PUBLIC_RENDERER_PLUGIN_INSTANCE_THROTTLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698