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

Side by Side Diff: content/renderer/pepper/pepper_plugin_instance_impl.cc

Issue 707113002: Plugin Power Saver: Refactor Plugin Instance Throttling code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@0190-plugin-power-saver-add-some-umas
Patch Set: 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 unified diff | Download patch
OLDNEW
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"
10 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
11 #include "base/logging.h" 10 #include "base/logging.h"
12 #include "base/memory/linked_ptr.h" 11 #include "base/memory/linked_ptr.h"
13 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
14 #include "base/metrics/histogram.h"
15 #include "base/stl_util.h" 13 #include "base/stl_util.h"
16 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
17 #include "base/strings/utf_offset_string_conversions.h" 15 #include "base/strings/utf_offset_string_conversions.h"
18 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
19 #include "base/time/time.h" 17 #include "base/time/time.h"
20 #include "cc/base/latency_info_swap_promise.h" 18 #include "cc/base/latency_info_swap_promise.h"
21 #include "cc/blink/web_layer_impl.h" 19 #include "cc/blink/web_layer_impl.h"
22 #include "cc/layers/texture_layer.h" 20 #include "cc/layers/texture_layer.h"
23 #include "cc/trees/layer_tree_host.h" 21 #include "cc/trees/layer_tree_host.h"
24 #include "content/common/content_constants_internal.h" 22 #include "content/common/content_constants_internal.h"
25 #include "content/common/frame_messages.h" 23 #include "content/common/frame_messages.h"
26 #include "content/common/input/web_input_event_traits.h" 24 #include "content/common/input/web_input_event_traits.h"
27 #include "content/public/common/content_constants.h" 25 #include "content/public/common/content_constants.h"
28 #include "content/public/common/content_switches.h"
29 #include "content/public/common/page_zoom.h" 26 #include "content/public/common/page_zoom.h"
30 #include "content/public/renderer/content_renderer_client.h" 27 #include "content/public/renderer/content_renderer_client.h"
31 #include "content/renderer/gpu/render_widget_compositor.h" 28 #include "content/renderer/gpu/render_widget_compositor.h"
32 #include "content/renderer/pepper/content_decryptor_delegate.h" 29 #include "content/renderer/pepper/content_decryptor_delegate.h"
33 #include "content/renderer/pepper/event_conversion.h" 30 #include "content/renderer/pepper/event_conversion.h"
34 #include "content/renderer/pepper/fullscreen_container.h" 31 #include "content/renderer/pepper/fullscreen_container.h"
35 #include "content/renderer/pepper/gfx_conversion.h" 32 #include "content/renderer/pepper/gfx_conversion.h"
36 #include "content/renderer/pepper/host_dispatcher_wrapper.h" 33 #include "content/renderer/pepper/host_dispatcher_wrapper.h"
37 #include "content/renderer/pepper/host_globals.h" 34 #include "content/renderer/pepper/host_globals.h"
38 #include "content/renderer/pepper/message_channel.h" 35 #include "content/renderer/pepper/message_channel.h"
39 #include "content/renderer/pepper/pepper_browser_connection.h" 36 #include "content/renderer/pepper/pepper_browser_connection.h"
40 #include "content/renderer/pepper/pepper_compositor_host.h" 37 #include "content/renderer/pepper/pepper_compositor_host.h"
41 #include "content/renderer/pepper/pepper_file_ref_renderer_host.h" 38 #include "content/renderer/pepper/pepper_file_ref_renderer_host.h"
42 #include "content/renderer/pepper/pepper_graphics_2d_host.h" 39 #include "content/renderer/pepper/pepper_graphics_2d_host.h"
43 #include "content/renderer/pepper/pepper_in_process_router.h" 40 #include "content/renderer/pepper/pepper_in_process_router.h"
44 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" 41 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
45 #include "content/renderer/pepper/pepper_plugin_instance_throttler.h" 42 #include "content/renderer/pepper/pepper_plugin_instance_throttler.h"
46 #include "content/renderer/pepper/pepper_try_catch.h" 43 #include "content/renderer/pepper/pepper_try_catch.h"
47 #include "content/renderer/pepper/pepper_url_loader_host.h" 44 #include "content/renderer/pepper/pepper_url_loader_host.h"
48 #include "content/renderer/pepper/plugin_module.h" 45 #include "content/renderer/pepper/plugin_module.h"
49 #include "content/renderer/pepper/plugin_object.h" 46 #include "content/renderer/pepper/plugin_object.h"
50 #include "content/renderer/pepper/plugin_power_saver_helper.h"
51 #include "content/renderer/pepper/ppapi_preferences_builder.h" 47 #include "content/renderer/pepper/ppapi_preferences_builder.h"
52 #include "content/renderer/pepper/ppb_buffer_impl.h" 48 #include "content/renderer/pepper/ppb_buffer_impl.h"
53 #include "content/renderer/pepper/ppb_graphics_3d_impl.h" 49 #include "content/renderer/pepper/ppb_graphics_3d_impl.h"
54 #include "content/renderer/pepper/ppb_image_data_impl.h" 50 #include "content/renderer/pepper/ppb_image_data_impl.h"
55 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" 51 #include "content/renderer/pepper/renderer_ppapi_host_impl.h"
56 #include "content/renderer/pepper/url_request_info_util.h" 52 #include "content/renderer/pepper/url_request_info_util.h"
57 #include "content/renderer/pepper/url_response_info_util.h" 53 #include "content/renderer/pepper/url_response_info_util.h"
58 #include "content/renderer/render_frame_impl.h" 54 #include "content/renderer/render_frame_impl.h"
59 #include "content/renderer/render_thread_impl.h" 55 #include "content/renderer/render_thread_impl.h"
60 #include "content/renderer/render_view_impl.h" 56 #include "content/renderer/render_view_impl.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 #include "third_party/WebKit/public/platform/WebGamepads.h" 101 #include "third_party/WebKit/public/platform/WebGamepads.h"
106 #include "third_party/WebKit/public/platform/WebRect.h" 102 #include "third_party/WebKit/public/platform/WebRect.h"
107 #include "third_party/WebKit/public/platform/WebString.h" 103 #include "third_party/WebKit/public/platform/WebString.h"
108 #include "third_party/WebKit/public/platform/WebURL.h" 104 #include "third_party/WebKit/public/platform/WebURL.h"
109 #include "third_party/WebKit/public/platform/WebURLError.h" 105 #include "third_party/WebKit/public/platform/WebURLError.h"
110 #include "third_party/WebKit/public/platform/WebURLRequest.h" 106 #include "third_party/WebKit/public/platform/WebURLRequest.h"
111 #include "third_party/WebKit/public/web/WebBindings.h" 107 #include "third_party/WebKit/public/web/WebBindings.h"
112 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 108 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
113 #include "third_party/WebKit/public/web/WebDataSource.h" 109 #include "third_party/WebKit/public/web/WebDataSource.h"
114 #include "third_party/WebKit/public/web/WebDocument.h" 110 #include "third_party/WebKit/public/web/WebDocument.h"
115 #include "third_party/WebKit/public/web/WebElement.h"
116 #include "third_party/WebKit/public/web/WebInputEvent.h" 111 #include "third_party/WebKit/public/web/WebInputEvent.h"
117 #include "third_party/WebKit/public/web/WebLocalFrame.h" 112 #include "third_party/WebKit/public/web/WebLocalFrame.h"
118 #include "third_party/WebKit/public/web/WebPluginContainer.h" 113 #include "third_party/WebKit/public/web/WebPluginContainer.h"
119 #include "third_party/WebKit/public/web/WebPrintParams.h" 114 #include "third_party/WebKit/public/web/WebPrintParams.h"
120 #include "third_party/WebKit/public/web/WebPrintScalingOption.h" 115 #include "third_party/WebKit/public/web/WebPrintScalingOption.h"
121 #include "third_party/WebKit/public/web/WebScopedUserGesture.h" 116 #include "third_party/WebKit/public/web/WebScopedUserGesture.h"
122 #include "third_party/WebKit/public/web/WebScriptSource.h" 117 #include "third_party/WebKit/public/web/WebScriptSource.h"
123 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" 118 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
124 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" 119 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
125 #include "third_party/WebKit/public/web/WebView.h" 120 #include "third_party/WebKit/public/web/WebView.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 input_sequence); 379 input_sequence);
385 new_latency->TraceEventType(WebInputEventTraits::GetName(type)); 380 new_latency->TraceEventType(WebInputEventTraits::GetName(type));
386 if (old_latency) { 381 if (old_latency) {
387 new_latency->CopyLatencyFrom(*old_latency, 382 new_latency->CopyLatencyFrom(*old_latency,
388 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT); 383 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT);
389 new_latency->CopyLatencyFrom(*old_latency, 384 new_latency->CopyLatencyFrom(*old_latency,
390 ui::INPUT_EVENT_LATENCY_UI_COMPONENT); 385 ui::INPUT_EVENT_LATENCY_UI_COMPONENT);
391 } 386 }
392 } 387 }
393 388
394 // How the throttled power saver is unthrottled, if ever.
395 // These numeric values are used in UMA logs; do not change them.
396 enum PowerSaverUnthrottleMethod {
397 UNTHROTTLE_METHOD_NEVER = 0,
398 UNTHROTTLE_METHOD_BY_CLICK = 1,
399 UNTHROTTLE_METHOD_BY_WHITELIST = 2,
400 UNTHROTTLE_METHOD_NUM_ITEMS
401 };
402
403 const char kPowerSaverUnthrottleHistogram[] = "Plugin.PowerSaverUnthrottle";
404
405 void RecordUnthrottleMethodMetric(PowerSaverUnthrottleMethod method) {
406 UMA_HISTOGRAM_ENUMERATION(kPowerSaverUnthrottleHistogram, method,
407 UNTHROTTLE_METHOD_NUM_ITEMS);
408 }
409
410 bool IsFlashPlugin(PluginModule* module) {
411 return module->name() == kFlashPluginName;
412 }
413
414 } // namespace 389 } // namespace
415 390
416 // static 391 // static
417 PepperPluginInstanceImpl* PepperPluginInstanceImpl::Create( 392 PepperPluginInstanceImpl* PepperPluginInstanceImpl::Create(
418 RenderFrameImpl* render_frame, 393 RenderFrameImpl* render_frame,
419 PluginModule* module, 394 PluginModule* module,
420 WebPluginContainer* container, 395 WebPluginContainer* container,
421 const GURL& plugin_url) { 396 const GURL& plugin_url) {
422 base::Callback<const void*(const char*)> get_plugin_interface_func = 397 base::Callback<const void*(const char*)> get_plugin_interface_func =
423 base::Bind(&PluginModule::GetPluginInterface, module); 398 base::Bind(&PluginModule::GetPluginInterface, module);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 const GURL& plugin_url) 479 const GURL& plugin_url)
505 : RenderFrameObserver(render_frame), 480 : RenderFrameObserver(render_frame),
506 render_frame_(render_frame), 481 render_frame_(render_frame),
507 module_(module), 482 module_(module),
508 instance_interface_(instance_interface), 483 instance_interface_(instance_interface),
509 pp_instance_(0), 484 pp_instance_(0),
510 container_(container), 485 container_(container),
511 layer_bound_to_fullscreen_(false), 486 layer_bound_to_fullscreen_(false),
512 layer_is_hardware_(false), 487 layer_is_hardware_(false),
513 plugin_url_(plugin_url), 488 plugin_url_(plugin_url),
514 power_saver_enabled_(false),
515 is_peripheral_content_(false),
516 plugin_throttled_(false),
517 full_frame_(false), 489 full_frame_(false),
518 sent_initial_did_change_view_(false), 490 sent_initial_did_change_view_(false),
519 bound_graphics_2d_platform_(NULL), 491 bound_graphics_2d_platform_(NULL),
520 bound_compositor_(NULL), 492 bound_compositor_(NULL),
521 has_webkit_focus_(false), 493 has_webkit_focus_(false),
522 has_content_area_focus_(false), 494 has_content_area_focus_(false),
523 find_identifier_(-1), 495 find_identifier_(-1),
524 plugin_find_interface_(NULL), 496 plugin_find_interface_(NULL),
525 plugin_input_event_interface_(NULL), 497 plugin_input_event_interface_(NULL),
526 plugin_mouse_lock_interface_(NULL), 498 plugin_mouse_lock_interface_(NULL),
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 } 572 }
601 } 573 }
602 574
603 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host(); 575 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host();
604 resource_creation_ = host_impl->CreateInProcessResourceCreationAPI(this); 576 resource_creation_ = host_impl->CreateInProcessResourceCreationAPI(this);
605 577
606 if (GetContentClient()->renderer() && // NULL in unit tests. 578 if (GetContentClient()->renderer() && // NULL in unit tests.
607 GetContentClient()->renderer()->IsExternalPepperPlugin(module->name())) 579 GetContentClient()->renderer()->IsExternalPepperPlugin(module->name()))
608 external_document_load_ = true; 580 external_document_load_ = true;
609 581
610 if (IsFlashPlugin(module_.get())) { 582 if (module->name() == kFlashPluginName) {
611 RenderThread::Get()->RecordAction( 583 RenderThread::Get()->RecordAction(
612 base::UserMetricsAction("Flash.PluginInstanceCreated")); 584 base::UserMetricsAction("Flash.PluginInstanceCreated"));
613 } 585 }
614 } 586 }
615 587
616 PepperPluginInstanceImpl::~PepperPluginInstanceImpl() { 588 PepperPluginInstanceImpl::~PepperPluginInstanceImpl() {
617 DCHECK(!fullscreen_container_); 589 DCHECK(!fullscreen_container_);
618 590
619 if (plugin_throttled_)
620 RecordUnthrottleMethodMetric(UNTHROTTLE_METHOD_NEVER);
621
622 // Notify all the plugin objects of deletion. This will prevent blink from 591 // Notify all the plugin objects of deletion. This will prevent blink from
623 // calling into the plugin any more. 592 // calling into the plugin any more.
624 // 593 //
625 // Swap out the set so we can delete from it (the objects will try to 594 // Swap out the set so we can delete from it (the objects will try to
626 // unregister themselves inside the delete call). 595 // unregister themselves inside the delete call).
627 PluginObjectSet plugin_object_copy; 596 PluginObjectSet plugin_object_copy;
628 live_plugin_objects_.swap(plugin_object_copy); 597 live_plugin_objects_.swap(plugin_object_copy);
629 for (PluginObjectSet::iterator i = plugin_object_copy.begin(); 598 for (PluginObjectSet::iterator i = plugin_object_copy.begin();
630 i != plugin_object_copy.end(); 599 i != plugin_object_copy.end();
631 ++i) { 600 ++i) {
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 #endif 833 #endif
865 } 834 }
866 835
867 bool PepperPluginInstanceImpl::Initialize( 836 bool PepperPluginInstanceImpl::Initialize(
868 const std::vector<std::string>& arg_names, 837 const std::vector<std::string>& arg_names,
869 const std::vector<std::string>& arg_values, 838 const std::vector<std::string>& arg_values,
870 bool full_frame) { 839 bool full_frame) {
871 if (!render_frame_) 840 if (!render_frame_)
872 return false; 841 return false;
873 842
874 PluginPowerSaverHelper* power_saver_helper = 843 throttler_.reset(new PepperPluginInstanceThrottler(
875 render_frame_->plugin_power_saver_helper(); 844 this, base::Bind(&PepperPluginInstanceImpl::SendDidChangeView,
raymes 2014/11/10 02:34:20 Since we're already passing the PepperPluginInstan
tommycli 2014/11/11 19:54:30 Yes we can, but then we have to make SendDidChange
876 GURL content_origin = plugin_url_.GetOrigin(); 845 weak_factory_.GetWeakPtr())));
877 blink::WebRect bounds = container_->element().boundsInViewportSpace();
878
879 bool cross_origin = false;
880 is_peripheral_content_ =
881 IsFlashPlugin(module_.get()) &&
882 power_saver_helper->ShouldThrottleContent(content_origin, bounds.width,
883 bounds.height, &cross_origin);
884
885 power_saver_enabled_ = is_peripheral_content_ &&
886 base::CommandLine::ForCurrentProcess()->HasSwitch(
887 switches::kEnablePluginPowerSaver);
888
889 if (is_peripheral_content_) {
890 // To collect UMAs, register peripheral content even if we don't throttle.
891 power_saver_helper->RegisterPeripheralPlugin(
892 content_origin,
893 base::Bind(
894 &PepperPluginInstanceImpl::DisablePowerSaverByRetroactiveWhitelist,
895 weak_factory_.GetWeakPtr()));
896
897 if (power_saver_enabled_) {
898 throttler_.reset(new PepperPluginInstanceThrottler(
899 base::Bind(&PepperPluginInstanceImpl::SetPluginThrottled,
900 weak_factory_.GetWeakPtr(), true /* throttled */)));
901 }
902 } else if (cross_origin) {
903 power_saver_helper->WhitelistContentOrigin(content_origin);
904 }
905 846
906 message_channel_ = MessageChannel::Create(this, &message_channel_object_); 847 message_channel_ = MessageChannel::Create(this, &message_channel_object_);
907 848
908 full_frame_ = full_frame; 849 full_frame_ = full_frame;
909 850
910 UpdateTouchEventRequest(); 851 UpdateTouchEventRequest();
911 container_->setWantsWheelEvents(IsAcceptingWheelEvents()); 852 container_->setWantsWheelEvents(IsAcceptingWheelEvents());
912 853
913 SetGPUHistogram(ppapi::Preferences(PpapiPreferencesBuilder::Build( 854 SetGPUHistogram(ppapi::Preferences(PpapiPreferencesBuilder::Build(
914 render_frame_->render_view()->webkit_preferences())), 855 render_frame_->render_view()->webkit_preferences())),
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 gfx::Rect caret(text_input_caret_); 1092 gfx::Rect caret(text_input_caret_);
1152 caret.Offset(view_data_.rect.point.x, view_data_.rect.point.y); 1093 caret.Offset(view_data_.rect.point.x, view_data_.rect.point.y);
1153 return caret; 1094 return caret;
1154 } 1095 }
1155 1096
1156 bool PepperPluginInstanceImpl::HandleInputEvent( 1097 bool PepperPluginInstanceImpl::HandleInputEvent(
1157 const blink::WebInputEvent& event, 1098 const blink::WebInputEvent& event,
1158 WebCursorInfo* cursor_info) { 1099 WebCursorInfo* cursor_info) {
1159 TRACE_EVENT0("ppapi", "PepperPluginInstanceImpl::HandleInputEvent"); 1100 TRACE_EVENT0("ppapi", "PepperPluginInstanceImpl::HandleInputEvent");
1160 1101
1161 if (event.type == blink::WebInputEvent::MouseUp && is_peripheral_content_) { 1102 if (throttler_->ConsumeInputEvent(event))
1162 is_peripheral_content_ = false; 1103 return true;
1163 power_saver_enabled_ = false;
1164
1165 RecordUnthrottleMethodMetric(UNTHROTTLE_METHOD_BY_CLICK);
1166
1167 if (plugin_throttled_) {
1168 SetPluginThrottled(false /* throttled */);
1169 return true;
1170 }
1171 }
1172 1104
1173 if (!render_frame_) 1105 if (!render_frame_)
1174 return false; 1106 return false;
1175 if (WebInputEvent::isMouseEventType(event.type)) { 1107 if (WebInputEvent::isMouseEventType(event.type)) {
1176 render_frame_->PepperDidReceiveMouseEvent(this); 1108 render_frame_->PepperDidReceiveMouseEvent(this);
1177 } 1109 }
1178 1110
1179 // Don't dispatch input events to crashed plugins. 1111 // Don't dispatch input events to crashed plugins.
1180 if (module()->is_crashed()) 1112 if (module()->is_crashed())
1181 return false; 1113 return false;
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 view_change_weak_ptr_factory_.InvalidateWeakPtrs(); 1646 view_change_weak_ptr_factory_.InvalidateWeakPtrs();
1715 SendDidChangeView(); 1647 SendDidChangeView();
1716 } 1648 }
1717 1649
1718 void PepperPluginInstanceImpl::SendDidChangeView() { 1650 void PepperPluginInstanceImpl::SendDidChangeView() {
1719 // Don't send DidChangeView to crashed plugins. 1651 // Don't send DidChangeView to crashed plugins.
1720 if (module()->is_crashed()) 1652 if (module()->is_crashed())
1721 return; 1653 return;
1722 1654
1723 // When plugin is throttled, send ViewData indicating it's in the background. 1655 // When plugin is throttled, send ViewData indicating it's in the background.
1724 const ppapi::ViewData& view_data = 1656 const ppapi::ViewData& view_data = throttler_->is_throttled()
1725 plugin_throttled_ ? empty_view_data_ : view_data_; 1657 ? throttler_->throttled_view_data()
1658 : view_data_;
1726 1659
1727 if (view_change_weak_ptr_factory_.HasWeakPtrs() || 1660 if (view_change_weak_ptr_factory_.HasWeakPtrs() ||
1728 (sent_initial_did_change_view_ && 1661 (sent_initial_did_change_view_ &&
1729 last_sent_view_data_.Equals(view_data))) 1662 last_sent_view_data_.Equals(view_data)))
1730 return; // Nothing to update. 1663 return; // Nothing to update.
1731 1664
1732 sent_initial_did_change_view_ = true; 1665 sent_initial_did_change_view_ = true;
1733 last_sent_view_data_ = view_data; 1666 last_sent_view_data_ = view_data;
1734 ScopedPPResource resource( 1667 ScopedPPResource resource(
1735 ScopedPPResource::PassRef(), 1668 ScopedPPResource::PassRef(),
(...skipping 1609 matching lines...) Expand 10 before | Expand all | Expand 10 after
3345 } else { 3278 } else {
3346 // Running out-of-process. Initiate an IPC call to notify the plugin 3279 // Running out-of-process. Initiate an IPC call to notify the plugin
3347 // process. 3280 // process.
3348 ppapi::proxy::HostDispatcher* dispatcher = 3281 ppapi::proxy::HostDispatcher* dispatcher =
3349 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); 3282 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance());
3350 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( 3283 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad(
3351 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); 3284 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data));
3352 } 3285 }
3353 } 3286 }
3354 3287
3355 void PepperPluginInstanceImpl::SetPluginThrottled(bool throttled) {
3356 // Do not throttle if we've already disabled power saver.
3357 if (!power_saver_enabled_ && throttled)
3358 return;
3359
3360 plugin_throttled_ = throttled;
3361 SendDidChangeView();
3362 }
3363
3364 void PepperPluginInstanceImpl::DisablePowerSaverByRetroactiveWhitelist() {
3365 if (!is_peripheral_content_)
3366 return;
3367
3368 is_peripheral_content_ = false;
3369 power_saver_enabled_ = false;
3370 SetPluginThrottled(false);
3371
3372 RecordUnthrottleMethodMetric(UNTHROTTLE_METHOD_BY_WHITELIST);
3373 }
3374
3375 } // namespace content 3288 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_plugin_instance_impl.h ('k') | content/renderer/pepper/pepper_plugin_instance_throttler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698