OLD | NEW |
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 "content/renderer/pepper/pepper_webplugin_impl.h" |
14 #include "ppapi/shared_impl/ppb_view_shared.h" | 15 #include "ppapi/shared_impl/ppb_view_shared.h" |
15 #include "third_party/skia/include/core/SkBitmap.h" | 16 #include "third_party/skia/include/core/SkBitmap.h" |
16 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
17 | 18 |
18 namespace blink { | 19 namespace blink { |
19 class WebInputEvent; | 20 class WebInputEvent; |
20 struct WebRect; | 21 struct WebRect; |
21 } | 22 } |
22 | 23 |
23 namespace content { | 24 namespace content { |
24 | 25 |
25 class PepperWebPluginImpl; | 26 class PepperWebPluginImpl; |
26 class RenderFrameImpl; | 27 class RenderFrameImpl; |
27 | 28 |
28 class CONTENT_EXPORT PluginInstanceThrottlerImpl | 29 class CONTENT_EXPORT PluginInstanceThrottlerImpl |
29 : public PluginInstanceThrottler { | 30 : public PluginInstanceThrottler { |
30 public: | 31 public: |
31 PluginInstanceThrottlerImpl(); | 32 PluginInstanceThrottlerImpl(); |
32 | 33 |
33 ~PluginInstanceThrottlerImpl() override; | 34 ~PluginInstanceThrottlerImpl() override; |
34 | 35 |
35 // PluginInstanceThrottler implementation: | 36 // PluginInstanceThrottler implementation: |
36 void AddObserver(Observer* observer) override; | 37 void AddObserver(Observer* observer) override; |
37 void RemoveObserver(Observer* observer) override; | 38 void RemoveObserver(Observer* observer) override; |
38 bool IsThrottled() const override; | 39 bool IsThrottled() const override; |
39 bool IsHiddenForPlaceholder() const override; | 40 bool IsHiddenForPlaceholder() const override; |
40 void MarkPluginEssential(PowerSaverUnthrottleMethod method) override; | 41 void MarkPluginEssential(PowerSaverUnthrottleMethod method) override; |
41 void SetHiddenForPlaceholder(bool hidden) override; | 42 void SetHiddenForPlaceholder(bool hidden) override; |
42 blink::WebPlugin* GetWebPlugin() const override; | 43 PepperWebPluginImpl* GetWebPlugin() const override; |
43 const gfx::Size& GetSize() const override; | 44 const gfx::Size& GetSize() const override; |
44 void NotifyAudioThrottled() override; | 45 void NotifyAudioThrottled() override; |
45 | 46 |
46 void SetWebPlugin(PepperWebPluginImpl* web_plugin); | 47 void SetWebPlugin(PepperWebPluginImpl* web_plugin); |
47 | 48 |
48 bool needs_representative_keyframe() const { | 49 bool needs_representative_keyframe() const { |
49 return state_ == THROTTLER_STATE_AWAITING_KEYFRAME; | 50 return state_ == THROTTLER_STATE_AWAITING_KEYFRAME; |
50 } | 51 } |
51 | 52 |
52 bool power_saver_enabled() const { | 53 bool power_saver_enabled() const { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 92 |
92 PepperWebPluginImpl* web_plugin_; | 93 PepperWebPluginImpl* web_plugin_; |
93 | 94 |
94 // Holds a reference to the last received frame. This doesn't actually copy | 95 // Holds a reference to the last received frame. This doesn't actually copy |
95 // the pixel data, but rather increments the reference count to the pixels. | 96 // the pixel data, but rather increments the reference count to the pixels. |
96 SkBitmap last_received_frame_; | 97 SkBitmap last_received_frame_; |
97 | 98 |
98 // Number of frames we've examined to find a keyframe. | 99 // Number of frames we've examined to find a keyframe. |
99 int frames_examined_; | 100 int frames_examined_; |
100 | 101 |
101 // Plugin module name as of initialization. | |
102 std::string plugin_module_name_; | |
103 | |
104 // Plugin's unobscured dimensions as of initialization. | 102 // Plugin's unobscured dimensions as of initialization. |
105 gfx::Size unobscured_size_; | 103 gfx::Size unobscured_size_; |
106 | 104 |
107 // Video plugins with throttled audio often stop generating frames. | 105 // Video plugins with throttled audio often stop generating frames. |
108 // This timer is so we don't wait forever for candidate poster frames. | 106 // This timer is so we don't wait forever for candidate poster frames. |
109 bool audio_throttled_; | 107 bool audio_throttled_; |
110 base::DelayTimer<PluginInstanceThrottlerImpl> audio_throttled_frame_timeout_; | 108 base::DelayTimer<PluginInstanceThrottlerImpl> audio_throttled_frame_timeout_; |
111 | 109 |
112 ObserverList<Observer> observer_list_; | 110 ObserverList<Observer> observer_list_; |
113 | 111 |
114 base::WeakPtrFactory<PluginInstanceThrottlerImpl> weak_factory_; | 112 base::WeakPtrFactory<PluginInstanceThrottlerImpl> weak_factory_; |
115 | 113 |
116 DISALLOW_COPY_AND_ASSIGN(PluginInstanceThrottlerImpl); | 114 DISALLOW_COPY_AND_ASSIGN(PluginInstanceThrottlerImpl); |
117 }; | 115 }; |
118 } | 116 } |
119 | 117 |
120 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_ | 118 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_ |
OLD | NEW |