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

Side by Side Diff: components/plugins/renderer/loadable_plugin_placeholder.cc

Issue 1114623002: Plugin Power Saver: Make PPS work well with prerendered pages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/plugins/renderer/loadable_plugin_placeholder.h" 5 #include "components/plugins/renderer/loadable_plugin_placeholder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/json/string_escape.h" 9 #include "base/json/string_escape.h"
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 if (!allow_loading_) { 285 if (!allow_loading_) {
286 NOTREACHED(); 286 NOTREACHED();
287 return; 287 return;
288 } 288 }
289 289
290 if (premade_throttler_) { 290 if (premade_throttler_) {
291 premade_throttler_->SetHiddenForPlaceholder(false /* hidden */); 291 premade_throttler_->SetHiddenForPlaceholder(false /* hidden */);
292 ReplacePlugin(premade_throttler_->GetWebPlugin()); 292 ReplacePlugin(premade_throttler_->GetWebPlugin());
293 premade_throttler_ = nullptr; 293 premade_throttler_ = nullptr;
294 } else { 294 } else {
295 // TODO(mmenke): In the case of prerendering, feed into 295 ReplacePlugin(CreatePlugin());
296 // ChromeContentRendererClient::CreatePlugin instead, to
297 // reduce the chance of future regressions.
298 scoped_ptr<PluginInstanceThrottler> throttler;
299 #if defined(ENABLE_PLUGINS)
300 // If the plugin has already been marked essential in its placeholder form,
301 // we shouldn't create a new throttler and start the process all over again.
302 if (power_saver_enabled_)
303 throttler = PluginInstanceThrottler::Create();
304 #endif
305 WebPlugin* plugin = render_frame()->CreatePlugin(
306 GetFrame(), plugin_info_, GetPluginParams(), throttler.Pass());
307
308 ReplacePlugin(plugin);
309 } 296 }
310 } 297 }
311 298
312 void LoadablePluginPlaceholder::LoadCallback() { 299 void LoadablePluginPlaceholder::LoadCallback() {
313 RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Load_Click")); 300 RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Load_Click"));
314 #if defined(ENABLE_PLUGINS) 301 #if defined(ENABLE_PLUGINS)
315 // If the user specifically clicks on the plugin content's placeholder, 302 // If the user specifically clicks on the plugin content's placeholder,
316 // disable power saver throttling for this instance. 303 // disable power saver throttling for this instance.
317 MarkPluginEssential(PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_CLICK); 304 MarkPluginEssential(PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_CLICK);
318 #endif 305 #endif
(...skipping 22 matching lines...) Expand all
341 } 328 }
342 329
343 const content::WebPluginInfo& LoadablePluginPlaceholder::GetPluginInfo() const { 330 const content::WebPluginInfo& LoadablePluginPlaceholder::GetPluginInfo() const {
344 return plugin_info_; 331 return plugin_info_;
345 } 332 }
346 333
347 void LoadablePluginPlaceholder::SetIdentifier(const std::string& identifier) { 334 void LoadablePluginPlaceholder::SetIdentifier(const std::string& identifier) {
348 identifier_ = identifier; 335 identifier_ = identifier;
349 } 336 }
350 337
338 const std::string& LoadablePluginPlaceholder::GetIdentifier() const {
339 return identifier_;
340 }
341
351 bool LoadablePluginPlaceholder::LoadingBlocked() const { 342 bool LoadablePluginPlaceholder::LoadingBlocked() const {
352 DCHECK(allow_loading_); 343 DCHECK(allow_loading_);
353 return is_blocked_for_background_tab_ || is_blocked_for_power_saver_poster_ || 344 return is_blocked_for_background_tab_ || is_blocked_for_power_saver_poster_ ||
354 is_blocked_for_prerendering_; 345 is_blocked_for_prerendering_;
355 } 346 }
356 347
357 } // namespace plugins 348 } // namespace plugins
OLDNEW
« no previous file with comments | « components/plugins/renderer/loadable_plugin_placeholder.h ('k') | content/public/renderer/plugin_instance_throttler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698