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

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

Issue 863813002: Plugin Power Saver: Make Unthrottle metric collection more consistent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/plugin_instance_throttler_impl.h" 5 #include "content/renderer/pepper/plugin_instance_throttler_impl.h"
6 6
7 #include "base/metrics/histogram.h"
8 #include "base/time/time.h" 7 #include "base/time/time.h"
9 #include "content/public/common/content_constants.h" 8 #include "content/public/common/content_constants.h"
10 #include "content/public/renderer/render_frame.h" 9 #include "content/public/renderer/render_frame.h"
11 #include "content/public/renderer/render_thread.h" 10 #include "content/public/renderer/render_thread.h"
12 #include "third_party/WebKit/public/web/WebInputEvent.h" 11 #include "third_party/WebKit/public/web/WebInputEvent.h"
13 #include "ui/gfx/color_utils.h" 12 #include "ui/gfx/color_utils.h"
14 #include "url/gurl.h" 13 #include "url/gurl.h"
15 14
16 namespace content { 15 namespace content {
17 16
18 namespace { 17 namespace {
19 18
20 const char kPowerSaverUnthrottleHistogram[] = "Plugin.PowerSaver.Unthrottle";
21
22 void RecordUnthrottleMethodMetric(
23 PluginInstanceThrottlerImpl::PowerSaverUnthrottleMethod method) {
24 UMA_HISTOGRAM_ENUMERATION(
25 kPowerSaverUnthrottleHistogram, method,
26 PluginInstanceThrottler::UNTHROTTLE_METHOD_NUM_ITEMS);
27 }
28
29 // When we give up waiting for a suitable preview frame, and simply suspend 19 // When we give up waiting for a suitable preview frame, and simply suspend
30 // the plugin where it's at. In milliseconds. 20 // the plugin where it's at. In milliseconds.
31 const int kThrottleTimeout = 5000; 21 const int kThrottleTimeout = 5000;
32 22
33 // Threshold for 'boring' score to accept a frame as good enough to be a 23 // Threshold for 'boring' score to accept a frame as good enough to be a
34 // representative keyframe. Units are the ratio of all pixels that are within 24 // representative keyframe. Units are the ratio of all pixels that are within
35 // the most common luma bin. The same threshold is used for history thumbnails. 25 // the most common luma bin. The same threshold is used for history thumbnails.
36 const double kAcceptableFrameMaximumBoringness = 0.94; 26 const double kAcceptableFrameMaximumBoringness = 0.94;
37 27
38 const int kMinimumConsecutiveInterestingFrames = 4; 28 const int kMinimumConsecutiveInterestingFrames = 4;
(...skipping 18 matching lines...) Expand all
57 47
58 if (power_saver_enabled) { 48 if (power_saver_enabled) {
59 base::MessageLoop::current()->PostDelayedTask( 49 base::MessageLoop::current()->PostDelayedTask(
60 FROM_HERE, base::Bind(&PluginInstanceThrottlerImpl::EngageThrottle, 50 FROM_HERE, base::Bind(&PluginInstanceThrottlerImpl::EngageThrottle,
61 weak_factory_.GetWeakPtr()), 51 weak_factory_.GetWeakPtr()),
62 base::TimeDelta::FromMilliseconds(kThrottleTimeout)); 52 base::TimeDelta::FromMilliseconds(kThrottleTimeout));
63 } 53 }
64 } 54 }
65 55
66 PluginInstanceThrottlerImpl::~PluginInstanceThrottlerImpl() { 56 PluginInstanceThrottlerImpl::~PluginInstanceThrottlerImpl() {
57 if (state_ != PLUGIN_INSTANCE_MARKED_ESSENTIAL)
58 RecordUnthrottleMethodMetric(UNTHROTTLE_METHOD_NEVER);
67 } 59 }
68 60
69 void PluginInstanceThrottlerImpl::AddObserver(Observer* observer) { 61 void PluginInstanceThrottlerImpl::AddObserver(Observer* observer) {
70 observer_list_.AddObserver(observer); 62 observer_list_.AddObserver(observer);
71 } 63 }
72 64
73 void PluginInstanceThrottlerImpl::RemoveObserver(Observer* observer) { 65 void PluginInstanceThrottlerImpl::RemoveObserver(Observer* observer) {
74 observer_list_.RemoveObserver(observer); 66 observer_list_.RemoveObserver(observer);
75 } 67 }
76 68
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 120
129 void PluginInstanceThrottlerImpl::EngageThrottle() { 121 void PluginInstanceThrottlerImpl::EngageThrottle() {
130 if (state_ != POWER_SAVER_ENABLED_AWAITING_KEYFRAME) 122 if (state_ != POWER_SAVER_ENABLED_AWAITING_KEYFRAME)
131 return; 123 return;
132 124
133 state_ = POWER_SAVER_ENABLED_PLUGIN_THROTTLED; 125 state_ = POWER_SAVER_ENABLED_PLUGIN_THROTTLED;
134 FOR_EACH_OBSERVER(Observer, observer_list_, OnThrottleStateChange()); 126 FOR_EACH_OBSERVER(Observer, observer_list_, OnThrottleStateChange());
135 } 127 }
136 128
137 } // namespace content 129 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698