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

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

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 #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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 void PluginInstanceThrottlerImpl::SetHiddenForPlaceholder(bool hidden) { 94 void PluginInstanceThrottlerImpl::SetHiddenForPlaceholder(bool hidden) {
95 is_hidden_for_placeholder_ = hidden; 95 is_hidden_for_placeholder_ = hidden;
96 FOR_EACH_OBSERVER(Observer, observer_list_, OnHiddenForPlaceholder(hidden)); 96 FOR_EACH_OBSERVER(Observer, observer_list_, OnHiddenForPlaceholder(hidden));
97 } 97 }
98 98
99 blink::WebPlugin* PluginInstanceThrottlerImpl::GetWebPlugin() const { 99 blink::WebPlugin* PluginInstanceThrottlerImpl::GetWebPlugin() const {
100 DCHECK(web_plugin_); 100 DCHECK(web_plugin_);
101 return web_plugin_; 101 return web_plugin_;
102 } 102 }
103 103
104 const gfx::Size& PluginInstanceThrottlerImpl::GetSize() const {
105 return initialized_size_;
106 }
107
104 void PluginInstanceThrottlerImpl::SetWebPlugin(blink::WebPlugin* web_plugin) { 108 void PluginInstanceThrottlerImpl::SetWebPlugin(blink::WebPlugin* web_plugin) {
105 DCHECK(!web_plugin_); 109 DCHECK(!web_plugin_);
106 web_plugin_ = web_plugin; 110 web_plugin_ = web_plugin;
107 } 111 }
108 112
109 void PluginInstanceThrottlerImpl::Initialize( 113 void PluginInstanceThrottlerImpl::Initialize(
110 RenderFrameImpl* frame, 114 RenderFrameImpl* frame,
111 const GURL& content_origin, 115 const GURL& content_origin,
112 const std::string& plugin_module_name, 116 const std::string& plugin_module_name,
113 const blink::WebRect& bounds) { 117 const gfx::Size& size) {
118 initialized_size_ = size;
Lei Zhang 2015/03/18 00:48:12 put this in the initializer list?
tommycli 2015/03/19 22:10:12 I was not able to, as the Throttler is constructed
Lei Zhang 2015/03/19 22:29:44 Whoops, I was thinking this was the ctor. Ignore.
119
114 // |frame| may be nullptr in tests. 120 // |frame| may be nullptr in tests.
115 if (frame) { 121 if (frame) {
116 PluginPowerSaverHelper* helper = frame->plugin_power_saver_helper(); 122 PluginPowerSaverHelper* helper = frame->plugin_power_saver_helper();
117 bool cross_origin_main_content = false; 123 bool cross_origin_main_content = false;
118 if (!helper->ShouldThrottleContent(content_origin, plugin_module_name, 124 if (!helper->ShouldThrottleContent(content_origin, plugin_module_name,
119 bounds.width, bounds.height, 125 size.width(), size.height(),
120 &cross_origin_main_content)) { 126 &cross_origin_main_content)) {
121 state_ = THROTTLER_STATE_MARKED_ESSENTIAL; 127 state_ = THROTTLER_STATE_MARKED_ESSENTIAL;
122 128
123 if (cross_origin_main_content) 129 if (cross_origin_main_content)
124 helper->WhitelistContentOrigin(content_origin); 130 helper->WhitelistContentOrigin(content_origin);
125 131
126 return; 132 return;
127 } 133 }
128 134
129 // To collect UMAs, register peripheral content even if power saver mode 135 // To collect UMAs, register peripheral content even if power saver mode
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 183
178 void PluginInstanceThrottlerImpl::EngageThrottle() { 184 void PluginInstanceThrottlerImpl::EngageThrottle() {
179 if (state_ != THROTTLER_STATE_AWAITING_KEYFRAME) 185 if (state_ != THROTTLER_STATE_AWAITING_KEYFRAME)
180 return; 186 return;
181 187
182 state_ = THROTTLER_STATE_PLUGIN_THROTTLED; 188 state_ = THROTTLER_STATE_PLUGIN_THROTTLED;
183 FOR_EACH_OBSERVER(Observer, observer_list_, OnThrottleStateChange()); 189 FOR_EACH_OBSERVER(Observer, observer_list_, OnThrottleStateChange());
184 } 190 }
185 191
186 } // namespace content 192 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698