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

Unified Diff: content/renderer/pepper/pepper_plugin_instance_impl.cc

Issue 682813005: Plugin Power Saver: Fix (probably rare) crash in PepperPluginInstanceImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/pepper/pepper_plugin_instance_impl.cc
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc
index 7cdda79ded3e579a64a7bb53c1a5044599e42790..31ad5fc8edf55520dcb39ec2f3bf96e03c52f515 100644
--- a/content/renderer/pepper/pepper_plugin_instance_impl.cc
+++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc
@@ -580,32 +580,6 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl(
container_->element().document().url(),
GetPluginURL());
}
-
- PluginPowerSaverHelper* power_saver_helper =
- render_frame_->plugin_power_saver_helper();
- GURL content_origin = plugin_url_.GetOrigin();
- blink::WebRect bounds = container_->element().boundsInViewportSpace();
-
- bool cross_origin = false;
- power_saver_enabled_ =
- CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnablePluginPowerSaver) &&
- IsFlashPlugin(module_.get()) &&
- power_saver_helper->ShouldThrottleContent(
- content_origin, bounds.width, bounds.height, &cross_origin);
-
- if (power_saver_enabled_) {
- power_saver_helper->RegisterPeripheralPlugin(
- content_origin,
- base::Bind(&PepperPluginInstanceImpl::DisablePowerSaverAndUnthrottle,
- weak_factory_.GetWeakPtr()));
-
- throttler_.reset(new PepperPluginInstanceThrottler(
- base::Bind(&PepperPluginInstanceImpl::SetPluginThrottled,
- weak_factory_.GetWeakPtr(), true /* throttled */)));
- } else if (cross_origin) {
- power_saver_helper->WhitelistContentOrigin(content_origin);
- }
}
RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host();
@@ -875,6 +849,33 @@ bool PepperPluginInstanceImpl::Initialize(
bool full_frame) {
if (!render_frame_)
return false;
+
+ PluginPowerSaverHelper* power_saver_helper =
+ render_frame_->plugin_power_saver_helper();
+ GURL content_origin = plugin_url_.GetOrigin();
+ blink::WebRect bounds = container_->element().boundsInViewportSpace();
+
+ bool cross_origin = false;
+ power_saver_enabled_ =
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnablePluginPowerSaver) &&
+ IsFlashPlugin(module_.get()) &&
+ power_saver_helper->ShouldThrottleContent(
+ content_origin, bounds.width, bounds.height, &cross_origin);
+
+ if (power_saver_enabled_) {
+ power_saver_helper->RegisterPeripheralPlugin(
+ content_origin,
+ base::Bind(&PepperPluginInstanceImpl::DisablePowerSaverAndUnthrottle,
+ weak_factory_.GetWeakPtr()));
+
+ throttler_.reset(new PepperPluginInstanceThrottler(
+ base::Bind(&PepperPluginInstanceImpl::SetPluginThrottled,
+ weak_factory_.GetWeakPtr(), true /* throttled */)));
+ } else if (cross_origin) {
+ power_saver_helper->WhitelistContentOrigin(content_origin);
+ }
+
message_channel_ = MessageChannel::Create(this, &message_channel_object_);
full_frame_ = full_frame;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698