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

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

Issue 1088763002: Plugin Power Saver: Add comprehensive browser tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@0260-plugins-overhaul-prerender-tests
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 #include "ui/gfx/geometry/size.h"
17 17
18 namespace blink { 18 namespace blink {
19 class WebInputEvent; 19 class WebInputEvent;
20 struct WebRect; 20 struct WebRect;
21 } 21 }
22 22
23 namespace content { 23 namespace content {
24 24
25 class PepperWebPluginImpl;
25 class RenderFrameImpl; 26 class RenderFrameImpl;
26 27
27 class CONTENT_EXPORT PluginInstanceThrottlerImpl 28 class CONTENT_EXPORT PluginInstanceThrottlerImpl
28 : public PluginInstanceThrottler { 29 : public PluginInstanceThrottler {
29 public: 30 public:
30 PluginInstanceThrottlerImpl(); 31 PluginInstanceThrottlerImpl();
31 32
32 ~PluginInstanceThrottlerImpl() override; 33 ~PluginInstanceThrottlerImpl() override;
33 34
34 // PluginInstanceThrottler implementation: 35 // PluginInstanceThrottler implementation:
35 void AddObserver(Observer* observer) override; 36 void AddObserver(Observer* observer) override;
36 void RemoveObserver(Observer* observer) override; 37 void RemoveObserver(Observer* observer) override;
37 bool IsThrottled() const override; 38 bool IsThrottled() const override;
38 bool IsHiddenForPlaceholder() const override; 39 bool IsHiddenForPlaceholder() const override;
39 void MarkPluginEssential(PowerSaverUnthrottleMethod method) override; 40 void MarkPluginEssential(PowerSaverUnthrottleMethod method) override;
40 void SetHiddenForPlaceholder(bool hidden) override; 41 void SetHiddenForPlaceholder(bool hidden) override;
41 blink::WebPlugin* GetWebPlugin() const override; 42 blink::WebPlugin* GetWebPlugin() const override;
42 const gfx::Size& GetSize() const override; 43 const gfx::Size& GetSize() const override;
43 void NotifyAudioThrottled() override; 44 void NotifyAudioThrottled() override;
44 45
45 void SetWebPlugin(blink::WebPlugin* web_plugin); 46 void SetWebPlugin(PepperWebPluginImpl* web_plugin);
46 47
47 bool needs_representative_keyframe() const { 48 bool needs_representative_keyframe() const {
48 return state_ == THROTTLER_STATE_AWAITING_KEYFRAME; 49 return state_ == THROTTLER_STATE_AWAITING_KEYFRAME;
49 } 50 }
50 51
51 bool power_saver_enabled() const { 52 bool power_saver_enabled() const {
52 return state_ != THROTTLER_STATE_MARKED_ESSENTIAL; 53 return state_ != THROTTLER_STATE_MARKED_ESSENTIAL;
53 } 54 }
54 55
55 void Initialize(RenderFrameImpl* frame, 56 void Initialize(RenderFrameImpl* frame,
(...skipping 25 matching lines...) Expand all
81 // simply suspend the plugin where it's at. Chosen arbitrarily. 82 // simply suspend the plugin where it's at. Chosen arbitrarily.
82 static const int kMaximumFramesToExamine; 83 static const int kMaximumFramesToExamine;
83 84
84 void AudioThrottledFrameTimeout(); 85 void AudioThrottledFrameTimeout();
85 void EngageThrottle(); 86 void EngageThrottle();
86 87
87 ThrottlerState state_; 88 ThrottlerState state_;
88 89
89 bool is_hidden_for_placeholder_; 90 bool is_hidden_for_placeholder_;
90 91
91 blink::WebPlugin* web_plugin_; 92 PepperWebPluginImpl* web_plugin_;
92 93
93 // Holds a reference to the last received frame. This doesn't actually copy 94 // Holds a reference to the last received frame. This doesn't actually copy
94 // the pixel data, but rather increments the reference count to the pixels. 95 // the pixel data, but rather increments the reference count to the pixels.
95 SkBitmap last_received_frame_; 96 SkBitmap last_received_frame_;
96 97
97 // Number of consecutive interesting frames we've encountered. 98 // Number of consecutive interesting frames we've encountered.
98 int consecutive_interesting_frames_; 99 int consecutive_interesting_frames_;
99 100
100 // Number of frames we've examined to find a keyframe. 101 // Number of frames we've examined to find a keyframe.
101 int frames_examined_; 102 int frames_examined_;
102 103
104 // Plugin module name as of initialization.
105 std::string plugin_module_name_;
106
103 // Plugin's unobscured dimensions as of initialization. 107 // Plugin's unobscured dimensions as of initialization.
104 gfx::Size unobscured_size_; 108 gfx::Size unobscured_size_;
105 109
106 // Video plugins with throttled audio often stop generating frames. 110 // Video plugins with throttled audio often stop generating frames.
107 // This timer is so we don't wait forever for candidate poster frames. 111 // This timer is so we don't wait forever for candidate poster frames.
108 bool audio_throttled_; 112 bool audio_throttled_;
109 base::DelayTimer<PluginInstanceThrottlerImpl> audio_throttled_frame_timeout_; 113 base::DelayTimer<PluginInstanceThrottlerImpl> audio_throttled_frame_timeout_;
110 114
111 ObserverList<Observer> observer_list_; 115 ObserverList<Observer> observer_list_;
112 116
113 base::WeakPtrFactory<PluginInstanceThrottlerImpl> weak_factory_; 117 base::WeakPtrFactory<PluginInstanceThrottlerImpl> weak_factory_;
114 118
115 DISALLOW_COPY_AND_ASSIGN(PluginInstanceThrottlerImpl); 119 DISALLOW_COPY_AND_ASSIGN(PluginInstanceThrottlerImpl);
116 }; 120 };
117 } 121 }
118 122
119 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_ 123 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698