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

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

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 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 class GURL; 12 class GURL;
13 class SkBitmap;
13 14
14 namespace content { 15 namespace content {
15 16
16 class RenderFrame; 17 class RenderFrame;
17 18
18 // Plugin instances are "peripheral" if they are heuristically determined to be 19 // Plugin instances are "peripheral" if they are heuristically determined to be
19 // not "essential" to the web page content. See comments on 20 // not "essential" to the web page content. See comments on
20 // RenderFrame::ShouldThrottleContent for details on these heuristics. 21 // RenderFrame::ShouldThrottleContent for details on these heuristics.
21 enum PluginPowerSaverMode { 22 enum PluginPowerSaverMode {
22 // Plugin content is main content, and therefore never throttled. 23 // Plugin content is main content, and therefore never throttled.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 enum PowerSaverUnthrottleMethod { 55 enum PowerSaverUnthrottleMethod {
55 UNTHROTTLE_METHOD_NEVER = 0, 56 UNTHROTTLE_METHOD_NEVER = 0,
56 UNTHROTTLE_METHOD_BY_CLICK = 1, 57 UNTHROTTLE_METHOD_BY_CLICK = 1,
57 UNTHROTTLE_METHOD_BY_WHITELIST = 2, 58 UNTHROTTLE_METHOD_BY_WHITELIST = 2,
58 UNTHROTTLE_METHOD_BY_AUDIO = 3, 59 UNTHROTTLE_METHOD_BY_AUDIO = 3,
59 UNTHROTTLE_METHOD_NUM_ITEMS 60 UNTHROTTLE_METHOD_NUM_ITEMS
60 }; 61 };
61 62
62 class Observer { 63 class Observer {
63 public: 64 public:
64 virtual void OnThrottleStateChange() = 0; 65 // Guaranteed to be called before the throttle is engaged.
66 virtual void OnKeyframeExtracted(const SkBitmap* bitmap) {}
67 virtual void OnThrottleStateChange() {}
68 virtual void OnThrottlerDestroyed() {}
65 }; 69 };
66 70
67 // Returns a nullptr if no throttler needed based on |power_saver_mode|. 71 // Returns a nullptr if no throttler needed based on |power_saver_mode|.
68 static scoped_ptr<PluginInstanceThrottler> Get( 72 static scoped_ptr<PluginInstanceThrottler> Get(
69 RenderFrame* frame, 73 RenderFrame* frame,
70 const GURL& plugin_url, 74 const GURL& plugin_url,
71 PluginPowerSaverMode power_saver_mode); 75 PluginPowerSaverMode power_saver_mode);
72 76
73 static void RecordUnthrottleMethodMetric(PowerSaverUnthrottleMethod method); 77 static void RecordUnthrottleMethodMetric(PowerSaverUnthrottleMethod method);
74 78
75 virtual ~PluginInstanceThrottler() {} 79 virtual ~PluginInstanceThrottler() {}
76 80
77 virtual void AddObserver(Observer* observer) = 0; 81 virtual void AddObserver(Observer* observer) = 0;
78 virtual void RemoveObserver(Observer* observer) = 0; 82 virtual void RemoveObserver(Observer* observer) = 0;
79 83
80 virtual bool IsThrottled() const = 0; 84 virtual bool IsThrottled() const = 0;
81 85
82 // Marks the plugin as essential. Unthrottles the plugin if already throttled. 86 // Marks the plugin as essential. Unthrottles the plugin if already throttled.
83 virtual void MarkPluginEssential(PowerSaverUnthrottleMethod method) = 0; 87 virtual void MarkPluginEssential(PowerSaverUnthrottleMethod method) = 0;
84 88
85 protected: 89 protected:
86 PluginInstanceThrottler() {} 90 PluginInstanceThrottler() {}
87 91
88 private: 92 private:
89 DISALLOW_COPY_AND_ASSIGN(PluginInstanceThrottler); 93 DISALLOW_COPY_AND_ASSIGN(PluginInstanceThrottler);
90 }; 94 };
91 } 95 }
92 96
93 #endif // CONTENT_PUBLIC_RENDERER_PLUGIN_INSTANCE_THROTTLER_H_ 97 #endif // CONTENT_PUBLIC_RENDERER_PLUGIN_INSTANCE_THROTTLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698