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

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: use gfx::Size Created 5 years, 9 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 "content/common/content_export.h" 11 #include "content/common/content_export.h"
12 #include "content/public/renderer/plugin_instance_throttler.h" 12 #include "content/public/renderer/plugin_instance_throttler.h"
13 #include "ppapi/shared_impl/ppb_view_shared.h" 13 #include "ppapi/shared_impl/ppb_view_shared.h"
14 #include "ui/gfx/geometry/size.h"
14 15
15 namespace blink { 16 namespace blink {
16 class WebInputEvent; 17 class WebInputEvent;
17 struct WebRect; 18 struct WebRect;
18 } 19 }
19 20
20 namespace content { 21 namespace content {
21 22
22 class RenderFrameImpl; 23 class RenderFrameImpl;
23 24
24 class CONTENT_EXPORT PluginInstanceThrottlerImpl 25 class CONTENT_EXPORT PluginInstanceThrottlerImpl
25 : public PluginInstanceThrottler { 26 : public PluginInstanceThrottler {
26 public: 27 public:
27 PluginInstanceThrottlerImpl(bool power_saver_enabled); 28 PluginInstanceThrottlerImpl(bool power_saver_enabled);
28 29
29 ~PluginInstanceThrottlerImpl() override; 30 ~PluginInstanceThrottlerImpl() override;
30 31
31 // PluginInstanceThrottler implementation: 32 // PluginInstanceThrottler implementation:
32 void AddObserver(Observer* observer) override; 33 void AddObserver(Observer* observer) override;
33 void RemoveObserver(Observer* observer) override; 34 void RemoveObserver(Observer* observer) override;
34 bool IsThrottled() const override; 35 bool IsThrottled() const override;
35 bool IsHiddenForPlaceholder() const override; 36 bool IsHiddenForPlaceholder() const override;
36 void MarkPluginEssential(PowerSaverUnthrottleMethod method) override; 37 void MarkPluginEssential(PowerSaverUnthrottleMethod method) override;
37 void SetHiddenForPlaceholder(bool hidden) override; 38 void SetHiddenForPlaceholder(bool hidden) override;
38 blink::WebPlugin* GetWebPlugin() const override; 39 blink::WebPlugin* GetWebPlugin() const override;
40 const gfx::Size& GetSize() const override;
39 41
40 void SetWebPlugin(blink::WebPlugin* web_plugin); 42 void SetWebPlugin(blink::WebPlugin* web_plugin);
41 43
42 bool needs_representative_keyframe() const { 44 bool needs_representative_keyframe() const {
43 return state_ == THROTTLER_STATE_AWAITING_KEYFRAME; 45 return state_ == THROTTLER_STATE_AWAITING_KEYFRAME;
44 } 46 }
45 47
46 bool power_saver_enabled() const { 48 bool power_saver_enabled() const {
47 return state_ == THROTTLER_STATE_AWAITING_KEYFRAME || 49 return state_ == THROTTLER_STATE_AWAITING_KEYFRAME ||
48 state_ == THROTTLER_STATE_PLUGIN_THROTTLED; 50 state_ == THROTTLER_STATE_PLUGIN_THROTTLED;
49 } 51 }
50 52
51 // Throttler needs to be initialized with the real plugin's view bounds. 53 // Throttler needs to be initialized with the real plugin's view bounds.
52 void Initialize(RenderFrameImpl* frame, 54 void Initialize(RenderFrameImpl* frame,
53 const GURL& content_origin, 55 const GURL& content_origin,
54 const std::string& plugin_module_name, 56 const std::string& plugin_module_name,
55 const blink::WebRect& bounds); 57 const gfx::Size& size);
56 58
57 // Called when the plugin flushes it's graphics context. Supplies the 59 // Called when the plugin flushes it's graphics context. Supplies the
58 // throttler with a candidate to use as the representative keyframe. 60 // throttler with a candidate to use as the representative keyframe.
59 void OnImageFlush(const SkBitmap* bitmap); 61 void OnImageFlush(const SkBitmap* bitmap);
60 62
61 // Returns true if |event| was handled and shouldn't be further processed. 63 // Returns true if |event| was handled and shouldn't be further processed.
62 bool ConsumeInputEvent(const blink::WebInputEvent& event); 64 bool ConsumeInputEvent(const blink::WebInputEvent& event);
63 65
64 private: 66 private:
65 friend class PluginInstanceThrottlerImplTest; 67 friend class PluginInstanceThrottlerImplTest;
(...skipping 21 matching lines...) Expand all
87 bool is_hidden_for_placeholder_; 89 bool is_hidden_for_placeholder_;
88 90
89 blink::WebPlugin* web_plugin_; 91 blink::WebPlugin* web_plugin_;
90 92
91 // Number of consecutive interesting frames we've encountered. 93 // Number of consecutive interesting frames we've encountered.
92 int consecutive_interesting_frames_; 94 int consecutive_interesting_frames_;
93 95
94 // Number of frames we've examined to find a keyframe. 96 // Number of frames we've examined to find a keyframe.
95 int frames_examined_; 97 int frames_examined_;
96 98
99 // Plugin dimensions as of initialization.
100 gfx::Size initialized_size_;
Lei Zhang 2015/03/18 00:48:12 const?
tommycli 2015/03/19 22:10:13 Can not, since it's assigned in Initialize, right?
101
97 ObserverList<Observer> observer_list_; 102 ObserverList<Observer> observer_list_;
98 103
99 base::WeakPtrFactory<PluginInstanceThrottlerImpl> weak_factory_; 104 base::WeakPtrFactory<PluginInstanceThrottlerImpl> weak_factory_;
100 105
101 DISALLOW_COPY_AND_ASSIGN(PluginInstanceThrottlerImpl); 106 DISALLOW_COPY_AND_ASSIGN(PluginInstanceThrottlerImpl);
102 }; 107 };
103 } 108 }
104 109
105 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_ 110 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698