OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/renderer/pepper/pepper_plugin_instance_metrics.h" | |
6 | |
7 #include "base/metrics/histogram.h" | |
8 #include "base/metrics/sparse_histogram.h" | |
9 #include "ppapi/shared_impl/ppapi_preferences.h" | |
10 | |
11 #if defined(OS_WIN) | |
12 #include "base/win/windows_version.h" | |
13 #endif | |
14 | |
15 #define UMA_HISTOGRAM_ASPECT_RATIO(name, width, height) \ | |
16 UMA_HISTOGRAM_SPARSE_SLOWLY( \ | |
Bernhard Bauer
2015/01/13 23:29:36
I think this should be indented four spaces per th
tommycli
2015/01/14 01:45:00
Done. I just used git cl format. Not sure why it's
| |
17 name, (height) ? ((width)*100) / (height) : kInfiniteRatio); | |
18 | |
19 namespace content { | |
20 | |
21 namespace { | |
22 | |
23 // Histogram tracking prevalence of tiny Flash instances. Units in pixels. | |
24 enum PluginFlashTinyContentSize { | |
25 TINY_CONTENT_SIZE_1_1 = 0, | |
26 TINY_CONTENT_SIZE_5_5 = 1, | |
27 TINY_CONTENT_SIZE_10_10 = 2, | |
28 TINY_CONTENT_SIZE_LARGE = 3, | |
29 TINY_CONTENT_SIZE_NUM_ITEMS | |
30 }; | |
31 | |
32 const int kInfiniteRatio = 99999; | |
33 | |
34 const char kFlashClickSizeAspectRatioHistogram[] = | |
35 "Plugin.Flash.ClickSize.AspectRatio"; | |
36 const char kFlashClickSizeHeightHistogram[] = "Plugin.Flash.ClickSize.Height"; | |
37 const char kFlashClickSizeWidthHistogram[] = "Plugin.Flash.ClickSize.Width"; | |
38 const char kFlashTinyContentSizeHistogram[] = "Plugin.Flash.TinyContentSize"; | |
39 | |
40 } // namespace | |
41 | |
42 void RecordFlashSizeMetric(int width, int height) { | |
43 PluginFlashTinyContentSize size = TINY_CONTENT_SIZE_LARGE; | |
44 | |
45 if (width <= 1 && height <= 1) | |
46 size = TINY_CONTENT_SIZE_1_1; | |
47 else if (width <= 5 && height <= 5) | |
48 size = TINY_CONTENT_SIZE_5_5; | |
49 else if (width <= 10 && height <= 10) | |
50 size = TINY_CONTENT_SIZE_10_10; | |
51 | |
52 UMA_HISTOGRAM_ENUMERATION(kFlashTinyContentSizeHistogram, size, | |
53 TINY_CONTENT_SIZE_NUM_ITEMS); | |
54 } | |
55 | |
56 void RecordFlashClickSizeMetric(int width, int height) { | |
57 base::HistogramBase* width_histogram = base::LinearHistogram::FactoryGet( | |
58 kFlashClickSizeWidthHistogram, | |
59 0, // minimum width | |
60 500, // maximum width | |
61 100, // number of buckets. | |
62 base::HistogramBase::kUmaTargetedHistogramFlag); | |
63 width_histogram->Add(width); | |
64 | |
65 base::HistogramBase* height_histogram = base::LinearHistogram::FactoryGet( | |
66 kFlashClickSizeHeightHistogram, | |
67 0, // minimum height | |
68 400, // maximum height | |
69 100, // number of buckets. | |
70 base::HistogramBase::kUmaTargetedHistogramFlag); | |
71 height_histogram->Add(height); | |
72 | |
73 UMA_HISTOGRAM_ASPECT_RATIO(kFlashClickSizeAspectRatioHistogram, width, | |
74 height); | |
75 } | |
76 | |
77 void SetGPUHistogram(const ppapi::Preferences& prefs, | |
78 const std::vector<std::string>& arg_names, | |
79 const std::vector<std::string>& arg_values) { | |
80 // Calculate a histogram to let us determine how likely people are to try to | |
81 // run Stage3D content on machines that have it blacklisted. | |
82 #if defined(OS_WIN) | |
83 bool needs_gpu = false; | |
84 bool is_xp = base::win::GetVersion() <= base::win::VERSION_XP; | |
85 | |
86 for (size_t i = 0; i < arg_names.size(); i++) { | |
87 if (arg_names[i] == "wmode") { | |
88 // In theory content other than Flash could have a "wmode" argument, | |
89 // but that's pretty unlikely. | |
90 if (arg_values[i] == "direct" || arg_values[i] == "gpu") | |
91 needs_gpu = true; | |
92 break; | |
93 } | |
94 } | |
95 // 0 : No 3D content and GPU is blacklisted | |
96 // 1 : No 3D content and GPU is not blacklisted | |
97 // 2 : 3D content but GPU is blacklisted | |
98 // 3 : 3D content and GPU is not blacklisted | |
99 // 4 : No 3D content and GPU is blacklisted on XP | |
100 // 5 : No 3D content and GPU is not blacklisted on XP | |
101 // 6 : 3D content but GPU is blacklisted on XP | |
102 // 7 : 3D content and GPU is not blacklisted on XP | |
103 UMA_HISTOGRAM_ENUMERATION( | |
104 "Flash.UsesGPU", is_xp * 4 + needs_gpu * 2 + prefs.is_webgl_supported, 8); | |
105 #endif | |
106 } | |
107 | |
108 } // namespace content | |
OLD | NEW |