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

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

Issue 2211753002: Plugin Power Saver Tiny: Fix Plugin.PowerSaver.PeripheralHeuristic UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 url::Origin(GURL(GetPluginParams().url)), 44 url::Origin(GURL(GetPluginParams().url)),
45 base::Bind(&LoadablePluginPlaceholder::MarkPluginEssential, 45 base::Bind(&LoadablePluginPlaceholder::MarkPluginEssential,
46 weak_factory_.GetWeakPtr(), 46 weak_factory_.GetWeakPtr(),
47 PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_WHITELIST)); 47 PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_WHITELIST));
48 } 48 }
49 49
50 void LoadablePluginPlaceholder::SetPremadePlugin( 50 void LoadablePluginPlaceholder::SetPremadePlugin(
51 content::PluginInstanceThrottler* throttler) { 51 content::PluginInstanceThrottler* throttler) {
52 DCHECK(throttler); 52 DCHECK(throttler);
53 DCHECK(!premade_throttler_); 53 DCHECK(!premade_throttler_);
54 heuristic_run_before_ = true;
54 premade_throttler_ = throttler; 55 premade_throttler_ = throttler;
55 } 56 }
56 57
57 LoadablePluginPlaceholder::LoadablePluginPlaceholder( 58 LoadablePluginPlaceholder::LoadablePluginPlaceholder(
58 content::RenderFrame* render_frame, 59 content::RenderFrame* render_frame,
59 blink::WebLocalFrame* frame, 60 blink::WebLocalFrame* frame,
60 const blink::WebPluginParams& params, 61 const blink::WebPluginParams& params,
61 const std::string& html_data) 62 const std::string& html_data)
62 : PluginPlaceholderBase(render_frame, frame, params, html_data), 63 : PluginPlaceholderBase(render_frame, frame, params, html_data),
64 heuristic_run_before_(false),
63 is_blocked_for_tinyness_(false), 65 is_blocked_for_tinyness_(false),
64 is_blocked_for_background_tab_(false), 66 is_blocked_for_background_tab_(false),
65 is_blocked_for_prerendering_(false), 67 is_blocked_for_prerendering_(false),
66 is_blocked_for_power_saver_poster_(false), 68 is_blocked_for_power_saver_poster_(false),
67 power_saver_enabled_(false), 69 power_saver_enabled_(false),
68 premade_throttler_(nullptr), 70 premade_throttler_(nullptr),
69 allow_loading_(false), 71 allow_loading_(false),
70 finished_loading_(false), 72 finished_loading_(false),
71 heuristic_run_before_(premade_throttler_ != nullptr),
72 weak_factory_(this) {} 73 weak_factory_(this) {}
73 74
74 LoadablePluginPlaceholder::~LoadablePluginPlaceholder() { 75 LoadablePluginPlaceholder::~LoadablePluginPlaceholder() {
75 } 76 }
76 77
77 void LoadablePluginPlaceholder::MarkPluginEssential( 78 void LoadablePluginPlaceholder::MarkPluginEssential(
78 PluginInstanceThrottler::PowerSaverUnthrottleMethod method) { 79 PluginInstanceThrottler::PowerSaverUnthrottleMethod method) {
79 if (!power_saver_enabled_) 80 if (!power_saver_enabled_)
80 return; 81 return;
81 82
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 int width = roundf(unobscured_rect_.width() / zoom_factor); 196 int width = roundf(unobscured_rect_.width() / zoom_factor);
196 int height = roundf(unobscured_rect_.height() / zoom_factor); 197 int height = roundf(unobscured_rect_.height() / zoom_factor);
197 int x = roundf(unobscured_rect_.x() / zoom_factor); 198 int x = roundf(unobscured_rect_.x() / zoom_factor);
198 int y = roundf(unobscured_rect_.y() / zoom_factor); 199 int y = roundf(unobscured_rect_.y() / zoom_factor);
199 200
200 // On a size update check if we now qualify as a essential plugin. 201 // On a size update check if we now qualify as a essential plugin.
201 url::Origin content_origin = url::Origin(GetPluginParams().url); 202 url::Origin content_origin = url::Origin(GetPluginParams().url);
202 content::RenderFrame::PeripheralContentStatus status = 203 content::RenderFrame::PeripheralContentStatus status =
203 render_frame()->GetPeripheralContentStatus( 204 render_frame()->GetPeripheralContentStatus(
204 render_frame()->GetWebFrame()->top()->getSecurityOrigin(), 205 render_frame()->GetWebFrame()->top()->getSecurityOrigin(),
205 content_origin, gfx::Size(width, height)); 206 content_origin, gfx::Size(width, height),
207 !heuristic_run_before_ /* record_decision */);
206 208
207 bool plugin_is_tiny_and_blocked = 209 bool plugin_is_tiny_and_blocked =
208 is_blocked_for_tinyness_ && 210 is_blocked_for_tinyness_ &&
209 status == 211 status ==
210 content::RenderFrame::CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_TINY; 212 content::RenderFrame::CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_TINY;
211 213
212 // Early exit for plugins that we've discovered to be essential. 214 // Early exit for plugins that we've discovered to be essential.
213 if (!plugin_is_tiny_and_blocked && 215 if (!plugin_is_tiny_and_blocked &&
214 status != content::RenderFrame::CONTENT_STATUS_PERIPHERAL) { 216 status != content::RenderFrame::CONTENT_STATUS_PERIPHERAL) {
215 MarkPluginEssential( 217 MarkPluginEssential(
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 return identifier_; 361 return identifier_;
360 } 362 }
361 363
362 bool LoadablePluginPlaceholder::LoadingBlocked() const { 364 bool LoadablePluginPlaceholder::LoadingBlocked() const {
363 DCHECK(allow_loading_); 365 DCHECK(allow_loading_);
364 return is_blocked_for_tinyness_ || is_blocked_for_background_tab_ || 366 return is_blocked_for_tinyness_ || is_blocked_for_background_tab_ ||
365 is_blocked_for_power_saver_poster_ || is_blocked_for_prerendering_; 367 is_blocked_for_power_saver_poster_ || is_blocked_for_prerendering_;
366 } 368 }
367 369
368 } // namespace plugins 370 } // namespace plugins
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698