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

Side by Side Diff: content/renderer/pepper/plugin_instance_throttler_impl.h

Issue 1015023002: Plugin Power Saver: Throttle 'large' plugins that appear small. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_ 5 #ifndef CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_
6 #define CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_ 6 #define CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
11 #include "base/timer/timer.h" 11 #include "base/timer/timer.h"
12 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
13 #include "content/public/renderer/plugin_instance_throttler.h" 13 #include "content/public/renderer/plugin_instance_throttler.h"
14 #include "ppapi/shared_impl/ppb_view_shared.h" 14 #include "ppapi/shared_impl/ppb_view_shared.h"
15 #include "third_party/skia/include/core/SkBitmap.h" 15 #include "third_party/skia/include/core/SkBitmap.h"
16 #include "ui/gfx/geometry/size.h"
16 17
17 namespace blink { 18 namespace blink {
18 class WebInputEvent; 19 class WebInputEvent;
19 struct WebRect; 20 struct WebRect;
20 } 21 }
21 22
22 namespace content { 23 namespace content {
23 24
24 class RenderFrameImpl; 25 class RenderFrameImpl;
25 26
26 class CONTENT_EXPORT PluginInstanceThrottlerImpl 27 class CONTENT_EXPORT PluginInstanceThrottlerImpl
27 : public PluginInstanceThrottler { 28 : public PluginInstanceThrottler {
28 public: 29 public:
29 PluginInstanceThrottlerImpl(); 30 PluginInstanceThrottlerImpl();
30 31
31 ~PluginInstanceThrottlerImpl() override; 32 ~PluginInstanceThrottlerImpl() override;
32 33
33 // PluginInstanceThrottler implementation: 34 // PluginInstanceThrottler implementation:
34 void AddObserver(Observer* observer) override; 35 void AddObserver(Observer* observer) override;
35 void RemoveObserver(Observer* observer) override; 36 void RemoveObserver(Observer* observer) override;
36 bool IsThrottled() const override; 37 bool IsThrottled() const override;
37 bool IsHiddenForPlaceholder() const override; 38 bool IsHiddenForPlaceholder() const override;
38 void MarkPluginEssential(PowerSaverUnthrottleMethod method) override; 39 void MarkPluginEssential(PowerSaverUnthrottleMethod method) override;
39 void SetHiddenForPlaceholder(bool hidden) override; 40 void SetHiddenForPlaceholder(bool hidden) override;
40 blink::WebPlugin* GetWebPlugin() const override; 41 blink::WebPlugin* GetWebPlugin() const override;
42 const gfx::Size& GetSize() const override;
41 void NotifyAudioThrottled() override; 43 void NotifyAudioThrottled() override;
42 44
43 void SetWebPlugin(blink::WebPlugin* web_plugin); 45 void SetWebPlugin(blink::WebPlugin* web_plugin);
44 46
45 bool needs_representative_keyframe() const { 47 bool needs_representative_keyframe() const {
46 return state_ == THROTTLER_STATE_AWAITING_KEYFRAME; 48 return state_ == THROTTLER_STATE_AWAITING_KEYFRAME;
47 } 49 }
48 50
49 bool power_saver_enabled() const { 51 bool power_saver_enabled() const {
50 return state_ != THROTTLER_STATE_MARKED_ESSENTIAL; 52 return state_ != THROTTLER_STATE_MARKED_ESSENTIAL;
51 } 53 }
52 54
53 // Throttler needs to be initialized with the real plugin's view bounds.
54 void Initialize(RenderFrameImpl* frame, 55 void Initialize(RenderFrameImpl* frame,
55 const GURL& content_origin, 56 const GURL& content_origin,
56 const std::string& plugin_module_name, 57 const std::string& plugin_module_name,
57 const blink::WebRect& bounds); 58 const gfx::Size& unobscured_size);
58 59
59 // Called when the plugin flushes it's graphics context. Supplies the 60 // Called when the plugin flushes it's graphics context. Supplies the
60 // throttler with a candidate to use as the representative keyframe. 61 // throttler with a candidate to use as the representative keyframe.
61 void OnImageFlush(const SkBitmap* bitmap); 62 void OnImageFlush(const SkBitmap* bitmap);
62 63
63 // Returns true if |event| was handled and shouldn't be further processed. 64 // Returns true if |event| was handled and shouldn't be further processed.
64 bool ConsumeInputEvent(const blink::WebInputEvent& event); 65 bool ConsumeInputEvent(const blink::WebInputEvent& event);
65 66
66 private: 67 private:
67 friend class PluginInstanceThrottlerImplTest; 68 friend class PluginInstanceThrottlerImplTest;
(...skipping 24 matching lines...) Expand all
92 // Holds a reference to the last received frame. This doesn't actually copy 93 // Holds a reference to the last received frame. This doesn't actually copy
93 // the pixel data, but rather increments the reference count to the pixels. 94 // the pixel data, but rather increments the reference count to the pixels.
94 SkBitmap last_received_frame_; 95 SkBitmap last_received_frame_;
95 96
96 // Number of consecutive interesting frames we've encountered. 97 // Number of consecutive interesting frames we've encountered.
97 int consecutive_interesting_frames_; 98 int consecutive_interesting_frames_;
98 99
99 // Number of frames we've examined to find a keyframe. 100 // Number of frames we've examined to find a keyframe.
100 int frames_examined_; 101 int frames_examined_;
101 102
103 // Plugin's unobscured dimensions as of initialization.
104 gfx::Size unobscured_size_;
105
102 // Video plugins with throttled audio often stop generating frames. 106 // Video plugins with throttled audio often stop generating frames.
103 // This timer is so we don't wait forever for candidate poster frames. 107 // This timer is so we don't wait forever for candidate poster frames.
104 bool audio_throttled_; 108 bool audio_throttled_;
105 base::DelayTimer<PluginInstanceThrottlerImpl> audio_throttled_frame_timeout_; 109 base::DelayTimer<PluginInstanceThrottlerImpl> audio_throttled_frame_timeout_;
106 110
107 ObserverList<Observer> observer_list_; 111 ObserverList<Observer> observer_list_;
108 112
109 base::WeakPtrFactory<PluginInstanceThrottlerImpl> weak_factory_; 113 base::WeakPtrFactory<PluginInstanceThrottlerImpl> weak_factory_;
110 114
111 DISALLOW_COPY_AND_ASSIGN(PluginInstanceThrottlerImpl); 115 DISALLOW_COPY_AND_ASSIGN(PluginInstanceThrottlerImpl);
112 }; 116 };
113 } 117 }
114 118
115 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_ 119 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_webplugin_impl.cc ('k') | content/renderer/pepper/plugin_instance_throttler_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698