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

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

Issue 1024493004: Plugin Power Saver: Record PPS UMAs only for users with PPS enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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" 7 #include "base/metrics/histogram.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "content/public/common/content_constants.h" 9 #include "content/public/common/content_constants.h"
10 #include "content/public/renderer/render_thread.h" 10 #include "content/public/renderer/render_thread.h"
(...skipping 19 matching lines...) Expand all
30 // video frames. We use this timeout to prevent waiting forever for a good 30 // video frames. We use this timeout to prevent waiting forever for a good
31 // poster image. Chosen arbitrarily. 31 // poster image. Chosen arbitrarily.
32 const int kAudioThrottledFrameTimeoutMilliseconds = 500; 32 const int kAudioThrottledFrameTimeoutMilliseconds = 500;
33 33
34 } // namespace 34 } // namespace
35 35
36 // static 36 // static
37 const int PluginInstanceThrottlerImpl::kMaximumFramesToExamine = 150; 37 const int PluginInstanceThrottlerImpl::kMaximumFramesToExamine = 150;
38 38
39 // static 39 // static
40 scoped_ptr<PluginInstanceThrottler> PluginInstanceThrottler::Create( 40 scoped_ptr<PluginInstanceThrottler> PluginInstanceThrottler::Create() {
41 bool power_saver_enabled) { 41 return make_scoped_ptr(new PluginInstanceThrottlerImpl);
42 return make_scoped_ptr(new PluginInstanceThrottlerImpl(power_saver_enabled));
43 } 42 }
44 43
45 // static 44 // static
46 void PluginInstanceThrottler::RecordUnthrottleMethodMetric( 45 void PluginInstanceThrottler::RecordUnthrottleMethodMetric(
47 PluginInstanceThrottlerImpl::PowerSaverUnthrottleMethod method) { 46 PluginInstanceThrottlerImpl::PowerSaverUnthrottleMethod method) {
48 UMA_HISTOGRAM_ENUMERATION( 47 UMA_HISTOGRAM_ENUMERATION(
49 "Plugin.PowerSaver.Unthrottle", method, 48 "Plugin.PowerSaver.Unthrottle", method,
50 PluginInstanceThrottler::UNTHROTTLE_METHOD_NUM_ITEMS); 49 PluginInstanceThrottler::UNTHROTTLE_METHOD_NUM_ITEMS);
51 } 50 }
52 51
53 PluginInstanceThrottlerImpl::PluginInstanceThrottlerImpl( 52 PluginInstanceThrottlerImpl::PluginInstanceThrottlerImpl()
54 bool power_saver_enabled) 53 : state_(THROTTLER_STATE_AWAITING_KEYFRAME),
55 : state_(power_saver_enabled ? THROTTLER_STATE_AWAITING_KEYFRAME
56 : THROTTLER_STATE_POWER_SAVER_DISABLED),
57 is_hidden_for_placeholder_(false), 54 is_hidden_for_placeholder_(false),
58 web_plugin_(nullptr), 55 web_plugin_(nullptr),
59 consecutive_interesting_frames_(0), 56 consecutive_interesting_frames_(0),
60 frames_examined_(0), 57 frames_examined_(0),
61 audio_throttled_(false), 58 audio_throttled_(false),
62 audio_throttled_frame_timeout_( 59 audio_throttled_frame_timeout_(
63 FROM_HERE, 60 FROM_HERE,
64 base::TimeDelta::FromMilliseconds( 61 base::TimeDelta::FromMilliseconds(
65 kAudioThrottledFrameTimeoutMilliseconds), 62 kAudioThrottledFrameTimeoutMilliseconds),
66 this, 63 this,
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 204
208 // Release our reference to the underlying pixel data. 205 // Release our reference to the underlying pixel data.
209 last_received_frame_.reset(); 206 last_received_frame_.reset();
210 } 207 }
211 208
212 state_ = THROTTLER_STATE_PLUGIN_THROTTLED; 209 state_ = THROTTLER_STATE_PLUGIN_THROTTLED;
213 FOR_EACH_OBSERVER(Observer, observer_list_, OnThrottleStateChange()); 210 FOR_EACH_OBSERVER(Observer, observer_list_, OnThrottleStateChange());
214 } 211 }
215 212
216 } // namespace content 213 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698