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

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

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 #ifndef CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_ 5 #ifndef CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_
6 #define CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_ 6 #define CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
11 #include "base/timer/timer.h" 11 #include "base/timer/timer.h"
12 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
13 #include "content/public/renderer/plugin_instance_throttler.h" 13 #include "content/public/renderer/plugin_instance_throttler.h"
14 #include "ppapi/shared_impl/ppb_view_shared.h" 14 #include "ppapi/shared_impl/ppb_view_shared.h"
15 #include "third_party/skia/include/core/SkBitmap.h" 15 #include "third_party/skia/include/core/SkBitmap.h"
16 16
17 namespace blink { 17 namespace blink {
18 class WebInputEvent; 18 class WebInputEvent;
19 struct WebRect; 19 struct WebRect;
20 } 20 }
21 21
22 namespace content { 22 namespace content {
23 23
24 class RenderFrameImpl; 24 class RenderFrameImpl;
25 25
26 class CONTENT_EXPORT PluginInstanceThrottlerImpl 26 class CONTENT_EXPORT PluginInstanceThrottlerImpl
27 : public PluginInstanceThrottler { 27 : public PluginInstanceThrottler {
28 public: 28 public:
29 PluginInstanceThrottlerImpl(bool power_saver_enabled); 29 PluginInstanceThrottlerImpl();
30 30
31 ~PluginInstanceThrottlerImpl() override; 31 ~PluginInstanceThrottlerImpl() override;
32 32
33 // PluginInstanceThrottler implementation: 33 // PluginInstanceThrottler implementation:
34 void AddObserver(Observer* observer) override; 34 void AddObserver(Observer* observer) override;
35 void RemoveObserver(Observer* observer) override; 35 void RemoveObserver(Observer* observer) override;
36 bool IsThrottled() const override; 36 bool IsThrottled() const override;
37 bool IsHiddenForPlaceholder() const override; 37 bool IsHiddenForPlaceholder() const override;
38 void MarkPluginEssential(PowerSaverUnthrottleMethod method) override; 38 void MarkPluginEssential(PowerSaverUnthrottleMethod method) override;
39 void SetHiddenForPlaceholder(bool hidden) override; 39 void SetHiddenForPlaceholder(bool hidden) override;
40 blink::WebPlugin* GetWebPlugin() const override; 40 blink::WebPlugin* GetWebPlugin() const override;
41 void NotifyAudioThrottled() override; 41 void NotifyAudioThrottled() override;
42 42
43 void SetWebPlugin(blink::WebPlugin* web_plugin); 43 void SetWebPlugin(blink::WebPlugin* web_plugin);
44 44
45 bool needs_representative_keyframe() const { 45 bool needs_representative_keyframe() const {
46 return state_ == THROTTLER_STATE_AWAITING_KEYFRAME; 46 return state_ == THROTTLER_STATE_AWAITING_KEYFRAME;
47 } 47 }
48 48
49 bool power_saver_enabled() const { 49 bool power_saver_enabled() const {
50 return state_ == THROTTLER_STATE_AWAITING_KEYFRAME || 50 return state_ != THROTTLER_STATE_MARKED_ESSENTIAL;
51 state_ == THROTTLER_STATE_PLUGIN_THROTTLED;
52 } 51 }
53 52
54 // Throttler needs to be initialized with the real plugin's view bounds. 53 // Throttler needs to be initialized with the real plugin's view bounds.
55 void Initialize(RenderFrameImpl* frame, 54 void Initialize(RenderFrameImpl* frame,
56 const GURL& content_origin, 55 const GURL& content_origin,
57 const std::string& plugin_module_name, 56 const std::string& plugin_module_name,
58 const blink::WebRect& bounds); 57 const blink::WebRect& bounds);
59 58
60 // Called when the plugin flushes it's graphics context. Supplies the 59 // Called when the plugin flushes it's graphics context. Supplies the
61 // throttler with a candidate to use as the representative keyframe. 60 // throttler with a candidate to use as the representative keyframe.
62 void OnImageFlush(const SkBitmap* bitmap); 61 void OnImageFlush(const SkBitmap* bitmap);
63 62
64 // Returns true if |event| was handled and shouldn't be further processed. 63 // Returns true if |event| was handled and shouldn't be further processed.
65 bool ConsumeInputEvent(const blink::WebInputEvent& event); 64 bool ConsumeInputEvent(const blink::WebInputEvent& event);
66 65
67 private: 66 private:
68 friend class PluginInstanceThrottlerImplTest; 67 friend class PluginInstanceThrottlerImplTest;
69 68
70 enum ThrottlerState { 69 enum ThrottlerState {
71 // Power saver is disabled, but the plugin instance is still peripheral.
72 THROTTLER_STATE_POWER_SAVER_DISABLED,
73 // Plugin has been found to be peripheral, Plugin Power Saver is enabled, 70 // Plugin has been found to be peripheral, Plugin Power Saver is enabled,
74 // and throttler is awaiting a representative keyframe. 71 // and throttler is awaiting a representative keyframe.
75 THROTTLER_STATE_AWAITING_KEYFRAME, 72 THROTTLER_STATE_AWAITING_KEYFRAME,
76 // A representative keyframe has been chosen and the plugin is throttled. 73 // A representative keyframe has been chosen and the plugin is throttled.
77 THROTTLER_STATE_PLUGIN_THROTTLED, 74 THROTTLER_STATE_PLUGIN_THROTTLED,
78 // Plugin instance has been marked essential. 75 // Plugin instance has been marked essential.
79 THROTTLER_STATE_MARKED_ESSENTIAL, 76 THROTTLER_STATE_MARKED_ESSENTIAL,
80 }; 77 };
81 78
82 // Maximum number of frames to examine for a suitable keyframe. After that, we 79 // Maximum number of frames to examine for a suitable keyframe. After that, we
(...skipping 26 matching lines...) Expand all
109 106
110 ObserverList<Observer> observer_list_; 107 ObserverList<Observer> observer_list_;
111 108
112 base::WeakPtrFactory<PluginInstanceThrottlerImpl> weak_factory_; 109 base::WeakPtrFactory<PluginInstanceThrottlerImpl> weak_factory_;
113 110
114 DISALLOW_COPY_AND_ASSIGN(PluginInstanceThrottlerImpl); 111 DISALLOW_COPY_AND_ASSIGN(PluginInstanceThrottlerImpl);
115 }; 112 };
116 } 113 }
117 114
118 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_ 115 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_INSTANCE_THROTTLER_IMPL_H_
OLDNEW
« no previous file with comments | « content/public/renderer/plugin_instance_throttler.h ('k') | content/renderer/pepper/plugin_instance_throttler_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698