| 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 #include "content/renderer/pepper/plugin_instance_throttler_impl.h" | 5 #include "content/renderer/pepper/plugin_instance_throttler_impl.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "content/public/common/content_constants.h" | 9 #include "content/public/common/content_constants.h" |
| 10 #include "content/public/renderer/render_thread.h" | 10 #include "content/public/renderer/render_thread.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 void PluginInstanceThrottlerImpl::SetHiddenForPlaceholder(bool hidden) { | 103 void PluginInstanceThrottlerImpl::SetHiddenForPlaceholder(bool hidden) { |
| 104 is_hidden_for_placeholder_ = hidden; | 104 is_hidden_for_placeholder_ = hidden; |
| 105 FOR_EACH_OBSERVER(Observer, observer_list_, OnHiddenForPlaceholder(hidden)); | 105 FOR_EACH_OBSERVER(Observer, observer_list_, OnHiddenForPlaceholder(hidden)); |
| 106 } | 106 } |
| 107 | 107 |
| 108 blink::WebPlugin* PluginInstanceThrottlerImpl::GetWebPlugin() const { | 108 blink::WebPlugin* PluginInstanceThrottlerImpl::GetWebPlugin() const { |
| 109 DCHECK(web_plugin_); | 109 DCHECK(web_plugin_); |
| 110 return web_plugin_; | 110 return web_plugin_; |
| 111 } | 111 } |
| 112 | 112 |
| 113 const gfx::Size& PluginInstanceThrottlerImpl::GetSize() const { |
| 114 return unobscured_size_; |
| 115 } |
| 116 |
| 113 void PluginInstanceThrottlerImpl::NotifyAudioThrottled() { | 117 void PluginInstanceThrottlerImpl::NotifyAudioThrottled() { |
| 114 audio_throttled_ = true; | 118 audio_throttled_ = true; |
| 115 audio_throttled_frame_timeout_.Reset(); | 119 audio_throttled_frame_timeout_.Reset(); |
| 116 } | 120 } |
| 117 | 121 |
| 118 void PluginInstanceThrottlerImpl::SetWebPlugin(blink::WebPlugin* web_plugin) { | 122 void PluginInstanceThrottlerImpl::SetWebPlugin(blink::WebPlugin* web_plugin) { |
| 119 DCHECK(!web_plugin_); | 123 DCHECK(!web_plugin_); |
| 120 web_plugin_ = web_plugin; | 124 web_plugin_ = web_plugin; |
| 121 } | 125 } |
| 122 | 126 |
| 123 void PluginInstanceThrottlerImpl::Initialize( | 127 void PluginInstanceThrottlerImpl::Initialize( |
| 124 RenderFrameImpl* frame, | 128 RenderFrameImpl* frame, |
| 125 const GURL& content_origin, | 129 const GURL& content_origin, |
| 126 const std::string& plugin_module_name, | 130 const std::string& plugin_module_name, |
| 127 const blink::WebRect& bounds) { | 131 const gfx::Size& unobscured_size) { |
| 132 unobscured_size_ = unobscured_size; |
| 133 |
| 128 // |frame| may be nullptr in tests. | 134 // |frame| may be nullptr in tests. |
| 129 if (frame) { | 135 if (frame) { |
| 130 PluginPowerSaverHelper* helper = frame->plugin_power_saver_helper(); | 136 PluginPowerSaverHelper* helper = frame->plugin_power_saver_helper(); |
| 131 bool cross_origin_main_content = false; | 137 bool cross_origin_main_content = false; |
| 132 if (!helper->ShouldThrottleContent(content_origin, plugin_module_name, | 138 if (!helper->ShouldThrottleContent(content_origin, plugin_module_name, |
| 133 bounds.width, bounds.height, | 139 unobscured_size.width(), |
| 140 unobscured_size.height(), |
| 134 &cross_origin_main_content)) { | 141 &cross_origin_main_content)) { |
| 135 state_ = THROTTLER_STATE_MARKED_ESSENTIAL; | 142 state_ = THROTTLER_STATE_MARKED_ESSENTIAL; |
| 136 | 143 |
| 137 if (cross_origin_main_content) | 144 if (cross_origin_main_content) |
| 138 helper->WhitelistContentOrigin(content_origin); | 145 helper->WhitelistContentOrigin(content_origin); |
| 139 | 146 |
| 140 return; | 147 return; |
| 141 } | 148 } |
| 142 | 149 |
| 143 // To collect UMAs, register peripheral content even if power saver mode | 150 // To collect UMAs, register peripheral content even if power saver mode |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 211 |
| 205 // Release our reference to the underlying pixel data. | 212 // Release our reference to the underlying pixel data. |
| 206 last_received_frame_.reset(); | 213 last_received_frame_.reset(); |
| 207 } | 214 } |
| 208 | 215 |
| 209 state_ = THROTTLER_STATE_PLUGIN_THROTTLED; | 216 state_ = THROTTLER_STATE_PLUGIN_THROTTLED; |
| 210 FOR_EACH_OBSERVER(Observer, observer_list_, OnThrottleStateChange()); | 217 FOR_EACH_OBSERVER(Observer, observer_list_, OnThrottleStateChange()); |
| 211 } | 218 } |
| 212 | 219 |
| 213 } // namespace content | 220 } // namespace content |
| OLD | NEW |