summaryrefslogtreecommitdiffstats
path: root/content/renderer
diff options
context:
space:
mode:
authortommycli <tommycli@chromium.org>2014-11-05 11:33:57 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-05 19:34:21 +0000
commit4d61f56bd68e7efe982276254c7abb48852e65ca (patch)
tree322a2608e67feca2b4c0d1eb8d92bc577ff73605 /content/renderer
parent2cb9eb135cca2d8a64fa7e95e90f9f698c2cc8c2 (diff)
downloadchromium_src-4d61f56bd68e7efe982276254c7abb48852e65ca.zip
chromium_src-4d61f56bd68e7efe982276254c7abb48852e65ca.tar.gz
chromium_src-4d61f56bd68e7efe982276254c7abb48852e65ca.tar.bz2
Plugin Power Saver: Fix (probably rare) crash in PepperPluginInstanceImpl.
Wasn't able to repro personally, but based on stack traces, crash reports, and sadrul@'s diagnosis, this should probably fix the crash in below bug. BUG=430228 Review URL: https://codereview.chromium.org/682813005 Cr-Commit-Position: refs/heads/master@{#302848}
Diffstat (limited to 'content/renderer')
-rw-r--r--content/renderer/pepper/pepper_plugin_instance_impl.cc53
1 files changed, 27 insertions, 26 deletions
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc
index 7cdda79..31ad5fc8 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;