| 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" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 ~PluginInstanceThrottlerImpl() override; | 29 ~PluginInstanceThrottlerImpl() override; |
| 30 | 30 |
| 31 // PluginInstanceThrottler implementation: | 31 // PluginInstanceThrottler implementation: |
| 32 void AddObserver(Observer* observer) override; | 32 void AddObserver(Observer* observer) override; |
| 33 void RemoveObserver(Observer* observer) override; | 33 void RemoveObserver(Observer* observer) override; |
| 34 bool IsThrottled() const override; | 34 bool IsThrottled() const override; |
| 35 bool IsHiddenForPlaceholder() const override; | 35 bool IsHiddenForPlaceholder() const override; |
| 36 void MarkPluginEssential(PowerSaverUnthrottleMethod method) override; | 36 void MarkPluginEssential(PowerSaverUnthrottleMethod method) override; |
| 37 void SetHiddenForPlaceholder(bool hidden) override; | 37 void SetHiddenForPlaceholder(bool hidden) override; |
| 38 blink::WebPlugin* GetWebPlugin() const override; | 38 blink::WebPlugin* GetWebPlugin() const override; |
| 39 int GetWidth() const override; |
| 40 int GetHeight() 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 int width, |
| 58 int height); |
| 56 | 59 |
| 57 // Called when the plugin flushes it's graphics context. Supplies the | 60 // Called when the plugin flushes it's graphics context. Supplies the |
| 58 // throttler with a candidate to use as the representative keyframe. | 61 // throttler with a candidate to use as the representative keyframe. |
| 59 void OnImageFlush(const SkBitmap* bitmap); | 62 void OnImageFlush(const SkBitmap* bitmap); |
| 60 | 63 |
| 61 // 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. |
| 62 bool ConsumeInputEvent(const blink::WebInputEvent& event); | 65 bool ConsumeInputEvent(const blink::WebInputEvent& event); |
| 63 | 66 |
| 64 private: | 67 private: |
| 65 friend class PluginInstanceThrottlerImplTest; | 68 friend class PluginInstanceThrottlerImplTest; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 87 bool is_hidden_for_placeholder_; | 90 bool is_hidden_for_placeholder_; |
| 88 | 91 |
| 89 blink::WebPlugin* web_plugin_; | 92 blink::WebPlugin* web_plugin_; |
| 90 | 93 |
| 91 // Number of consecutive interesting frames we've encountered. | 94 // Number of consecutive interesting frames we've encountered. |
| 92 int consecutive_interesting_frames_; | 95 int consecutive_interesting_frames_; |
| 93 | 96 |
| 94 // Number of frames we've examined to find a keyframe. | 97 // Number of frames we've examined to find a keyframe. |
| 95 int frames_examined_; | 98 int frames_examined_; |
| 96 | 99 |
| 100 // Plugin dimensions as of initialization. |
| 101 int initialized_width_; |
| 102 int initialized_height_; |
| 103 |
| 97 ObserverList<Observer> observer_list_; | 104 ObserverList<Observer> observer_list_; |
| 98 | 105 |
| 99 base::WeakPtrFactory<PluginInstanceThrottlerImpl> weak_factory_; | 106 base::WeakPtrFactory<PluginInstanceThrottlerImpl> weak_factory_; |
| 100 | 107 |
| 101 DISALLOW_COPY_AND_ASSIGN(PluginInstanceThrottlerImpl); | 108 DISALLOW_COPY_AND_ASSIGN(PluginInstanceThrottlerImpl); |
| 102 }; | 109 }; |
| 103 } | 110 } |
| 104 | 111 |
| 105 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_ | 112 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_ |
| OLD | NEW |