OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/pepper/pepper_plugin_instance_impl.h" | 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/metrics/sparse_histogram.h" | |
15 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
17 #include "base/strings/utf_offset_string_conversions.h" | 18 #include "base/strings/utf_offset_string_conversions.h" |
18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
19 #include "base/time/time.h" | 20 #include "base/time/time.h" |
20 #include "cc/base/latency_info_swap_promise.h" | 21 #include "cc/base/latency_info_swap_promise.h" |
21 #include "cc/blink/web_layer_impl.h" | 22 #include "cc/blink/web_layer_impl.h" |
22 #include "cc/layers/texture_layer.h" | 23 #include "cc/layers/texture_layer.h" |
23 #include "cc/trees/layer_tree_host.h" | 24 #include "cc/trees/layer_tree_host.h" |
24 #include "content/common/content_constants_internal.h" | 25 #include "content/common/content_constants_internal.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 using blink::WebURLRequest; | 180 using blink::WebURLRequest; |
180 using blink::WebURLResponse; | 181 using blink::WebURLResponse; |
181 using blink::WebUserGestureIndicator; | 182 using blink::WebUserGestureIndicator; |
182 using blink::WebUserGestureToken; | 183 using blink::WebUserGestureToken; |
183 using blink::WebView; | 184 using blink::WebView; |
184 | 185 |
185 namespace content { | 186 namespace content { |
186 | 187 |
187 namespace { | 188 namespace { |
188 | 189 |
190 static const int kInfiniteRatio = 99999; | |
191 | |
192 #define UMA_HISTOGRAM_ASPECT_RATIO(name, width, height) \ | |
193 UMA_HISTOGRAM_SPARSE_SLOWLY( \ | |
groby-ooo-7-16
2014/11/07 21:57:44
I think we need cutoffs - beyond 3:1 or 4:1 it's
tommycli
2014/11/07 22:46:37
I used the same aspect ratio encoding as here:
ht
groby-ooo-7-16
2014/11/07 23:02:20
These are video aspect ratios - they're rarely fli
tommycli
2014/11/07 23:14:10
Done.
| |
194 name, \ | |
195 (height) ? ((width) * 100) / (height) : kInfiniteRatio); | |
196 | |
189 // Check PP_TextInput_Type and ui::TextInputType are kept in sync. | 197 // Check PP_TextInput_Type and ui::TextInputType are kept in sync. |
190 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_NONE) == int(PP_TEXTINPUT_TYPE_NONE), | 198 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_NONE) == int(PP_TEXTINPUT_TYPE_NONE), |
191 mismatching_enums); | 199 mismatching_enums); |
192 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_TEXT) == int(PP_TEXTINPUT_TYPE_TEXT), | 200 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_TEXT) == int(PP_TEXTINPUT_TYPE_TEXT), |
193 mismatching_enums); | 201 mismatching_enums); |
194 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_PASSWORD) == | 202 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_PASSWORD) == |
195 int(PP_TEXTINPUT_TYPE_PASSWORD), | 203 int(PP_TEXTINPUT_TYPE_PASSWORD), |
196 mismatching_enums); | 204 mismatching_enums); |
197 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_SEARCH) == int(PP_TEXTINPUT_TYPE_SEARCH), | 205 COMPILE_ASSERT(int(ui::TEXT_INPUT_TYPE_SEARCH) == int(PP_TEXTINPUT_TYPE_SEARCH), |
198 mismatching_enums); | 206 mismatching_enums); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
384 input_sequence); | 392 input_sequence); |
385 new_latency->TraceEventType(WebInputEventTraits::GetName(type)); | 393 new_latency->TraceEventType(WebInputEventTraits::GetName(type)); |
386 if (old_latency) { | 394 if (old_latency) { |
387 new_latency->CopyLatencyFrom(*old_latency, | 395 new_latency->CopyLatencyFrom(*old_latency, |
388 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT); | 396 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT); |
389 new_latency->CopyLatencyFrom(*old_latency, | 397 new_latency->CopyLatencyFrom(*old_latency, |
390 ui::INPUT_EVENT_LATENCY_UI_COMPONENT); | 398 ui::INPUT_EVENT_LATENCY_UI_COMPONENT); |
391 } | 399 } |
392 } | 400 } |
393 | 401 |
402 enum PluginFlashInstanceSize { | |
403 INSTANCE_SIZE_1_1 = 0, | |
404 INSTANCE_SIZE_5_5 = 1, | |
405 INSTANCE_SIZE_10_10 = 2, | |
406 INSTANCE_SIZE_LARGE = 3, | |
407 INSTANCE_SIZE_NUM_ITEMS | |
408 }; | |
409 | |
394 // How the throttled power saver is unthrottled, if ever. | 410 // How the throttled power saver is unthrottled, if ever. |
395 // These numeric values are used in UMA logs; do not change them. | 411 // These numeric values are used in UMA logs; do not change them. |
396 enum PowerSaverUnthrottleMethod { | 412 enum PowerSaverUnthrottleMethod { |
397 UNTHROTTLE_METHOD_NEVER = 0, | 413 UNTHROTTLE_METHOD_NEVER = 0, |
398 UNTHROTTLE_METHOD_BY_CLICK = 1, | 414 UNTHROTTLE_METHOD_BY_CLICK = 1, |
399 UNTHROTTLE_METHOD_BY_WHITELIST = 2, | 415 UNTHROTTLE_METHOD_BY_WHITELIST = 2, |
400 UNTHROTTLE_METHOD_NUM_ITEMS | 416 UNTHROTTLE_METHOD_NUM_ITEMS |
401 }; | 417 }; |
402 | 418 |
419 const char kFlashClickSizeAspectRatioHistogram[] = | |
420 "Plugin.FlashClickSizeAspectRatio"; | |
groby-ooo-7-16
2014/11/07 21:57:44
Plugin.Flash.ClickSize.AspectRatio ? (And the same
tommycli
2014/11/07 22:46:37
Done.
| |
421 const char kFlashClickSizeHeightHistogram[] = "Plugin.FlashClickSizeHeight"; | |
422 const char kFlashClickSizeWidthHistogram[] = "Plugin.FlashClickSizeWidth"; | |
423 const char kFlashInstanceSizeHistogram[] = "Plugin.FlashInstanceSize"; | |
403 const char kPowerSaverUnthrottleHistogram[] = "Plugin.PowerSaverUnthrottle"; | 424 const char kPowerSaverUnthrottleHistogram[] = "Plugin.PowerSaverUnthrottle"; |
404 | 425 |
426 void RecordFlashSizeMetric(int width, int height) { | |
427 if (width <= 1 && height <= 1) { | |
428 UMA_HISTOGRAM_ENUMERATION(kFlashInstanceSizeHistogram, INSTANCE_SIZE_1_1, | |
429 INSTANCE_SIZE_NUM_ITEMS); | |
430 } else if (width <= 5 && height <= 5) { | |
431 UMA_HISTOGRAM_ENUMERATION(kFlashInstanceSizeHistogram, INSTANCE_SIZE_5_5, | |
432 INSTANCE_SIZE_NUM_ITEMS); | |
433 } else if (width <= 10 && height <= 10) { | |
434 UMA_HISTOGRAM_ENUMERATION(kFlashInstanceSizeHistogram, INSTANCE_SIZE_10_10, | |
435 INSTANCE_SIZE_NUM_ITEMS); | |
436 } else { | |
437 UMA_HISTOGRAM_ENUMERATION(kFlashInstanceSizeHistogram, INSTANCE_SIZE_LARGE, | |
438 INSTANCE_SIZE_NUM_ITEMS); | |
439 } | |
440 } | |
441 | |
442 void RecordFlashClickSizeMetric(int width, int height) { | |
443 UMA_HISTOGRAM_COUNTS(kFlashClickSizeHeightHistogram, height); | |
groby-ooo-7-16
2014/11/07 21:57:44
I believe these are exponential histograms. We wan
tommycli
2014/11/07 22:46:37
Done.
I followed this example: https://code.googl
groby-ooo-7-16
2014/11/07 23:02:20
They're not "doing it wrong", but they might be in
tommycli
2014/11/07 23:14:10
Done. Good point.
| |
444 UMA_HISTOGRAM_COUNTS(kFlashClickSizeWidthHistogram, width); | |
445 UMA_HISTOGRAM_ASPECT_RATIO(kFlashClickSizeAspectRatioHistogram, width, | |
446 height); | |
447 } | |
448 | |
405 void RecordUnthrottleMethodMetric(PowerSaverUnthrottleMethod method) { | 449 void RecordUnthrottleMethodMetric(PowerSaverUnthrottleMethod method) { |
406 UMA_HISTOGRAM_ENUMERATION(kPowerSaverUnthrottleHistogram, method, | 450 UMA_HISTOGRAM_ENUMERATION(kPowerSaverUnthrottleHistogram, method, |
407 UNTHROTTLE_METHOD_NUM_ITEMS); | 451 UNTHROTTLE_METHOD_NUM_ITEMS); |
408 } | 452 } |
409 | 453 |
410 bool IsFlashPlugin(PluginModule* module) { | 454 bool IsFlashPlugin(PluginModule* module) { |
411 return module->name() == kFlashPluginName; | 455 return module->name() == kFlashPluginName; |
412 } | 456 } |
413 | 457 |
414 } // namespace | 458 } // namespace |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
504 const GURL& plugin_url) | 548 const GURL& plugin_url) |
505 : RenderFrameObserver(render_frame), | 549 : RenderFrameObserver(render_frame), |
506 render_frame_(render_frame), | 550 render_frame_(render_frame), |
507 module_(module), | 551 module_(module), |
508 instance_interface_(instance_interface), | 552 instance_interface_(instance_interface), |
509 pp_instance_(0), | 553 pp_instance_(0), |
510 container_(container), | 554 container_(container), |
511 layer_bound_to_fullscreen_(false), | 555 layer_bound_to_fullscreen_(false), |
512 layer_is_hardware_(false), | 556 layer_is_hardware_(false), |
513 plugin_url_(plugin_url), | 557 plugin_url_(plugin_url), |
558 has_been_clicked_(false), | |
514 power_saver_enabled_(false), | 559 power_saver_enabled_(false), |
515 is_peripheral_content_(false), | 560 is_peripheral_content_(false), |
516 plugin_throttled_(false), | 561 plugin_throttled_(false), |
517 full_frame_(false), | 562 full_frame_(false), |
518 sent_initial_did_change_view_(false), | 563 sent_initial_did_change_view_(false), |
519 bound_graphics_2d_platform_(NULL), | 564 bound_graphics_2d_platform_(NULL), |
520 bound_compositor_(NULL), | 565 bound_compositor_(NULL), |
521 has_webkit_focus_(false), | 566 has_webkit_focus_(false), |
522 has_content_area_focus_(false), | 567 has_content_area_focus_(false), |
523 find_identifier_(-1), | 568 find_identifier_(-1), |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
599 GetPluginURL()); | 644 GetPluginURL()); |
600 } | 645 } |
601 } | 646 } |
602 | 647 |
603 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host(); | 648 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host(); |
604 resource_creation_ = host_impl->CreateInProcessResourceCreationAPI(this); | 649 resource_creation_ = host_impl->CreateInProcessResourceCreationAPI(this); |
605 | 650 |
606 if (GetContentClient()->renderer() && // NULL in unit tests. | 651 if (GetContentClient()->renderer() && // NULL in unit tests. |
607 GetContentClient()->renderer()->IsExternalPepperPlugin(module->name())) | 652 GetContentClient()->renderer()->IsExternalPepperPlugin(module->name())) |
608 external_document_load_ = true; | 653 external_document_load_ = true; |
609 | |
610 if (IsFlashPlugin(module_.get())) { | |
611 RenderThread::Get()->RecordAction( | |
612 base::UserMetricsAction("Flash.PluginInstanceCreated")); | |
613 } | |
614 } | 654 } |
615 | 655 |
616 PepperPluginInstanceImpl::~PepperPluginInstanceImpl() { | 656 PepperPluginInstanceImpl::~PepperPluginInstanceImpl() { |
617 DCHECK(!fullscreen_container_); | 657 DCHECK(!fullscreen_container_); |
618 | 658 |
619 if (plugin_throttled_) | 659 if (plugin_throttled_) |
620 RecordUnthrottleMethodMetric(UNTHROTTLE_METHOD_NEVER); | 660 RecordUnthrottleMethodMetric(UNTHROTTLE_METHOD_NEVER); |
621 | 661 |
622 // Notify all the plugin objects of deletion. This will prevent blink from | 662 // Notify all the plugin objects of deletion. This will prevent blink from |
623 // calling into the plugin any more. | 663 // calling into the plugin any more. |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
864 #endif | 904 #endif |
865 } | 905 } |
866 | 906 |
867 bool PepperPluginInstanceImpl::Initialize( | 907 bool PepperPluginInstanceImpl::Initialize( |
868 const std::vector<std::string>& arg_names, | 908 const std::vector<std::string>& arg_names, |
869 const std::vector<std::string>& arg_values, | 909 const std::vector<std::string>& arg_values, |
870 bool full_frame) { | 910 bool full_frame) { |
871 if (!render_frame_) | 911 if (!render_frame_) |
872 return false; | 912 return false; |
873 | 913 |
914 blink::WebRect bounds = container_->element().boundsInViewportSpace(); | |
915 if (IsFlashPlugin(module_.get())) { | |
groby-ooo-7-16
2014/11/07 21:57:44
Curious: Why did this move? To do all recording at
tommycli
2014/11/07 22:46:38
Yes. And it had to be here because you can only ge
| |
916 RenderThread::Get()->RecordAction( | |
917 base::UserMetricsAction("Flash.PluginInstanceCreated")); | |
918 RecordFlashSizeMetric(bounds.width, bounds.height); | |
919 } | |
920 | |
874 PluginPowerSaverHelper* power_saver_helper = | 921 PluginPowerSaverHelper* power_saver_helper = |
875 render_frame_->plugin_power_saver_helper(); | 922 render_frame_->plugin_power_saver_helper(); |
876 GURL content_origin = plugin_url_.GetOrigin(); | 923 GURL content_origin = plugin_url_.GetOrigin(); |
877 blink::WebRect bounds = container_->element().boundsInViewportSpace(); | |
878 | 924 |
879 bool cross_origin = false; | 925 bool cross_origin = false; |
880 is_peripheral_content_ = | 926 is_peripheral_content_ = |
881 IsFlashPlugin(module_.get()) && | 927 IsFlashPlugin(module_.get()) && |
882 power_saver_helper->ShouldThrottleContent(content_origin, bounds.width, | 928 power_saver_helper->ShouldThrottleContent(content_origin, bounds.width, |
883 bounds.height, &cross_origin); | 929 bounds.height, &cross_origin); |
884 | 930 |
885 power_saver_enabled_ = is_peripheral_content_ && | 931 power_saver_enabled_ = is_peripheral_content_ && |
886 base::CommandLine::ForCurrentProcess()->HasSwitch( | 932 base::CommandLine::ForCurrentProcess()->HasSwitch( |
887 switches::kEnablePluginPowerSaver); | 933 switches::kEnablePluginPowerSaver); |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1151 gfx::Rect caret(text_input_caret_); | 1197 gfx::Rect caret(text_input_caret_); |
1152 caret.Offset(view_data_.rect.point.x, view_data_.rect.point.y); | 1198 caret.Offset(view_data_.rect.point.x, view_data_.rect.point.y); |
1153 return caret; | 1199 return caret; |
1154 } | 1200 } |
1155 | 1201 |
1156 bool PepperPluginInstanceImpl::HandleInputEvent( | 1202 bool PepperPluginInstanceImpl::HandleInputEvent( |
1157 const blink::WebInputEvent& event, | 1203 const blink::WebInputEvent& event, |
1158 WebCursorInfo* cursor_info) { | 1204 WebCursorInfo* cursor_info) { |
1159 TRACE_EVENT0("ppapi", "PepperPluginInstanceImpl::HandleInputEvent"); | 1205 TRACE_EVENT0("ppapi", "PepperPluginInstanceImpl::HandleInputEvent"); |
1160 | 1206 |
1207 if (event.type == blink::WebInputEvent::MouseDown && !has_been_clicked_ && | |
1208 IsFlashPlugin(module_.get())) { | |
1209 has_been_clicked_ = true; | |
1210 blink::WebRect bounds = container_->element().boundsInViewportSpace(); | |
1211 RecordFlashClickSizeMetric(bounds.width, bounds.height); | |
1212 } | |
1213 | |
1161 if (event.type == blink::WebInputEvent::MouseUp && is_peripheral_content_) { | 1214 if (event.type == blink::WebInputEvent::MouseUp && is_peripheral_content_) { |
1162 is_peripheral_content_ = false; | 1215 is_peripheral_content_ = false; |
1163 power_saver_enabled_ = false; | 1216 power_saver_enabled_ = false; |
1164 | 1217 |
1165 RecordUnthrottleMethodMetric(UNTHROTTLE_METHOD_BY_CLICK); | 1218 RecordUnthrottleMethodMetric(UNTHROTTLE_METHOD_BY_CLICK); |
1166 | 1219 |
1167 if (plugin_throttled_) { | 1220 if (plugin_throttled_) { |
1168 SetPluginThrottled(false /* throttled */); | 1221 SetPluginThrottled(false /* throttled */); |
1169 return true; | 1222 return true; |
1170 } | 1223 } |
(...skipping 2195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3366 return; | 3419 return; |
3367 | 3420 |
3368 is_peripheral_content_ = false; | 3421 is_peripheral_content_ = false; |
3369 power_saver_enabled_ = false; | 3422 power_saver_enabled_ = false; |
3370 SetPluginThrottled(false); | 3423 SetPluginThrottled(false); |
3371 | 3424 |
3372 RecordUnthrottleMethodMetric(UNTHROTTLE_METHOD_BY_WHITELIST); | 3425 RecordUnthrottleMethodMetric(UNTHROTTLE_METHOD_BY_WHITELIST); |
3373 } | 3426 } |
3374 | 3427 |
3375 } // namespace content | 3428 } // namespace content |
OLD | NEW |