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

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

Issue 703453004: Plugin Power Saver: Add some UMAs to test plugins in wild. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: try reupload 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 | « content/renderer/pepper/pepper_plugin_instance_impl.cc ('k') | tools/metrics/actions/actions.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/pepper/plugin_power_saver_helper.cc
diff --git a/content/renderer/pepper/plugin_power_saver_helper.cc b/content/renderer/pepper/plugin_power_saver_helper.cc
index 13c079ee1c876503c7f49eeb5416aaa4958b3265..365789c6835e6ed94ecb72e418a4dc06af8959ba 100644
--- a/content/renderer/pepper/plugin_power_saver_helper.cc
+++ b/content/renderer/pepper/plugin_power_saver_helper.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/callback.h"
+#include "base/metrics/histogram.h"
#include "content/common/frame_messages.h"
#include "content/public/renderer/document_state.h"
#include "content/public/renderer/navigation_state.h"
@@ -16,11 +17,29 @@ namespace content {
namespace {
+// Initial decision of the peripheral content decision.
+// These numeric values are used in UMA logs; do not change them.
+enum PeripheralHeuristicDecision {
+ HEURISTIC_DECISION_PERIPHERAL = 0,
+ HEURISTIC_DECISION_ESSENTIAL_SAME_ORIGIN = 1,
+ HEURISTIC_DECISION_ESSENTIAL_CROSS_ORIGIN_BIG = 2,
+ HEURISTIC_DECISION_ESSENTIAL_CROSS_ORIGIN_WHITELISTED = 3,
+ HEURISTIC_DECISION_NUM_ITEMS
+};
+
+const char kPeripheralHeuristicHistogram[] =
+ "Plugin.PowerSaverPeripheralHeuristic";
+
// Maximum dimensions plug-in content may have while still being considered
// peripheral content. These match the sizes used by Safari.
const int kPeripheralContentMaxWidth = 400;
const int kPeripheralContentMaxHeight = 300;
+void RecordDecisionMetric(PeripheralHeuristicDecision decision) {
+ UMA_HISTOGRAM_ENUMERATION(kPeripheralHeuristicHistogram, decision,
+ HEURISTIC_DECISION_NUM_ITEMS);
+}
+
} // namespace
PluginPowerSaverHelper::PeripheralPlugin::PeripheralPlugin(
@@ -89,24 +108,34 @@ bool PluginPowerSaverHelper::ShouldThrottleContent(const GURL& content_origin,
// --site-per-process mode.
blink::WebFrame* main_frame =
render_frame()->GetWebFrame()->view()->mainFrame();
- if (main_frame->isWebRemoteFrame())
+ if (main_frame->isWebRemoteFrame()) {
+ RecordDecisionMetric(HEURISTIC_DECISION_PERIPHERAL);
return true;
+ }
// All same-origin plugin content is essential.
GURL main_frame_origin = GURL(main_frame->document().url()).GetOrigin();
if (content_origin == main_frame_origin) {
+ RecordDecisionMetric(HEURISTIC_DECISION_ESSENTIAL_SAME_ORIGIN);
*cross_origin = false;
return false;
}
// Whitelisted plugin origins are also essential.
- if (origin_whitelist_.count(content_origin))
+ if (origin_whitelist_.count(content_origin)) {
+ RecordDecisionMetric(HEURISTIC_DECISION_ESSENTIAL_CROSS_ORIGIN_WHITELISTED);
return false;
+ }
// Cross-origin plugin content is peripheral if smaller than a maximum size.
bool content_is_small = width < kPeripheralContentMaxWidth ||
height < kPeripheralContentMaxHeight;
+ if (content_is_small)
+ RecordDecisionMetric(HEURISTIC_DECISION_PERIPHERAL);
+ else
+ RecordDecisionMetric(HEURISTIC_DECISION_ESSENTIAL_CROSS_ORIGIN_BIG);
+
return content_is_small;
}
« no previous file with comments | « content/renderer/pepper/pepper_plugin_instance_impl.cc ('k') | tools/metrics/actions/actions.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698