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

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

Issue 764763005: Plugin Power Saver: Always mark 'tiny' plugins as essential. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@0201-plugin-power-saver-use-poster-frame-on-blocked-only
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | content/renderer/pepper/plugin_power_saver_helper_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/pepper_plugin_instance_throttler.h" 5 #include "content/renderer/pepper/pepper_plugin_instance_throttler.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/metrics/sparse_histogram.h" 10 #include "base/metrics/sparse_histogram.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 plugin_throttled_(false), 123 plugin_throttled_(false),
124 weak_factory_(this) { 124 weak_factory_(this) {
125 GURL content_origin = plugin_url.GetOrigin(); 125 GURL content_origin = plugin_url.GetOrigin();
126 126
127 if (is_flash_plugin_ && RenderThread::Get()) { 127 if (is_flash_plugin_ && RenderThread::Get()) {
128 RenderThread::Get()->RecordAction( 128 RenderThread::Get()->RecordAction(
129 base::UserMetricsAction("Flash.PluginInstanceCreated")); 129 base::UserMetricsAction("Flash.PluginInstanceCreated"));
130 RecordFlashSizeMetric(bounds.width, bounds.height); 130 RecordFlashSizeMetric(bounds.width, bounds.height);
131 } 131 }
132 132
133 bool cross_origin = false; 133 bool is_main_attraction = false;
134 is_peripheral_content_ = 134 is_peripheral_content_ =
135 is_flash_plugin_ && 135 is_flash_plugin_ &&
136 power_saver_helper->ShouldThrottleContent(content_origin, bounds.width, 136 power_saver_helper->ShouldThrottleContent(
137 bounds.height, &cross_origin); 137 content_origin, bounds.width, bounds.height, &is_main_attraction);
138 138
139 power_saver_enabled_ = is_peripheral_content_ && 139 power_saver_enabled_ = is_peripheral_content_ &&
140 base::CommandLine::ForCurrentProcess()->HasSwitch( 140 base::CommandLine::ForCurrentProcess()->HasSwitch(
141 switches::kEnablePluginPowerSaver); 141 switches::kEnablePluginPowerSaver);
142 142
143 if (is_peripheral_content_) { 143 if (is_peripheral_content_) {
144 // To collect UMAs, register peripheral content even if we don't throttle. 144 // To collect UMAs, register peripheral content even if we don't throttle.
145 power_saver_helper->RegisterPeripheralPlugin( 145 power_saver_helper->RegisterPeripheralPlugin(
146 content_origin, base::Bind(&PepperPluginInstanceThrottler:: 146 content_origin, base::Bind(&PepperPluginInstanceThrottler::
147 DisablePowerSaverByRetroactiveWhitelist, 147 DisablePowerSaverByRetroactiveWhitelist,
148 weak_factory_.GetWeakPtr())); 148 weak_factory_.GetWeakPtr()));
149 149
150 if (power_saver_enabled_) { 150 if (power_saver_enabled_) {
151 needs_representative_keyframe_ = true; 151 needs_representative_keyframe_ = true;
152 base::MessageLoop::current()->PostDelayedTask( 152 base::MessageLoop::current()->PostDelayedTask(
153 FROM_HERE, 153 FROM_HERE,
154 base::Bind(&PepperPluginInstanceThrottler::SetPluginThrottled, 154 base::Bind(&PepperPluginInstanceThrottler::SetPluginThrottled,
155 weak_factory_.GetWeakPtr(), true /* throttled */), 155 weak_factory_.GetWeakPtr(), true /* throttled */),
156 base::TimeDelta::FromMilliseconds(kThrottleTimeout)); 156 base::TimeDelta::FromMilliseconds(kThrottleTimeout));
157 } 157 }
158 } else if (cross_origin) { 158 } else if (is_main_attraction) {
159 power_saver_helper->WhitelistContentOrigin(content_origin); 159 power_saver_helper->WhitelistContentOrigin(content_origin);
160 } 160 }
161 } 161 }
162 162
163 PepperPluginInstanceThrottler::~PepperPluginInstanceThrottler() { 163 PepperPluginInstanceThrottler::~PepperPluginInstanceThrottler() {
164 } 164 }
165 165
166 void PepperPluginInstanceThrottler::OnImageFlush(const SkBitmap* bitmap) { 166 void PepperPluginInstanceThrottler::OnImageFlush(const SkBitmap* bitmap) {
167 if (!needs_representative_keyframe_ || !bitmap) 167 if (!needs_representative_keyframe_ || !bitmap)
168 return; 168 return;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 return; 217 return;
218 218
219 is_peripheral_content_ = false; 219 is_peripheral_content_ = false;
220 power_saver_enabled_ = false; 220 power_saver_enabled_ = false;
221 SetPluginThrottled(false); 221 SetPluginThrottled(false);
222 222
223 RecordUnthrottleMethodMetric(UNTHROTTLE_METHOD_BY_WHITELIST); 223 RecordUnthrottleMethodMetric(UNTHROTTLE_METHOD_BY_WHITELIST);
224 } 224 }
225 225
226 } // namespace content 226 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/pepper/plugin_power_saver_helper_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698