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

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: removed plugininstancecreated 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
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..2c97cd288262d37e828bd76d39c4c521e10f499c 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,6 +17,19 @@ namespace content {
namespace {
+// Initial decision of the peripheral content decision.
+// These numeric values are used in UMA logs; do not change them.
+enum PeripheralHeuristicDecision {
+ PERIPHERAL_HEURISTIC_DECISION_PERIPHERAL = 0,
+ PERIPHERAL_HEURISTIC_DECISION_ESSENTIAL_SAME_ORIGIN = 1,
+ PERIPHERAL_HEURISTIC_DECISION_ESSENTIAL_CROSS_ORIGIN_BIG = 2,
+ PERIPHERAL_HEURISTIC_DECISION_ESSENTIAL_CROSS_ORIGIN_WHITELISTED = 2,
Lei Zhang 2014/11/05 01:23:49 value should be 3?
tommycli 2014/11/05 19:01:41 Done.
+ PERIPHERAL_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;
@@ -89,24 +103,47 @@ 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()) {
+ UMA_HISTOGRAM_ENUMERATION(kPeripheralHeuristicHistogram,
+ PERIPHERAL_HEURISTIC_DECISION_PERIPHERAL,
+ PERIPHERAL_HEURISTIC_DECISION_NUM_ITEMS);
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) {
+ UMA_HISTOGRAM_ENUMERATION(
+ kPeripheralHeuristicHistogram,
+ PERIPHERAL_HEURISTIC_DECISION_ESSENTIAL_SAME_ORIGIN,
+ PERIPHERAL_HEURISTIC_DECISION_NUM_ITEMS);
*cross_origin = false;
return false;
}
// Whitelisted plugin origins are also essential.
- if (origin_whitelist_.count(content_origin))
+ if (origin_whitelist_.count(content_origin)) {
+ UMA_HISTOGRAM_ENUMERATION(
+ kPeripheralHeuristicHistogram,
+ PERIPHERAL_HEURISTIC_DECISION_ESSENTIAL_CROSS_ORIGIN_WHITELISTED,
+ PERIPHERAL_HEURISTIC_DECISION_NUM_ITEMS);
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) {
+ UMA_HISTOGRAM_ENUMERATION(kPeripheralHeuristicHistogram,
+ PERIPHERAL_HEURISTIC_DECISION_PERIPHERAL,
+ PERIPHERAL_HEURISTIC_DECISION_NUM_ITEMS);
+ } else {
+ UMA_HISTOGRAM_ENUMERATION(
+ kPeripheralHeuristicHistogram,
+ PERIPHERAL_HEURISTIC_DECISION_ESSENTIAL_CROSS_ORIGIN_BIG,
+ PERIPHERAL_HEURISTIC_DECISION_NUM_ITEMS);
+ }
return content_is_small;
}

Powered by Google App Engine
This is Rietveld 408576698